結果

問題 No.634 硬貨の枚数1
ユーザー ixTL255
提出日時 2023-01-02 22:22:24
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 503 bytes
コンパイル時間 11,819 ms
コンパイル使用メモリ 378,296 KB
実行使用メモリ 227,584 KB
最終ジャッジ日時 2024-11-27 01:19:41
合計ジャッジ時間 93,542 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47 TLE * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashSet;

fn main() {
	let mut n = String::new();
	std::io::stdin().read_line(&mut n).ok();
	let n: usize = n.trim().parse().unwrap();

	let mut t: Vec<usize> = vec![1];
	
	for i in 2.. {
		if i < n { t.push(t[i - 2] + i); }
		else { break; }
	}

	let set: HashSet<usize> = t.iter().cloned().collect();

	let mut ans = 3;
	if set.contains(&n) {
		println!("{}", 1);
		return;
	}

	for i in 0..set.len() {
		if set.contains(&(n - t[i])) {
			ans = 2;
		}
	}

	println!("{}", ans);
}
0