結果

問題 No.1252 数字根D
ユーザー kozy
提出日時 2020-10-09 21:30:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-20 08:50:59
合計ジャッジ時間 1,520 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def suti(S):
    if S%d==0:
        return d
    else:
        return S%d
Q=int(input())
for i in range(Q):
    d,a,b=map(int,input().split())
    d-=1
    s=(b-a)//d
    ans=(((1+d)*d)//2)*s
    a=suti(a)
    b=suti(b)
    if a<b:
        ans+=((b-a+1)*(b+a))//2
        print(ans)
    elif a==b:
        print(ans+a)
    else:
        ans+=((d-a+1)*(d+a))//2
        ans+=((b)*(b+1))//2
        print(ans)
0