結果

問題 No.1648 Sum of Powers
ユーザー convexineqconvexineq
提出日時 2021-08-13 22:53:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,856 KB
実行使用メモリ 101,416 KB
最終ジャッジ日時 2024-04-14 19:40:15
合計ジャッジ時間 7,905 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 49 ms
63,276 KB
testcase_02 AC 91 ms
100,976 KB
testcase_03 AC 89 ms
101,208 KB
testcase_04 AC 96 ms
101,104 KB
testcase_05 AC 90 ms
100,924 KB
testcase_06 AC 92 ms
101,296 KB
testcase_07 AC 90 ms
101,096 KB
testcase_08 AC 91 ms
101,152 KB
testcase_09 AC 92 ms
101,200 KB
testcase_10 AC 91 ms
100,716 KB
testcase_11 AC 89 ms
101,352 KB
testcase_12 AC 93 ms
101,180 KB
testcase_13 AC 91 ms
101,004 KB
testcase_14 AC 87 ms
100,740 KB
testcase_15 AC 92 ms
100,732 KB
testcase_16 AC 92 ms
101,196 KB
testcase_17 AC 93 ms
101,388 KB
testcase_18 AC 88 ms
100,736 KB
testcase_19 AC 89 ms
101,300 KB
testcase_20 AC 89 ms
101,200 KB
testcase_21 AC 92 ms
100,996 KB
testcase_22 AC 92 ms
101,236 KB
testcase_23 AC 92 ms
100,860 KB
testcase_24 AC 91 ms
101,068 KB
testcase_25 AC 93 ms
101,084 KB
testcase_26 AC 92 ms
101,148 KB
testcase_27 AC 92 ms
100,872 KB
testcase_28 AC 94 ms
100,724 KB
testcase_29 AC 93 ms
101,416 KB
testcase_30 AC 95 ms
101,004 KB
testcase_31 AC 95 ms
100,784 KB
testcase_32 AC 93 ms
101,268 KB
testcase_33 AC 94 ms
101,340 KB
testcase_34 AC 92 ms
101,352 KB
testcase_35 AC 93 ms
100,848 KB
testcase_36 AC 94 ms
100,736 KB
testcase_37 AC 94 ms
101,080 KB
testcase_38 AC 94 ms
101,156 KB
testcase_39 AC 96 ms
100,752 KB
testcase_40 AC 94 ms
100,844 KB
testcase_41 AC 96 ms
101,104 KB
testcase_42 AC 101 ms
100,872 KB
testcase_43 AC 93 ms
101,280 KB
testcase_44 AC 93 ms
101,156 KB
testcase_45 AC 94 ms
100,724 KB
testcase_46 AC 93 ms
100,848 KB
testcase_47 AC 92 ms
101,236 KB
testcase_48 AC 48 ms
63,784 KB
testcase_49 AC 90 ms
101,072 KB
testcase_50 AC 90 ms
101,268 KB
testcase_51 AC 48 ms
63,104 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 92 ms
101,208 KB
testcase_56 AC 94 ms
101,020 KB
testcase_57 AC 49 ms
65,044 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)

s = (2,a)
for i in range(T):
    if s == (q,p):
        print(i+2)
        exit()
    s = f(*s)

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