結果
問題 |
No.1407 Kindness
|
ユーザー |
![]() |
提出日時 | 2021-02-28 09:18:46 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 791 bytes |
コンパイル時間 | 14,498 ms |
コンパイル使用メモリ | 404,692 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 18:11:26 |
合計ジャッジ時間 | 13,961 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
fn main() { let n: String = read(); let mut dp = vec![0i64; 2]; let big_int = 1000_000_000 + 7; dp[0] += 1; for (i, c) in n.chars().enumerate() { if i > 0 { dp[1] += 1; } let mut next = vec![0i64; 2]; for j in 0..2 { let lim = if j == 1 { 9 } else { c.to_digit(10).unwrap() }; for l in 0..lim + 1 { let idx1 = if j == 1 || l < lim { 1 } else { 0 }; next[idx1] += dp[j] * l as i64; next[idx1] %= big_int; } } dp = next; } println!("{}", (dp[0] + dp[1]) % big_int); } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() }