1
0
This commit is contained in:
2026-02-04 11:15:03 +08:00
commit 8b20a5dd21
125 changed files with 4177 additions and 0 deletions

6
problems/p28/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "p28"
version = "0.1.0"
edition = "2024"
[dependencies]

16
problems/p28/src/main.rs Normal file
View File

@@ -0,0 +1,16 @@
// 1, 3, 5, 7, 9, 13, 17, 21, 25, 31
//+2,+2,+2,+2,+4,+4,+4,+4, +6
//
//右上角固定为平方数nxn
fn main() {
let mut sum = 1;
let n = 1001;
for round in 1..=(n / 2) {
let base = (round * 2 + 1) * (round * 2 + 1);
sum += base * 4;
sum -= round * 2 * 6;
}
println!("{sum}");
}