結果
| 問題 | No.1281 Cigarette Distribution | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-11-06 21:59:34 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 251 ms / 2,000 ms | 
| コード長 | 850 bytes | 
| コンパイル時間 | 717 ms | 
| コンパイル使用メモリ | 71,680 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 12:47:30 | 
| 合計ジャッジ時間 | 3,400 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
const int MOD = 1e9 + 7;
long long repow(long long x, long long y){
    if(y == 0) return 1;
    long long res = 1;
    while(y > 0){
        if(y & 1) res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    for(int i = 1; i <= M; i++){
        if((i - 1) * 2 + 1 > N) cout << 0 << endl;
        else{
            long long t = N;
            t -= (i - 1) * 2 + 1;
            long long cnt = t / i;
            long long ama = t % i;
            long long ans = 1;
            ans = ans * repow(2 + cnt, i - 1 - ama) % MOD * repow(3 + cnt, ama) % MOD * (1 + cnt) % MOD;
            cout << ans << endl;
        }
    }
}
            
            
            
        