結果

問題 No.1281 Cigarette Distribution
ユーザー 👑 platinumplatinum
提出日時 2020-05-17 18:45:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 67,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 01:26:12
合計ジャッジ時間 4,749 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 78 ms
4,380 KB
testcase_13 AC 180 ms
4,376 KB
testcase_14 AC 132 ms
4,380 KB
testcase_15 AC 91 ms
4,376 KB
testcase_16 AC 115 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 294 ms
4,376 KB
testcase_19 AC 306 ms
4,380 KB
testcase_20 AC 300 ms
4,380 KB
testcase_21 AC 150 ms
4,376 KB
testcase_22 AC 186 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const int Max_Num=2e5;
const LL mod=1e9+7;

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
	int N, M;
	cin >> N >> M;
	assert(N>=1 && N<=Max_Num);
	assert(M>=1 && M<=N);
	for(LL X=1; X<=M; X++){
		LL dis=(N+1)/X;
		LL rem=(N+1)%X;
		LL ans=modpow(dis,X-rem-1)*modpow(dis+1,rem)%mod;
		ans*=dis-1, ans%=mod;
		cout << ans << endl;
	}

	return 0;
}
0