結果

問題 No.528 10^9と10^9+7と回文
ユーザー nanaenanae
提出日時 2017-06-09 23:20:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 668 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 8,444 KB
最終ジャッジ日時 2023-10-01 00:53:30
合計ジャッジ時間 1,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,780 KB
testcase_01 AC 17 ms
7,880 KB
testcase_02 AC 16 ms
7,832 KB
testcase_03 AC 16 ms
7,840 KB
testcase_04 AC 15 ms
7,784 KB
testcase_05 AC 15 ms
7,856 KB
testcase_06 AC 16 ms
7,864 KB
testcase_07 AC 16 ms
7,828 KB
testcase_08 AC 16 ms
7,868 KB
testcase_09 AC 16 ms
7,860 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,852 KB
testcase_23 AC 15 ms
7,844 KB
testcase_24 AC 16 ms
7,784 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

mod1 = 10**9
mod2 = 10**9 + 7

def solve():
    n = input()
    keta = len(n)

    if keta & 1:
        ans = 2 * 10**((keta - 1) // 2) - 2
    else:
        ans = 11 * 10**((keta - 1) // 2) - 2

    tmp = int(n) // 10**(keta // 2) - 10**((keta - 1) // 2) + 1

    if int(n) < int(f(keta, n)):
        tmp -= 1

    ans += tmp

    ans1 = ans % mod1
    ans2 = ans % mod2
    
    print(ans1)
    print(ans2)


def f(keta, n):
    if keta & 1:
        ue = n[:(keta + 1) // 2]
        sita = ue[:-1][::-1]
        return ue + sita
    else:
        ue = n[:keta // 2]
        sita = ue[::-1]
        return ue + sita

if __name__ == '__main__':
    solve()
0