結果

問題 No.1274 楽しい格子点
ユーザー hotman78
提出日時 2020-09-24 23:03:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,194 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,564 KB
実行使用メモリ 84,192 KB
最終ジャッジ日時 2024-07-22 18:36:52
合計ジャッジ時間 27,080 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

from decimal import Decimal
import decimal
import sys
import math
a,b=map(int,input().split())
a=abs(a)
b=abs(b)
decimal.getcontext().prec = 400
if a==0 and b==0:
    print("0.25")
    sys.exit()
k=math.gcd(a,b)
ans=Decimal(0)
for i in range(1,100):
    for j in range(1,100):
        if i%k==1 and j%k==1:
            if (i//k+j//k)%2==0 or (a//k+b//k)%2==1:
                ans+=Decimal(1)/Decimal((i+j)**(i+j))
        if k==1:
            if (i//k+j//k)%2==0 or (a//k+b//k)%2==1:
                ans+=Decimal(1)/Decimal((i+j)**(i+j))
print(ans)
0