結果

問題 No.3054 ほぼ直角二等辺三角形
ユーザー tomarint2tomarint2
提出日時 2019-04-01 23:24:46
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 89,240 KB
最終ジャッジ日時 2023-08-18 02:38:02
合計ジャッジ時間 6,061 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 219 ms
88,892 KB
testcase_01 AC 220 ms
88,692 KB
testcase_02 AC 220 ms
88,840 KB
testcase_03 AC 218 ms
88,708 KB
testcase_04 AC 220 ms
89,240 KB
testcase_05 AC 218 ms
88,884 KB
testcase_06 AC 221 ms
89,128 KB
testcase_07 AC 220 ms
89,116 KB
testcase_08 AC 222 ms
88,944 KB
testcase_09 AC 223 ms
89,096 KB
testcase_10 AC 223 ms
89,160 KB
testcase_11 AC 223 ms
89,216 KB
testcase_12 AC 221 ms
88,964 KB
testcase_13 AC 222 ms
88,964 KB
testcase_14 AC 222 ms
89,120 KB
testcase_15 AC 223 ms
88,968 KB
testcase_16 AC 225 ms
88,968 KB
testcase_17 AC 230 ms
89,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import decimal
decimal.getcontext().prec = 30

def solve(X):
    # a(n) = 6*a(n-1) - a(n-2) + 2 with a(0) = 0, a(1) = 3.
    A=[0,3]
    for i in range(2,30):
        A.append(6 * A[i-1] - A[i-2] + 2)
    #print(A)
    for a in A[1:]:
        b = a + 1
        c2 = decimal.Decimal(a * a + b * b)
        p = decimal.Decimal('0.5')
        c = pow(c2, p)
        c = str(c)
        c = c[:c.index('.')]

        if len(str(c)) != X:
            continue
        return (a,b,c)

X=int(input())
#for X in range(1,20):
a,b,c=solve(X)
print(a,b,c)
0