結果

問題 No.1281 Cigarette Distribution
ユーザー platinum
提出日時 2020-11-04 16:24:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 67,356 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 09:58:02
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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