提出 #72199017
ソースコード 拡げる
use libm::sqrt;
use proconio::input;
fn main() {
input! {
n:usize
}
let up = 1_usize + sqrt(n as f64) as usize;
let mut hairetu: Vec<usize> = (0..=n).into_iter().map(|_| 0).collect();
for x in 1..=up {
for y in x + 1..=up {
let nn = x.pow(2_u32) + y.pow(2_u32);
if nn > n {
// eprintln!("x={x} y={y} {nn}>{n}");
break;
}
hairetu[nn] += 1;
}
}
let mut new = Vec::new();
let mut c = 0;
for i in 1..=n {
if hairetu[i] == 1 {
c += 1;
new.push(i);
// print!("{i}");
}
}
println!("{c}");
if c != 0 {
print!("{}", new[0]);
for i in 1..c {
print!(" {}", new[i]);
}
} else {
println!();
return;
}
// eprintln!("{:?}", hairetu);
// println!("{}", new.join(" "));
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - 2026 |
| ユーザ | moamoa |
| 言語 | Rust (rustc 1.89.0) |
| 得点 | 300 |
| コード長 | 928 Byte |
| 結果 | AC |
| 実行時間 | 138 ms |
| メモリ | 92332 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 1800 KiB |
| 00_sample_01.txt | AC | 1 ms | 1824 KiB |
| 00_sample_02.txt | AC | 1 ms | 1948 KiB |
| 01_random_00.txt | AC | 58 ms | 39480 KiB |
| 01_random_01.txt | AC | 119 ms | 81800 KiB |
| 01_random_02.txt | AC | 56 ms | 38696 KiB |
| 01_random_03.txt | AC | 128 ms | 85668 KiB |
| 01_random_04.txt | AC | 34 ms | 24140 KiB |
| 01_random_05.txt | AC | 67 ms | 46456 KiB |
| 01_random_06.txt | AC | 44 ms | 31276 KiB |
| 01_random_07.txt | AC | 40 ms | 28336 KiB |
| 01_random_08.txt | AC | 63 ms | 44216 KiB |
| 01_random_09.txt | AC | 133 ms | 89472 KiB |
| 02_corner_00.txt | AC | 2 ms | 2056 KiB |
| 02_corner_01.txt | AC | 138 ms | 92132 KiB |
| 02_corner_02.txt | AC | 138 ms | 92216 KiB |
| 02_corner_03.txt | AC | 138 ms | 92180 KiB |
| 02_corner_04.txt | AC | 138 ms | 92332 KiB |