結果
問題 | No.1276 3枚のカード |
ユーザー | LyricalMaestro |
提出日時 | 2024-10-19 03:49:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 935 ms / 2,000 ms |
コード長 | 2,734 bytes |
コンパイル時間 | 900 ms |
コンパイル使用メモリ | 82,212 KB |
実行使用メモリ | 83,268 KB |
最終ジャッジ日時 | 2024-10-19 03:49:34 |
合計ジャッジ時間 | 31,392 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,980 KB |
testcase_01 | AC | 38 ms
53,092 KB |
testcase_02 | AC | 38 ms
53,628 KB |
testcase_03 | AC | 36 ms
54,000 KB |
testcase_04 | AC | 37 ms
53,672 KB |
testcase_05 | AC | 36 ms
53,512 KB |
testcase_06 | AC | 37 ms
53,792 KB |
testcase_07 | AC | 36 ms
53,616 KB |
testcase_08 | AC | 36 ms
52,932 KB |
testcase_09 | AC | 36 ms
53,768 KB |
testcase_10 | AC | 829 ms
83,004 KB |
testcase_11 | AC | 412 ms
79,528 KB |
testcase_12 | AC | 532 ms
80,492 KB |
testcase_13 | AC | 540 ms
80,540 KB |
testcase_14 | AC | 111 ms
77,292 KB |
testcase_15 | AC | 436 ms
80,040 KB |
testcase_16 | AC | 873 ms
82,724 KB |
testcase_17 | AC | 493 ms
80,192 KB |
testcase_18 | AC | 400 ms
79,852 KB |
testcase_19 | AC | 591 ms
81,364 KB |
testcase_20 | AC | 385 ms
79,232 KB |
testcase_21 | AC | 387 ms
79,456 KB |
testcase_22 | AC | 876 ms
82,768 KB |
testcase_23 | AC | 107 ms
77,432 KB |
testcase_24 | AC | 561 ms
80,764 KB |
testcase_25 | AC | 237 ms
78,748 KB |
testcase_26 | AC | 696 ms
81,964 KB |
testcase_27 | AC | 799 ms
82,288 KB |
testcase_28 | AC | 729 ms
82,316 KB |
testcase_29 | AC | 468 ms
79,952 KB |
testcase_30 | AC | 146 ms
77,780 KB |
testcase_31 | AC | 102 ms
77,020 KB |
testcase_32 | AC | 242 ms
78,408 KB |
testcase_33 | AC | 76 ms
74,532 KB |
testcase_34 | AC | 193 ms
77,864 KB |
testcase_35 | AC | 186 ms
78,096 KB |
testcase_36 | AC | 76 ms
76,472 KB |
testcase_37 | AC | 186 ms
77,972 KB |
testcase_38 | AC | 140 ms
77,472 KB |
testcase_39 | AC | 249 ms
78,612 KB |
testcase_40 | AC | 851 ms
83,080 KB |
testcase_41 | AC | 695 ms
82,180 KB |
testcase_42 | AC | 779 ms
82,452 KB |
testcase_43 | AC | 670 ms
81,604 KB |
testcase_44 | AC | 932 ms
82,368 KB |
testcase_45 | AC | 857 ms
83,268 KB |
testcase_46 | AC | 855 ms
83,084 KB |
testcase_47 | AC | 697 ms
82,380 KB |
testcase_48 | AC | 700 ms
81,524 KB |
testcase_49 | AC | 750 ms
82,648 KB |
testcase_50 | AC | 859 ms
82,976 KB |
testcase_51 | AC | 750 ms
82,512 KB |
testcase_52 | AC | 613 ms
81,464 KB |
testcase_53 | AC | 733 ms
82,020 KB |
testcase_54 | AC | 815 ms
82,876 KB |
testcase_55 | AC | 673 ms
81,960 KB |
testcase_56 | AC | 643 ms
81,276 KB |
testcase_57 | AC | 782 ms
82,916 KB |
testcase_58 | AC | 830 ms
82,984 KB |
testcase_59 | AC | 717 ms
82,100 KB |
testcase_60 | AC | 935 ms
82,712 KB |
ソースコード
## https://yukicoder.me/problems/no/1276 import math MOD = 10 ** 9 + 7 def main(): N = int(input()) sqrt_n = int(math.sqrt(N)) # B <= sqrt_nのケースを考える answer1 = 0 for b in range(1, sqrt_n + 1): c_num = N // b - 1 sqrt_b = int(math.sqrt(b)) a_num = 0 for a in range(1, sqrt_b + 1): if b % a == 0: a_ = b // a a_num += 1 if a_ != a: a_num += 1 a_num = N - N // b - (a_num - 1) ans_num = (c_num * a_num) % MOD answer1 += ans_num answer1 %= MOD # B > sqrt_nのケースを考える array = [] for r in range(2, sqrt_n + 2): upper = N // r lower = (N // (r + 1)) + 1 if upper <= sqrt_n: break lower = max(sqrt_n + 1, lower) array.append((lower, upper, r)) answer2 = 0 for lower, upper, r in array: total = (upper - lower + 1) total *= N total %= MOD total *= (r - 1) total %= MOD # 倍数を引く tot = (r * (upper - lower + 1)) % MOD tot *= (r - 1) tot %= MOD total -= tot total %= MOD # あらかじめ1は引いておく tot = ((r - 1) * (upper - lower + 1)) % MOD total -= tot total %= MOD sqrt_upper = int(math.sqrt(upper)) for p in range(2, sqrt_upper + 1): p2 = p * (p + 1) if p2 > upper: c = 0 if lower <= p ** 2: c += 1 else: lower2 = min(upper, max(p2, lower)) u1 = upper // p l1 = (lower2 - 1) // p b = 0 if lower <= p ** 2: b += 1 a = 2 * (u1 - l1) c = (a + b) % MOD c *= (r - 1) c %= MOD total -= c total %= MOD answer2 += total answer2 %= MOD answer = (answer1 + answer2) % MOD print(answer) def main2(): N = int(input()) # B <= sqrt_nのケースを考える answer1 = 0 for b in range(1, N + 1): c_num = N // b - 1 sqrt_b = int(math.sqrt(b)) a_num = 0 for a in range(1, sqrt_b + 1): if b % a == 0: a_ = b // a a_num += 1 if a_ != a: a_num += 1 a_num = N - N // b - (a_num - 1) ans_num = (c_num * a_num) % MOD answer1 += ans_num answer1 %= MOD print(answer1) if __name__ == "__main__": main()