結果

問題 No.528 10^9と10^9+7と回文
ユーザー 6soukiti296soukiti29
提出日時 2017-06-18 13:25:37
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 8,408 KB
最終ジャッジ日時 2023-07-25 00:41:11
合計ジャッジ時間 2,361 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 17 ms
7,772 KB
testcase_03 AC 17 ms
7,768 KB
testcase_04 AC 16 ms
7,852 KB
testcase_05 AC 16 ms
7,860 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,792 KB
testcase_08 WA -
testcase_09 AC 17 ms
7,800 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 16 ms
7,816 KB
testcase_23 AC 16 ms
7,844 KB
testcase_24 AC 36 ms
8,184 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def kaibun(y):
	x = len(str(y))
	flag = 0
	X = [9,9]
	i = 2
	while x > i:
		if i % 2 == 0:
			X.append(X[i - 1] * 10)
		else:
			X.append(X[i - 1])
		i = i + 1
	a = sum(X[:x - 1])
	for j in range(1, x // 2 + 1):
		if j == 1:
			a = a + (int(str(y)[j - 1]) - 1) * X[x - 2 * j + 1]//9
		else:
			a = a + (int(str(y)[j - 1])) * X[x - 2 * j + 1] // 9
	if y <= int(str(y)[::-1]):
		a = a + 1
	if x % 2 == 1:
		a = a + int(str(y)[x // 2])
	return a 
	# X[i] は i 桁の自然数のうち回文となるものの個数
n = int(input())

print(kaibun(n)%1000000000)
print(kaibun(n)%1000000007)
0