結果

問題 No.1281 Cigarette Distribution
ユーザー kk
提出日時 2020-12-25 19:08:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 202,012 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 18:44:54
合計ジャッジ時間 5,244 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 74 ms
4,348 KB
testcase_13 AC 175 ms
4,348 KB
testcase_14 AC 126 ms
4,348 KB
testcase_15 AC 88 ms
4,348 KB
testcase_16 AC 109 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 290 ms
4,348 KB
testcase_19 AC 291 ms
4,348 KB
testcase_20 AC 291 ms
4,348 KB
testcase_21 AC 146 ms
4,348 KB
testcase_22 AC 180 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

const long long MOD = 1e9 + 7;

long long modpow(long long x, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= m; i++) {
    int r = (n + 1) / i;
    int q = (n + 1) % i;

    long long ret = 0;
    if (q == 0) {
      ret = (r-1) * modpow(r, i-1, MOD) % MOD;
    } else {
      ret = (r-1) * modpow(r, i-q-1, MOD) % MOD * modpow(r+1, q, MOD) % MOD;
    }
    
    cout << ret << endl;
  }
  
  return 0;
}
0