結果

問題 No.3054 ほぼ直角二等辺三角形
ユーザー tomarint2tomarint2
提出日時 2019-04-01 23:24:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 80,384 KB
最終ジャッジ日時 2024-05-05 09:09:59
合計ジャッジ時間 3,625 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
80,128 KB
testcase_01 AC 113 ms
80,384 KB
testcase_02 AC 118 ms
79,872 KB
testcase_03 AC 112 ms
80,000 KB
testcase_04 AC 112 ms
80,000 KB
testcase_05 AC 114 ms
79,872 KB
testcase_06 AC 120 ms
80,128 KB
testcase_07 AC 125 ms
80,256 KB
testcase_08 AC 123 ms
80,384 KB
testcase_09 AC 122 ms
80,000 KB
testcase_10 AC 117 ms
80,000 KB
testcase_11 AC 112 ms
80,000 KB
testcase_12 AC 119 ms
80,384 KB
testcase_13 AC 116 ms
79,744 KB
testcase_14 AC 116 ms
80,000 KB
testcase_15 AC 122 ms
80,256 KB
testcase_16 AC 117 ms
80,128 KB
testcase_17 AC 115 ms
80,000 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