結果
問題 | No.129 お年玉(2) |
ユーザー | バカらっく |
提出日時 | 2019-10-03 03:20:42 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,879 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 13,696 KB |
最終ジャッジ日時 | 2024-10-03 06:05:33 |
合計ジャッジ時間 | 22,271 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1,618 ms
13,696 KB |
testcase_02 | AC | 28 ms
11,136 KB |
testcase_03 | AC | 28 ms
11,008 KB |
testcase_04 | AC | 28 ms
11,008 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 28 ms
11,008 KB |
testcase_30 | AC | 27 ms
10,880 KB |
testcase_31 | AC | 27 ms
11,008 KB |
testcase_32 | WA | - |
testcase_33 | AC | 27 ms
11,008 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
ソースコード
# -*- 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) ans = 1 for (i,v) in ansDic.items(): for j in range(v): ans *= i ans = ans % (1000000000 + 7) print(ans)