結果

問題 No.491 10^9+1と回文
ユーザー packet0
提出日時 2017-03-27 23:23:52
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 12,966 ms
コンパイル使用メモリ 403,048 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 09:58:28
合計ジャッジ時間 13,062 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 61
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around `for` iterator expression
  --> src/main.rs:10:18
   |
10 |         for i in (1..10) {
   |                  ^     ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
10 -         for i in (1..10) {
10 +         for i in 1..10 {
   |

warning: constant `base` should have an upper case name
 --> src/main.rs:1:7
  |
1 | const base: u64 = 1000000001;
  |       ^^^^ help: convert the identifier to upper case: `BASE`
  |
  = note: `#[warn(non_upper_case_globals)]` on by default

warning: unused `Result` that must be used
 --> src/main.rs:4:5
  |
4 |     std::io::stdin().read_line(&mut line);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this `Result` may be an `Err` variant, which should be handled
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
4 |     let _ = std::io::stdin().read_line(&mut line);
  |     +++++++

ソースコード

diff #

const base: u64 = 1000000001;
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let n: u64 = line.trim().parse().unwrap();

    let mut mul = 1;
    let mut count = 0;
    'a: loop {
        for i in (1..10) {
            if mul * i * base > n {
                break 'a;
            }
            count += 1;
        }
        mul = mul * 10 + 1;
    }
    println!("{}", count);
}
0