結果

問題 No.2174 3 O'clock Easy
ユーザー ixTL255
提出日時 2022-12-26 23:09:22
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 2,000 ms
+ 836µs
コード長 427 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 468 ms
コンパイル使用メモリ 184,396 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2026-09-27 11:19:23
合計ジャッジ時間 2,004 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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
			}
		}
	}
}
0