結果

問題 No.1281 Cigarette Distribution
コンテスト
ユーザー face4
提出日時 2020-12-06 13:42:44
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 693 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 353 ms
コンパイル使用メモリ 74,992 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-06 07:19:15
合計ジャッジ時間 2,229 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    cout << n << endl;
    for(int i = 2; i <= m; i++){
        if(n+1 < 2*i){
            cout << 0 << endl;
        }else if(i == 2){
            cout << n/2*(n-n/2)%mod << endl;    
        }else{ 
            int j = i-1;
            int x = n-1;
            cout << modpow(x/j, j-x%j)*modpow(x/j+1, x%j)%mod << endl;
        }
    }
    return 0;
}
0