結果

問題 No.2365 Present of good number
ユーザー nasutarou1341nasutarou1341
提出日時 2023-06-30 22:12:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 907 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 73,412 KB
最終ジャッジ日時 2023-09-21 16:15:04
合計ジャッジ時間 5,023 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,768 KB
testcase_01 AC 73 ms
71,548 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 71 ms
73,188 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 AC 77 ms
71,592 KB
testcase_18 AC 77 ms
71,608 KB
testcase_19 WA -
testcase_20 AC 71 ms
71,588 KB
testcase_21 AC 73 ms
71,564 KB
testcase_22 WA -
testcase_23 AC 73 ms
73,056 KB
testcase_24 AC 72 ms
71,612 KB
testcase_25 WA -
testcase_26 AC 73 ms
72,372 KB
testcase_27 AC 73 ms
72,560 KB
testcase_28 AC 71 ms
71,616 KB
testcase_29 AC 72 ms
72,812 KB
testcase_30 AC 72 ms
71,916 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 72 ms
72,556 KB
testcase_37 AC 72 ms
73,320 KB
testcase_38 AC 71 ms
72,928 KB
testcase_39 AC 71 ms
72,824 KB
testcase_40 AC 75 ms
73,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def prime(x):
  p = {}
  last = math.floor(x ** 0.5)
  if x % 2 == 0:
    cnt = 1
    x //= 2
    while x & 1 == 0:
      x //= 2
      cnt += 1
    p[2] = cnt
  for i in range(3, last + 1, 2):
    if x % i == 0:
      x //= i
      cnt = 1
      while x % i == 0:
        cnt += 1
        x //= i
      p[i] = cnt
  if x != 1:
    p[x] = 1
  return p

N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7

DP = [0] * N
L = [0] * N

P = []

def nasu(n, k):
  p = prime(n)
  ans = 1
  for key, val in p.items():
    if k == 1:
      ans = ans * pow(key + 1, val) % MOD
    else:
      if key == 2:
        d, m = divmod(k, 2)
        if m:
          t = pow(3, pow(2, d, MOD) * val % MOD, MOD)
        else:
          t = pow(2, pow(2, d, MOD) * val % MOD, MOD)
        ans = ans * t % MOD
      else:
        ans = ans * pow(nasu(key + 1, k - 1), val) % MOD
  return ans

print(nasu(N, K))

0