init
This commit is contained in:
6
problems/p28/Cargo.toml
Normal file
6
problems/p28/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "p28"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
16
problems/p28/src/main.rs
Normal file
16
problems/p28/src/main.rs
Normal 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}");
|
||||
}
|
||||
Reference in New Issue
Block a user