結果

問題 No.1281 Cigarette Distribution
ユーザー tonyu0tonyu0
提出日時 2020-11-07 15:52:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 94,248 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 20:35:20
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)

constexpr ll MOD = 1000000007;

ll mpow(ll x, ll e) {
  ll res = 1;
  while (e > 0) {
    if (e & 1) res = res * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, 1, m + 1) {
    ll q = (n + 1) / i;
    ll r = (n + 1) % i;
    cout << mpow(q + 1, r) * (q - 1) % MOD * mpow(q, i - r - 1) % MOD << '\n';
  }
  return 0;
}
0