結果

問題 No.528 10^9と10^9+7と回文
ユーザー 6soukiti296soukiti29
提出日時 2017-06-18 13:19:58
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 1,285 bytes
コンパイル時間 2,894 ms
コンパイル使用メモリ 68,740 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-12 13:06:19
合計ジャッジ時間 3,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 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 1 ms
4,380 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 13) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 22) Warning: imported and not used: 'strutils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 31) Warning: imported and not used: 'unicode' [UnusedImport]

ソースコード

diff #

import math,sequtils,strutils,unicode
proc powInt(n : int64, m : int64, k = 1_000_000_007):int64 =
    if m == 0:
        return 1
    elif m == 1:
        return (n mod k)
    if (m mod 2) == 0:
        return powInt((n*n) mod k,m div 2, k) mod k
    else:
        return (powInt((n*n) mod k,m div 2, k) * n) mod k
proc CToI(c : char):int =
    return( int(c) - int('0'))


var
    mod_Bill = (10.powInt(9)).int
    mod_Bill_7 = (10.powInt(9) + 7).int
    N : string
    p : int64
let N1 = stdin.readline
proc kaibun(N : string):int64 =
    var x = N.len
    var
        flag = 0
        X : seq[int64]
        i = 2
        a : int64
    X = @[9.int64,9.int64]
    while x > i:
        if (i mod 2) == 0:
            X.add(X[i - 1] * 10)
        else:
            X.add(X[i - 1])
        i += 1
    a = 0
    for i in X[0..len(X)-2]:
        a += i
    for j in 1..(x div 2):
        if j == 1:
            a = a + (N[j - 1].CToI - 1) * X[x - 2*j + 1] div 9
        else:
            a = a + N[j - 1].CToI * X[x - 2*j + 1] div 9
    for i in 0..<len(X) div 2:
        if N[i] > N[^(i + 1)]:
            break
        if i == len(N) div 2 - 1:
            a += 1
    if (x mod 2) == 1:
        a += N[x div 2].CToI
    return a
p = kaibun(N1)
echo p mod mod_Bill
echo p mod mod_Bill_7
0