結果

問題 No.480 合計
コンテスト
ユーザー Yoshihito
提出日時 2019-11-15 17:35:07
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 536 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,894 ms
コンパイル使用メモリ 183,504 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-12 03:04:55
合計ジャッジ時間 3,125 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `Read` and `stdin`
 --> src/main.rs:2:15
  |
2 | use std::io::{Read, Stdin, stdin};
  |               ^^^^         ^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

use std::io;
use std::io::{Read, Stdin, stdin};

struct Input {
    n: i32,
}

fn main() {
    let mut stdin = io::stdin();
    let input = read_input(&mut stdin);
    solve(input);
}

fn read_input(stdin: &mut Stdin) -> Input {
    let mut s = String::new();
    stdin.read_line(&mut s).expect("can't read input.");

    let n = s.trim_end().parse::<i32>().expect("can't convert to integer");
    Input { n }
}

fn solve(input: Input) {
    let mut sum = 0;
    for i in 1..=input.n {
        sum += i;
    }
    println!("{}", sum);
}
0