結果

問題 No.1260 たくさんの多項式
ユーザー tonyu0tonyu0
提出日時 2020-10-17 15:05:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 77,020 KB
最終ジャッジ日時 2023-09-28 08:03:36
合計ジャッジ時間 11,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,512 KB
testcase_01 AC 83 ms
76,716 KB
testcase_02 AC 82 ms
76,712 KB
testcase_03 AC 82 ms
76,400 KB
testcase_04 AC 83 ms
76,532 KB
testcase_05 AC 81 ms
76,692 KB
testcase_06 AC 82 ms
76,516 KB
testcase_07 AC 81 ms
76,424 KB
testcase_08 AC 81 ms
76,676 KB
testcase_09 AC 82 ms
76,676 KB
testcase_10 AC 80 ms
76,564 KB
testcase_11 AC 80 ms
76,584 KB
testcase_12 AC 79 ms
76,396 KB
testcase_13 AC 80 ms
76,520 KB
testcase_14 AC 81 ms
76,752 KB
testcase_15 AC 78 ms
76,504 KB
testcase_16 AC 81 ms
76,676 KB
testcase_17 AC 81 ms
76,784 KB
testcase_18 AC 81 ms
76,508 KB
testcase_19 AC 82 ms
76,516 KB
testcase_20 AC 222 ms
76,660 KB
testcase_21 AC 117 ms
76,740 KB
testcase_22 AC 199 ms
76,508 KB
testcase_23 AC 177 ms
76,676 KB
testcase_24 AC 182 ms
76,580 KB
testcase_25 AC 161 ms
76,716 KB
testcase_26 AC 177 ms
76,876 KB
testcase_27 AC 157 ms
76,716 KB
testcase_28 AC 217 ms
76,640 KB
testcase_29 AC 180 ms
76,948 KB
testcase_30 AC 145 ms
76,580 KB
testcase_31 AC 181 ms
76,524 KB
testcase_32 AC 180 ms
76,604 KB
testcase_33 AC 162 ms
76,884 KB
testcase_34 AC 210 ms
76,716 KB
testcase_35 AC 144 ms
76,644 KB
testcase_36 AC 132 ms
76,692 KB
testcase_37 AC 184 ms
76,688 KB
testcase_38 AC 190 ms
77,020 KB
testcase_39 AC 214 ms
76,748 KB
testcase_40 AC 184 ms
76,716 KB
testcase_41 AC 207 ms
76,764 KB
testcase_42 AC 174 ms
76,580 KB
testcase_43 AC 209 ms
76,680 KB
testcase_44 AC 161 ms
76,848 KB
testcase_45 AC 163 ms
76,676 KB
testcase_46 AC 156 ms
76,512 KB
testcase_47 AC 174 ms
76,740 KB
testcase_48 AC 97 ms
76,408 KB
testcase_49 AC 150 ms
76,764 KB
testcase_50 AC 116 ms
76,712 KB
testcase_51 AC 213 ms
76,700 KB
testcase_52 AC 125 ms
76,396 KB
testcase_53 AC 140 ms
76,720 KB
testcase_54 AC 215 ms
76,744 KB
testcase_55 AC 222 ms
76,712 KB
testcase_56 AC 147 ms
76,608 KB
testcase_57 AC 176 ms
76,648 KB
testcase_58 AC 139 ms
76,528 KB
testcase_59 AC 182 ms
76,668 KB
testcase_60 AC 225 ms
76,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
mod = 10 ** 9 + 7

ans = 0
# 次数が2次以上
# nをi進数に直すイメージ
for i in range(2, int(n ** .5) + 1):
    now = n
    while now > 0:
        ans += now % i  # 下の桁から埋める
        now //= i
    ans += now
    ans %= mod

# i * x + jを考える
sq = int(n ** .5) + 1
for i in range(1, sq):
    l = n // (i + 1) + 1  # xの係数がiである数のうち、最も小さい
    if l < sq:  # これは2次以上で数えた
        break
    r = n // i  # 最もでかい
    m = r - l + 1
    one = i * m  # xの係数の合計

    # 0次の係数について考える
    # 区間[l, r]の数は連続してるので、総和でうまくいける
    # 初項n % r, 公差i 項数 m → 総和
    zero = m * (2 * (n % r) + (m - 1) * i) // 2 % mod
    ans = (ans + one + zero) % mod
print(ans)
0