結果
問題 |
No.2174 3 O'clock Easy
|
ユーザー |
![]() |
提出日時 | 2022-12-26 23:09:22 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 427 bytes |
コンパイル時間 | 22,798 ms |
コンパイル使用メモリ | 389,444 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 10:06:48 |
合計ジャッジ時間 | 20,466 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
use std::io; fn main() { let mut n = String::new(); io::stdin().read_line(&mut n).ok(); let n: u64 = n.trim().parse().unwrap(); let mut ans: u64 = 0; for i in 0..n{ ans += power(i + 1, i % 3 + 1); } println!("{}", ans); } fn power(num: u64, repeat: u64) -> u64{ match repeat{ 0 => 1, 1 => num, _ => { let x = power(num, repeat / 2); if repeat %2 == 0{ x * x } else { x * x * num } } } }