結果

問題 No.1281 Cigarette Distribution
ユーザー yamakeyamake
提出日時 2020-11-07 11:34:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 1,016 ms
コンパイル使用メモリ 80,368 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 20:29:51
合計ジャッジ時間 2,604 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 14 ms
4,380 KB
testcase_13 AC 33 ms
4,380 KB
testcase_14 AC 25 ms
4,380 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 20 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 54 ms
4,380 KB
testcase_19 AC 53 ms
4,376 KB
testcase_20 AC 53 ms
4,376 KB
testcase_21 AC 28 ms
4,380 KB
testcase_22 AC 35 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
long long myPow(int x,int n,int rest){
    int res=1;
    int cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
            res%=rest;
        }
        n/=2;cur*=cur;
        cur%=rest;
    }
    return res;
}
signed main(){
  int n,m;cin>>n>>m;
  rep1(x,m){
    lint res=1;
    int base=n/x;
    int rest=n%x;
    res*=base-1;
    res*=myPow(base,x-1-rest-1,MOD);
    res%=MOD;
    res*=myPow(base+1,rest+1,MOD);
    res%=MOD;
    if(x==1)res=n;
    if(rest==x-1){
      res=base*myPow(base+1,x-1,MOD);
      res%=MOD;
    }
    cout<<res<<"\n";
  }
  return 0;
}
0