結果
問題 | No.493 とても長い数列と文字列(Long Long Sequence and a String) |
ユーザー | koba-e964 |
提出日時 | 2021-10-28 22:13:51 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,476 bytes |
コンパイル時間 | 12,167 ms |
コンパイル使用メモリ | 400,960 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 08:11:25 |
合計ジャッジ時間 | 14,130 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
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 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | WA | - |
testcase_104 | WA | - |
testcase_105 | WA | - |
testcase_106 | WA | - |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | AC | 1 ms
5,248 KB |
testcase_115 | AC | 1 ms
5,248 KB |
testcase_116 | AC | 1 ms
5,248 KB |
testcase_117 | AC | 1 ms
5,248 KB |
testcase_118 | WA | - |
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::Read; fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin=stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } #[allow(dead_code)] fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } const MOD: i64 = 1_000_000_007; fn dfs(k: usize, l: i64, r: i64, len: &[i64]) -> (i64, i64) { if l == r { return (0, 1); } if k == 1 { return (1, 1); } assert!(r <= len[k]); assert!(l <= r); if (l, r) == (0, len[k]) { let mut a = 0; let mut b = 1; let mut v = k as i64 * k as i64; while v > 0 { let mut r = v % 10; a += r; if r == 0 { r = 10; } b = b * r % MOD; v /= 10; } let (c, d) = dfs(k - 1, 0, len[k - 1], len); a += 2 * c; b = b * d % MOD * d % MOD; return (a, b); } let mut a = 0; let mut b = 1; let mid1 = len[k - 1]; let mid2 = len[k] - len[k - 1]; if l < mid1 { let (c, d) = dfs(k - 1, l, min(r, mid1), &len); a += c; b = b * d % MOD; } if l < mid2 && r > mid1 { let s: Vec<_> = format!("{}", k * k).bytes().collect(); for i in max(l, mid1) - mid1..min(r, mid2) - mid1 { let v = (s[i as usize] - b'0') as i64; a += v; let v = if v == 0 { 10 } else { v }; b = b * v % MOD; } } if r > mid2 { let (c, d) = dfs(k - 1, max(l, mid2) - mid2, r - mid2, &len); a += c; b = b * d % MOD; } (a, b) } fn main() { let k: usize = get(); let l: i64 = get(); let r: i64 = get(); let mut len = vec![0; 62]; len[1] = 1; for i in 2..62 { len[i] = len[i - 1] * 2 + format!("{}", i * i).len() as i64; } let k = min(k, 61); if r > len[k] { println!("-1"); return; } let (a, b) = dfs(k, l - 1, r, &len); println!("{} {}", a, b); }