結果

問題 No.1407 Kindness
ユーザー tonyu0tonyu0
提出日時 2021-02-27 00:30:18
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 160,268 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-04-10 14:51:35
合計ジャッジ時間 2,562 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 53 ms
13,056 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 36 ms
9,600 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 13 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let s: Vec<usize> = s
        .trim()
        .chars()
        .map(|c| c.to_digit(10).unwrap() as usize)
        .collect();
    let n = s.len();
    let mut val = vec![vec![0; 10]; n];
    for i in 0..10 {
        val[0][i] = i;
    }
    for i in 0..n - 1 {
        for j in 0..10 {
            for k in 0..10 {
                val[i + 1][j] += val[i][k] * j;
                val[i + 1][j] %= MOD;
            }
        }
    }
    let mut ans = 0;
    let mut now = s[0];
    ans += val[n - 1][1];
    for i in 1..s[0] {
        ans = (ans + val[n - 1][i] * i) % MOD;
    }

    for i in 1..n {
        if i != n - 1 {
            ans += val[n - i - 1][1];
        }
        for j in 1..s[i] {
            ans = (ans + val[n - i - 1][j] * now) % MOD;
        }
        now = now * s[i] % MOD;
    }
    println!("{}", ans + now);
}
0