結果

問題 No.1274 楽しい格子点
ユーザー tanon710
提出日時 2020-10-31 01:11:54
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 662 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 53,760 KB
最終ジャッジ日時 2024-07-22 18:44:21
合計ジャッジ時間 4,803 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 56 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

a,b=map(int,input().split())
a=abs(a)
b=abs(b)
if a==0 and b==0:
    print(0.25)
elif a==0 or b==0:
    k=max(a,b)
    ans=0
    for x in range(1,20+1,k):
        for y in range(1,20+1,k):
            ans+=1/((x+y)**(x+y))
    print(ans)
else:
    g=gcd(a,b)
    a//=g
    b//=g
    ans=0.25
    for x in range(1,20+1,g):
        for y in range(1,20+1,g):
            if x==1 and y==1:
                continue
            if (a+b)%2==0:
                if (x+y)%2==0:
                    ans+=1/((x+y)**(x+y))
            else:
                ans+=1/((x+y)**(x+y))
    print(ans)
0