結果
| 問題 | 
                            No.2174 3 O'clock Easy
                             | 
                    
| ユーザー | 
                             dolp
                         | 
                    
| 提出日時 | 2022-12-25 12:23:42 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 2,000 ms | 
| コード長 | 520 bytes | 
| コンパイル時間 | 12,145 ms | 
| コンパイル使用メモリ | 403,144 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-21 07:41:19 | 
| 合計ジャッジ時間 | 12,614 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 | 
コンパイルメッセージ
warning: unnecessary parentheses around `if` condition
  --> src/main.rs:14:12
   |
14 |         if (i % 3 == 1) {ans += i};
   |            ^          ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
14 -         if (i % 3 == 1) {ans += i};
14 +         if i % 3 == 1 {ans += i};
   |
warning: unnecessary parentheses around `if` condition
  --> src/main.rs:15:12
   |
15 |         if (i % 3 == 2) {ans += i * i};
   |            ^          ^
   |
help: remove these parentheses
   |
15 -         if (i % 3 == 2) {ans += i * i};
15 +         if i % 3 == 2 {ans += i * i};
   |
warning: unnecessary parentheses around `if` condition
  --> src/main.rs:16:12
   |
16 |         if (i % 3 == 0) {ans += i * i * i};
   |            ^          ^
   |
help: remove these parentheses
   |
16 -         if (i % 3 == 0) {ans += i * i * i};
16 +         if i % 3 == 0 {ans += i * i * i};
   |
warning: variable `N` should have a snake case name
 --> src/main.rs:7:9
  |
7 |     let N: i64 = input.trim().parse().unwrap();
  |         ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default
            
            ソースコード
use std::io;
fn main() {
    //標準入力を受け取る
    let mut input: String = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let N: i64 = input.trim().parse().unwrap();
    //答えを0で初期化
    let mut ans: i64 = 0;
    //iの値で場合分けしてansに足し込んでいく
    for i in 1..N+1{
        if (i % 3 == 1) {ans += i};
        if (i % 3 == 2) {ans += i * i};
        if (i % 3 == 0) {ans += i * i * i};
    }
    //答えを出力する
    println! ("{}", ans)
}
            
            
            
        
            
dolp