結果

問題 No.1648 Sum of Powers
ユーザー convexineqconvexineq
提出日時 2021-08-13 23:01:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 95,960 KB
最終ジャッジ日時 2024-04-14 19:59:09
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
93,264 KB
testcase_01 AC 53 ms
70,784 KB
testcase_02 AC 79 ms
94,724 KB
testcase_03 AC 75 ms
94,104 KB
testcase_04 AC 79 ms
94,920 KB
testcase_05 AC 79 ms
94,424 KB
testcase_06 AC 78 ms
94,832 KB
testcase_07 AC 76 ms
94,272 KB
testcase_08 AC 80 ms
95,844 KB
testcase_09 AC 78 ms
94,400 KB
testcase_10 AC 78 ms
94,552 KB
testcase_11 AC 73 ms
93,020 KB
testcase_12 AC 79 ms
95,660 KB
testcase_13 AC 75 ms
93,740 KB
testcase_14 AC 75 ms
93,464 KB
testcase_15 AC 77 ms
94,988 KB
testcase_16 AC 77 ms
95,668 KB
testcase_17 AC 78 ms
95,308 KB
testcase_18 AC 76 ms
94,352 KB
testcase_19 AC 77 ms
93,924 KB
testcase_20 AC 76 ms
94,192 KB
testcase_21 AC 78 ms
94,748 KB
testcase_22 AC 79 ms
95,412 KB
testcase_23 AC 77 ms
94,448 KB
testcase_24 AC 77 ms
95,148 KB
testcase_25 AC 78 ms
94,884 KB
testcase_26 AC 77 ms
95,140 KB
testcase_27 AC 79 ms
95,000 KB
testcase_28 AC 80 ms
94,556 KB
testcase_29 AC 77 ms
95,884 KB
testcase_30 AC 78 ms
95,960 KB
testcase_31 AC 80 ms
94,688 KB
testcase_32 AC 79 ms
94,388 KB
testcase_33 AC 77 ms
94,736 KB
testcase_34 AC 77 ms
95,348 KB
testcase_35 AC 78 ms
95,084 KB
testcase_36 AC 78 ms
95,492 KB
testcase_37 AC 80 ms
94,912 KB
testcase_38 AC 80 ms
94,748 KB
testcase_39 AC 81 ms
95,364 KB
testcase_40 AC 80 ms
94,540 KB
testcase_41 AC 82 ms
95,160 KB
testcase_42 AC 79 ms
94,264 KB
testcase_43 AC 80 ms
95,948 KB
testcase_44 AC 79 ms
94,692 KB
testcase_45 AC 80 ms
95,148 KB
testcase_46 AC 79 ms
94,516 KB
testcase_47 AC 79 ms
94,192 KB
testcase_48 AC 54 ms
70,540 KB
testcase_49 AC 78 ms
94,364 KB
testcase_50 AC 79 ms
94,940 KB
testcase_51 AC 53 ms
70,964 KB
testcase_52 AC 74 ms
92,700 KB
testcase_53 AC 75 ms
94,116 KB
testcase_54 AC 75 ms
94,296 KB
testcase_55 AC 79 ms
94,384 KB
testcase_56 AC 79 ms
95,124 KB
testcase_57 AC 53 ms
70,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
a,b,p,q = map(int,input().split())

T = 10**5+9
memo = {}
f = lambda x,y: (y,(a*y-b*x)%MOD)
B = (q,p)
for i in range(T):
    memo[B] = i
    B = f(*B)

v,w = (1,0),(0,1)
for _ in range(T):
    v,w = f(*v),f(*w)
c1,c2 = v
c3,c4 = w
g = lambda x,y: ((c1*x+c3*y)%MOD,(c2*x+c4*y)%MOD)

s = (2,a)
for j in range(1,T+1):
    s = g(*s)
    if s in memo:
        i = memo[s]
        print(j*T-i+1)
        exit()
0