結果
| 問題 |
No.681 Fractal Gravity Glue
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-18 04:14:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 639 bytes |
| コンパイル時間 | 564 ms |
| コンパイル使用メモリ | 61,468 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-18 04:14:47 |
| 合計ジャッジ時間 | 1,940 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d%d%d", &n, &b, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
using namespace std;
const int MOD = 1000000007;
int n, b, d, inv, ans;
int QMI(int a, int k) {
int ret = 1 % MOD;
while (k) {
if (k & 1) {
ret = 1LL * ret * a % MOD;
}
a = 1LL * a * a % MOD;
k >>= 1;
}
return ret;
}
int main() {
scanf("%d%d%d", &n, &b, &d);
ans = QMI(d + 1, b + 1) - 1;
(ans += MOD) %= MOD;
inv = QMI(d, MOD - 2);
ans = 1LL * ans * inv % MOD;
while (n > 0) {
ans = (ans - n % MOD + MOD) % MOD;
n /= (d + 1);
}
ans = (ans - (b + 1) + MOD) % MOD;
printf("%d\n", ans);
return 0;
}