結果
問題 |
No.3118 Increment or Multiply
|
ユーザー |
|
提出日時 | 2025-04-05 14:52:02 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 465 bytes |
コンパイル時間 | 3,540 ms |
コンパイル使用メモリ | 274,052 KB |
実行使用メモリ | 16,072 KB |
最終ジャッジ日時 | 2025-04-12 16:43:22 |
合計ジャッジ時間 | 7,257 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | WA * 5 TLE * 1 -- * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll t,n,a; ll f(ll i){ if(i == n) return 0; if(i * a > n) return n - i; return f(a * i) + 1; } int main(){ cin >> t; while(t--){ cin >> n >> a; if(a == 1){ cout << n * (n - 1) / 2 << endl; continue; } ll ans = 0; for(ll i = 1; i <= n; i++){ ans += f(i); } cout << ans << endl; } }