結果
問題 | No.129 お年玉(2) |
ユーザー | バカらっく |
提出日時 | 2019-10-03 08:17:32 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,700 ms / 5,000 ms |
コード長 | 1,872 bytes |
コンパイル時間 | 414 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,696 KB |
最終ジャッジ日時 | 2024-10-03 06:06:59 |
合計ジャッジ時間 | 23,828 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
11,392 KB |
testcase_01 | AC | 1,700 ms
13,568 KB |
testcase_02 | AC | 31 ms
11,008 KB |
testcase_03 | AC | 31 ms
11,008 KB |
testcase_04 | AC | 32 ms
11,008 KB |
testcase_05 | AC | 634 ms
12,672 KB |
testcase_06 | AC | 455 ms
12,800 KB |
testcase_07 | AC | 818 ms
13,184 KB |
testcase_08 | AC | 877 ms
12,800 KB |
testcase_09 | AC | 403 ms
12,928 KB |
testcase_10 | AC | 936 ms
13,312 KB |
testcase_11 | AC | 502 ms
12,672 KB |
testcase_12 | AC | 193 ms
12,928 KB |
testcase_13 | AC | 198 ms
12,672 KB |
testcase_14 | AC | 460 ms
12,928 KB |
testcase_15 | AC | 400 ms
12,544 KB |
testcase_16 | AC | 548 ms
13,184 KB |
testcase_17 | AC | 356 ms
13,056 KB |
testcase_18 | AC | 839 ms
13,056 KB |
testcase_19 | AC | 1,158 ms
13,440 KB |
testcase_20 | AC | 669 ms
13,312 KB |
testcase_21 | AC | 427 ms
13,312 KB |
testcase_22 | AC | 585 ms
13,056 KB |
testcase_23 | AC | 920 ms
13,184 KB |
testcase_24 | AC | 1,318 ms
13,440 KB |
testcase_25 | AC | 475 ms
12,672 KB |
testcase_26 | AC | 704 ms
12,928 KB |
testcase_27 | AC | 650 ms
12,672 KB |
testcase_28 | AC | 661 ms
13,440 KB |
testcase_29 | AC | 32 ms
11,008 KB |
testcase_30 | AC | 30 ms
10,880 KB |
testcase_31 | AC | 30 ms
10,880 KB |
testcase_32 | AC | 31 ms
10,880 KB |
testcase_33 | AC | 31 ms
11,008 KB |
testcase_34 | AC | 34 ms
11,008 KB |
testcase_35 | AC | 35 ms
10,880 KB |
testcase_36 | AC | 39 ms
11,136 KB |
testcase_37 | AC | 37 ms
11,136 KB |
testcase_38 | AC | 120 ms
11,648 KB |
testcase_39 | AC | 123 ms
11,904 KB |
testcase_40 | AC | 252 ms
12,672 KB |
testcase_41 | AC | 332 ms
12,288 KB |
testcase_42 | AC | 180 ms
11,776 KB |
testcase_43 | AC | 79 ms
11,648 KB |
testcase_44 | AC | 1,403 ms
13,568 KB |
testcase_45 | AC | 118 ms
11,392 KB |
testcase_46 | AC | 95 ms
11,904 KB |
testcase_47 | AC | 1,164 ms
13,696 KB |
testcase_48 | AC | 895 ms
12,928 KB |
ソースコード
# -*- coding:utf-8 -*- def getPrimeList(num): flags = [False for i in range(num + 1)] primeList = [] for i in range(2, num + 1): if flags[i]: continue lastIndex = int(num / i) for j in range(1, lastIndex + 1): if i * j >= len(flags): break flags[j * i] = True primeList.append(i) return primeList def getPrimeDic(num, primeList): current = num dic = {} if num <=1: return dic for i in primeList: if current < i: break if current % i != 0: continue dic[i] = 0 while current % i == 0: current /= i dic[i] += 1 return dic def dicPlusDic(dic1:dict, dic2:dict): dic3 = {} for (i,v) in dic1.items(): dic3[i] = v for(i,v) in dic2.items(): if i in dic3.keys(): dic3[i] += v else: dic3[i] = v return dic3 def dicMinusDic(dic1:dict, dic2:dict): dic3 = {} for (i,v) in dic1.items(): dic3[i] = v for(i,v) in dic2.items(): if i in dic3.keys(): dic3[i] -= v if dic3[i] <= 0: del dic3[i] return dic3 yosan = int(input()) kodomo = int(input()) atari = int(yosan / 1000) % kodomo if atari == 0: print(1) exit(0) primeList = getPrimeList(kodomo) primeCount = [getPrimeDic(i, primeList) for i in range(0, kodomo + 1)] ansDic = {} for i in [kodomo - j for j in range(atari)]: if i <= 1: continue ansDic = dicPlusDic(ansDic, primeCount[i]) sortDic = {} for i in range(atari + 1): if i <= 1: continue sortDic = dicPlusDic(sortDic, primeCount[i]) ansDic = dicMinusDic(ansDic, sortDic) mod = 1000000000 ans = 1 for (i,v) in ansDic.items(): for j in range(v): ans *= i print(ans%mod)