結果
| 問題 | No.1281 Cigarette Distribution | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-11-06 23:48:19 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 47 ms / 2,000 ms | 
| コード長 | 673 bytes | 
| コンパイル時間 | 1,351 ms | 
| コンパイル使用メモリ | 166,732 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 13:49:42 | 
| 合計ジャッジ時間 | 3,008 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll modpow(ll a,ll b){
    ll ans = 1;
    a %= mod;
    while(b){
        if(b&1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N,M; cin >> N >> M;
    for(int i=1;i<=M;i++){
        if(N % i == i - 1){
            cout << modpow((N + 1) / i, i - 1) * (N / i) % mod << '\n';
        }else{
            cout << modpow(N / i + 1, N % i + 1) * modpow(N / i, i - 2 - N % i) % mod * (N / i - 1) % mod << '\n';
        }
    }
}
            
            
            
        