結果
問題 | No.1260 たくさんの多項式 |
ユーザー |
![]() |
提出日時 | 2020-10-16 23:30:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 259 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 81,980 KB |
実行使用メモリ | 75,848 KB |
最終ジャッジ日時 | 2024-07-21 00:07:10 |
合計ジャッジ時間 | 15,964 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 61 |
ソースコード
mod = 10**9+7 def f(n, i): res = 0 while n: res += n%i n //= i return res U = 10**6 n = int(input()) ans = 0 if n <= U: for i in range(2, n+1): ans += f(n, i) ans %= mod print(ans) exit() for i in range(2, U+1): ans += f(n, i) ans %= mod for k in range(1, U): left = max(U, n//(k+1))+1 right = n // k if right < left: continue cnt = right - left + 1 ans += cnt * k ans %= mod a = n%left b = n%right ans += (a+b)*cnt//2 ans %= mod print(ans)