結果

問題 No.1049 Zero (Exhaust)
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-05-08 22:07:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 76,236 KB
最終ジャッジ日時 2023-09-17 02:55:22
合計ジャッジ時間 3,019 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
71,620 KB
testcase_01 AC 66 ms
71,300 KB
testcase_02 AC 68 ms
71,380 KB
testcase_03 AC 84 ms
75,980 KB
testcase_04 AC 63 ms
71,376 KB
testcase_05 AC 81 ms
76,056 KB
testcase_06 AC 81 ms
75,892 KB
testcase_07 AC 67 ms
75,924 KB
testcase_08 AC 76 ms
75,996 KB
testcase_09 AC 74 ms
75,980 KB
testcase_10 AC 76 ms
75,992 KB
testcase_11 AC 76 ms
76,080 KB
testcase_12 AC 77 ms
75,828 KB
testcase_13 AC 70 ms
76,236 KB
testcase_14 AC 74 ms
76,080 KB
testcase_15 AC 74 ms
75,804 KB
testcase_16 AC 75 ms
76,004 KB
testcase_17 AC 73 ms
76,068 KB
testcase_18 AC 76 ms
75,760 KB
testcase_19 AC 73 ms
75,892 KB
testcase_20 AC 70 ms
75,964 KB
testcase_21 AC 79 ms
76,104 KB
testcase_22 AC 71 ms
75,976 KB
testcase_23 AC 77 ms
75,972 KB
testcase_24 AC 79 ms
76,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

modで考えるのはそう
(1)は xをx+iにする
(2)は xをx*iにする

どっちも一意だが…
0に何懸けても0
→足してから×ことになる

iとPは互いに素
iが余り0になるにはP回足す必要あり?

i * (i*i*i* ・・・ + i * i * … + 1 + 1 + … )

そもそも iが指定されてないやん!
足し算の方は互いに影響
掛け算は、mod0にとっては自分、そうでなければ全て同値
"""

P,K = map(int,input().split())

zero = 1
other = 0
mod = 10**9+7

for i in range(K):

    nz = 0
    no = 0

    #足し算

    nz += (zero + other*(P-1)) % mod
    no += (zero + other*(P-1)) % mod

    #掛け算
    #print (nz,no)

    nz += zero * P + other * (P-1)
    no += other * (P-1)

    zero = nz % mod
    other = no % mod

    #print (zero,other)

print (zero)
0