結果

問題 No.1281 Cigarette Distribution
ユーザー platinumplatinum
提出日時 2020-11-04 16:24:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 67,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 15:48:46
合計ジャッジ時間 4,276 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 67 ms
4,380 KB
testcase_13 AC 160 ms
4,376 KB
testcase_14 AC 126 ms
4,376 KB
testcase_15 AC 78 ms
4,376 KB
testcase_16 AC 96 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 262 ms
4,376 KB
testcase_19 AC 263 ms
4,376 KB
testcase_20 AC 256 ms
4,380 KB
testcase_21 AC 130 ms
4,380 KB
testcase_22 AC 161 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using LL = long long;
const LL mod = 1e9+7;
const LL Max_N = 2e5;

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(){
  LL N, M;
  cin >> N >> M;
  assert(1 <= N and N <= Max_N);
  assert(1 <= M and M <= N);
  for(LL X = 1; X <= M; X++){
  	LL q = (N + 1) / X, r = (N + 1) % X;
  	LL ans = modpow(q + 1, r) * modpow(q, X - r - 1) % mod;
  	(ans *= q - 1) %= mod;
  	cout << ans << endl;
  }

  return 0;
}
0