結果

問題 No.1281 Cigarette Distribution
ユーザー nawawannawawan
提出日時 2020-11-06 21:59:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 71,076 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 18:43:20
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 70 ms
4,380 KB
testcase_13 AC 161 ms
4,376 KB
testcase_14 AC 120 ms
4,376 KB
testcase_15 AC 80 ms
4,380 KB
testcase_16 AC 103 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 260 ms
4,376 KB
testcase_19 AC 252 ms
4,376 KB
testcase_20 AC 250 ms
4,376 KB
testcase_21 AC 134 ms
4,376 KB
testcase_22 AC 163 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
        }
    }
}
0