結果

問題 No.1281 Cigarette Distribution
ユーザー tonyu0tonyu0
提出日時 2020-11-07 15:50:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 103,468 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 20:35:18
合計ジャッジ時間 2,728 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 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,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

[[maybe_unused]] 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;
    // rの箱にq+1, 1個の箱にq-1,
    cout << mpow(q + 1, r) * (q - 1) * mpow(q, i - r - 1) % MOD << '\n';
  }
  return 0;
}
0