結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー convexineqconvexineq
提出日時 2021-01-23 15:43:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 481 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 81,376 KB
最終ジャッジ日時 2023-08-29 06:06:10
合計ジャッジ時間 5,665 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
80,836 KB
testcase_01 AC 73 ms
75,264 KB
testcase_02 AC 76 ms
75,596 KB
testcase_03 AC 79 ms
75,444 KB
testcase_04 AC 75 ms
75,540 KB
testcase_05 AC 76 ms
75,264 KB
testcase_06 AC 140 ms
76,756 KB
testcase_07 AC 137 ms
76,696 KB
testcase_08 AC 134 ms
77,064 KB
testcase_09 AC 122 ms
76,848 KB
testcase_10 AC 123 ms
76,680 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

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

def points_on_line(a,b,t):
    g,p,q = extgcd(a,b) #ap+bq=1
    if t%g: return 0
    return t*q//a - (-t*p+b-1)//b + 1

T = int(input())
for _ in range(T):
    *abc,n = map(int,input().split())
    a,b,c = sorted(abc)
    ans = 0
    for t in range(n,-1,-c):
        ans += points_on_line(a,b,t)
    print(ans)
0