結果

問題 No.2555 Intriguing Triangle
ユーザー mkawa2mkawa2
提出日時 2023-12-02 18:58:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,847 ms / 2,000 ms
コード長 3,997 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 201,048 KB
最終ジャッジ日時 2023-12-02 18:58:42
合計ジャッジ時間 15,867 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 337 ms
189,688 KB
testcase_01 AC 392 ms
201,044 KB
testcase_02 AC 356 ms
201,044 KB
testcase_03 AC 381 ms
201,040 KB
testcase_04 AC 443 ms
201,032 KB
testcase_05 AC 333 ms
191,764 KB
testcase_06 AC 330 ms
189,688 KB
testcase_07 AC 373 ms
196,496 KB
testcase_08 AC 357 ms
201,028 KB
testcase_09 AC 420 ms
201,048 KB
testcase_10 AC 607 ms
201,048 KB
testcase_11 AC 445 ms
200,984 KB
testcase_12 AC 704 ms
201,048 KB
testcase_13 AC 575 ms
201,048 KB
testcase_14 AC 590 ms
201,048 KB
testcase_15 AC 483 ms
201,048 KB
testcase_16 AC 444 ms
201,044 KB
testcase_17 AC 330 ms
189,688 KB
testcase_18 AC 388 ms
201,028 KB
testcase_19 AC 340 ms
196,024 KB
testcase_20 AC 336 ms
189,688 KB
testcase_21 AC 1,847 ms
201,044 KB
testcase_22 AC 349 ms
198,212 KB
testcase_23 AC 344 ms
198,084 KB
testcase_24 AC 363 ms
201,044 KB
testcase_25 AC 392 ms
201,044 KB
testcase_26 AC 415 ms
201,044 KB
testcase_27 AC 423 ms
201,044 KB
testcase_28 AC 331 ms
191,768 KB
testcase_29 AC 484 ms
201,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = -1-(-1 << 31)
# inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

class Sieve:
    def __init__(self, n):
        self.plist = [2]
        min_prime_factor = [2, 0]*(n//2+1)
        for x in range(3, n+1, 2):
            if min_prime_factor[x] == 0:
                min_prime_factor[x] = x
                self.plist.append(x)
                if x**2 > n: continue
                for y in range(x**2, n+1, 2*x):
                    if min_prime_factor[y] == 0:
                        min_prime_factor[y] = x
        self.min_prime_factor = min_prime_factor

    def isprime(self, x):
        return self.min_prime_factor[x] == x

    def pf(self, x):
        pp, ee = [], []
        while x > 1:
            mpf = self.min_prime_factor[x]
            if pp and mpf == pp[-1]:
                ee[-1] += 1
            else:
                pp.append(mpf)
                ee.append(1)
            x //= mpf
        return pp, ee

    # unsorted
    def factor(self, a):
        ff = [1]
        pp, ee = self.pf(a)
        for p, e in zip(pp, ee):
            ff, gg = [], ff
            w = p
            for _ in range(e):
                for f in gg: ff.append(f*w)
                w *= p
            ff += gg
        return ff

sv=Sieve(10**7)

# 実数 a√b/c
class Real:
    def gcd(self,a,b):
        while b:a,b=b,a%b
        return a

    def __init__(self,a,b=1,c=1):
        assert b>0 and c>0
        for p in sv.plist:
            q=p**2
            while b%q==0:
                a*=p
                b//=q
            if q > b: break
        g=self.gcd(a,c)
        a//=g
        c//=g
        self.a,self.b,self.c=a,b,c

    def __add__(self, other):
        assert self.b==other.b
        g=self.gcd(self.c,other.c)
        c=self.c*other.c//g
        a=self.a*other.c//g+self.c*other.a//g
        return Real(a,self.b,c)

    def __sub__(self, other):
        assert self.b==other.b
        g=self.gcd(self.c,other.c)
        c=self.c*other.c//g
        a=self.a*other.c//g-self.c*other.a//g
        return Real(a,self.b,c)

    def __mul__(self, other):
        return Real(self.a*other.a,self.b*other.b,self.c*other.c)

    def __truediv__(self, other):
        return self*Real(other.c,other.b,other.a*other.b)

    def __eq__(self, other):
        return self.a==other.a and self.b==other.b and self.c==other.c

    def __pow__(self, power, modulo=None):
        return Real(self.a**2*self.b,1,self.c**2)

    def sqrt(self):
        assert self.b==1
        return Real(1,self.a*self.c,self.c)

    def __repr__(self):
        return str(self.a)+"√"+str(self.b)+"/"+str(self.c)

    def val(self):
        return self.a*self.b**0.5/self.c

def yog(b,c,cosA):
    return (b**2+c**2-Real(2)*b*c*cosA).sqrt()

def inv_yog(a,b,c):
    return (b**2+c**2-a**2)/(Real(2)*b*c)

def f(a,b,c,x,y):
    a=Real(a)
    b=Real(b)
    c=Real(c)
    x=Real(x)
    y=Real(y)
    cosB=inv_yog(c,b,x+a+y)
    AD=yog(b,x,cosB)
    res=inv_yog(x,b,AD)
    return res

a=II()
b=II()
c=II()
if b<c:b,c=c,b

for x in range(1,b+c-a-1):
    for y in range(max(1,b+1-x-a-c),b+c-x-a):
        # print(x,y,f(a,b,c,x,y),f(a,c,b,y,x))
        f1=f(a,b,c,x,y)
        f2=f(a,c,b,y,x)
        # print(x,y,abs(f1.val()-f2.val()))
        if f1==f2:
            print("Yes")
            exit()

print("No")
0