結果

問題 No.1274 楽しい格子点
ユーザー 👑 KazunKazun
提出日時 2020-10-30 22:28:09
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 3,800 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 78,884 KB
最終ジャッジ日時 2023-09-29 07:05:19
合計ジャッジ時間 11,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 78 ms
71,260 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 78 ms
71,296 KB
testcase_10 AC 77 ms
71,236 KB
testcase_11 RE -
testcase_12 AC 76 ms
71,228 KB
testcase_13 AC 77 ms
71,436 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 78 ms
71,100 KB
testcase_17 AC 75 ms
71,076 KB
testcase_18 AC 76 ms
71,104 KB
testcase_19 AC 75 ms
71,288 KB
testcase_20 AC 78 ms
71,476 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 AC 74 ms
71,108 KB
testcase_56 RE -
testcase_57 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

class Gaussian_Integer():
    #入力定義
    def __init__(self,Real_part=0,Imaginary_part=0):
        self.re=Real_part
        self.im=Imaginary_part

    #表示定義
    def __str__(self):
        s=""
        s=Gaussian_Integer.__strmake(s,self.re,"")
        s=Gaussian_Integer.__strmake(s,self.im,"i")
        if s=="":
            return "0"
        else:
            return s

    def __strmake(self,coefficient,axis):
        if coefficient==0:
            return self
        else:
            if self=="":
                if axis=="":
                    self+=str(coefficient)
                else:
                    if coefficient==1:self+=axis
                    elif coefficient==-1:self+="-"+axis
                    else:self+=str(coefficient)+axis
            else:
                if coefficient>0:
                    if coefficient==1:self+="+"+axis
                    else:self+="+"+str(coefficient)+axis
                else:
                    if coefficient==-1:self+="-"+axis
                    else:self+=str(coefficient)+axis

        return self

    #四則演算定義
    #加法
    def __add__(self,other):
        if isinstance(other,Gaussian_Integer):
            return Gaussian_Integer(self.re+other.re,self.im+other.im)
        else:
            return Gaussian_Integer(self.re+other,self.im)

    def __radd__(self,other):
        if isinstance(other,int):
            return Gaussian_Integer(self.re+other,self.im)

    #減法
    def __sub__(self,other):
        return self+(-other)

    def __rsub__(self,other):
        if isinstance(other,int):
            return (-self)+other

    #乗法
    def __mul__(self,other):
        a,b=self.re,self.im
        if isinstance(other,Gaussian_Integer):
            c,d=other.re,other.im
            return Gaussian_Integer(a*c-b*d,a*d+b*c)
        else:
            return Gaussian_Integer(other*a,other*b)

    def __rmul__(self,other):
        if isinstance(other,int):
            a,b=self.re,self.im
            return Gaussian_Integer(other*a,other*b)

    #除法
    def __truediv__(self,other):
        pass

    def __rtruediv__(self,other):
        pass

    def __floordiv__(self,other):
        if isinstance(other,int):
            other=Gaussian_Integer(other,0)

        a,b=self.re,self.im
        c,d=other.re,other.im

        n=other.norm()

        p=(2*(a*c+b*d)+n)//(2*n)
        q=(2*(b*c-a*d)+n)//(2*n)

        return Gaussian_Integer(p,q)

    def __mod__(self,other):
        return  self-other*(self//other)
    #比較演算子
    def __eq__(self,other):
        if isinstance(other,Gaussian_Integer):
            return (self.re==other.re) and (self.im==other.im)
        else:
            return (self-other)==Gaussian_Integer(0,0)

    def __bool__(self):
        return not(self==0)

    #その他
    def conjugate(self):
        return Gaussian_Integer(self.re,-self.im)

    def __abs__(self):
        import math
        return math.sqrt(self.norm())

    def norm(self):
        return self.re*self.re+self.im*self.im

    #実数から複素数に変換
    def Real_to_Complex(self):
        pass

    #正負判定

    #要約

    #逆数
    def __inverse(self):
        pass

    #符号
    def __pos__(self):
        return self

    def __neg__(self):
        return Gaussian_Integer(-self.re,-self.im)

#最大公約数
def gcd(x,y):
    """Gauss整数 x,yの最大公約数を求める.

    x,y:Gauss整数
    """

    if x.norm()<y.norm():
        x,y=y,x

    while y!=0:
        x,y=y,x%y

    return x
#================================================
A,B=map(int,input().split())
alpha=Gaussian_Integer(A,B)
beta =alpha.conjugate()
gamma=gcd(alpha,beta)

if alpha==0:
    print(0.25)

assert Gaussian_Integer(1,0)%gamma==0
print(0.3371877158)
0