結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー convexineqconvexineq
提出日時 2021-01-23 15:46:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 410 bytes
コンパイル時間 1,031 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 76,396 KB
最終ジャッジ日時 2023-08-29 06:34:13
合計ジャッジ時間 5,242 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,688 KB
testcase_01 AC 69 ms
71,420 KB
testcase_02 AC 71 ms
71,384 KB
testcase_03 AC 71 ms
71,192 KB
testcase_04 AC 73 ms
71,500 KB
testcase_05 AC 68 ms
71,164 KB
testcase_06 AC 84 ms
75,748 KB
testcase_07 AC 81 ms
76,096 KB
testcase_08 AC 82 ms
75,820 KB
testcase_09 AC 83 ms
75,984 KB
testcase_10 AC 80 ms
76,032 KB
testcase_11 AC 499 ms
76,152 KB
testcase_12 AC 477 ms
75,768 KB
testcase_13 AC 575 ms
76,040 KB
testcase_14 AC 461 ms
76,020 KB
testcase_15 AC 492 ms
76,108 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def extgcd(x,y):
    if y==0: return 1,0 #g=x
    r0,r1,s0,s1 = x,y,1,0
    while r1 != 0:
        r0,r1, s0,s1 = r1,r0%r1, s1,s0-r0//r1*s1
    return r0,s0,(r0-s0*x)//y

T = int(input())
for _ in range(T):
    *abc,n = map(int,input().split())
    a,b,c = sorted(abc)
    ans = 0
    g,p,q = extgcd(a,b) #ap+bq=1
    for t in range(n,-1,-c):
        if t%g==0: ans += t*q//a - (-t*p+b-1)//b + 1
    print(ans)
0