結果

問題 No.1281 Cigarette Distribution
ユーザー phsplsphspls
提出日時 2022-12-12 10:54:45
言語 Rust
(1.77.0)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 151,916 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 02:45:02
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 76 ms
5,376 KB
testcase_13 AC 179 ms
5,376 KB
testcase_14 AC 132 ms
5,376 KB
testcase_15 AC 88 ms
5,376 KB
testcase_16 AC 108 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 296 ms
5,376 KB
testcase_19 AC 300 ms
5,376 KB
testcase_20 AC 288 ms
5,376 KB
testcase_21 AC 148 ms
5,376 KB
testcase_22 AC 178 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const MOD: usize = 1e9 as usize + 7;

fn power(base: usize, times: usize) -> usize {
    if times == 0 { return 1usize; }
    if times == 1 { return base; }
    let temp = power(base, times/2);
    temp * temp % MOD * power(base, times%2) % MOD
}

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];

    for x in 1..=m {
        let base = (n+1) / x;
        let rest = (n+1) % x;
        println!("{}", power(base+1, rest) * (base-1) % MOD * power(base, x-rest-1) % MOD);
    }
}
0