結果
| 問題 |
No.2510 Six Cube Sum Counting
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-24 16:51:26 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,058 bytes |
| コンパイル時間 | 11,701 ms |
| コンパイル使用メモリ | 406,044 KB |
| 実行使用メモリ | 559,560 KB |
| 最終ジャッジ日時 | 2024-09-19 12:55:10 |
| 合計ジャッジ時間 | 46,713 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 4 |
| other | MLE * 26 |
ソースコード
use std::io;
use std::collections::HashMap;
fn solve() -> i64 {
// input! {
// x: i64,
// }
let x: i64 = input().parse().unwrap();
let mut cubes: HashMap<i64, Vec<(i64, i64, i64)>> = HashMap::new();
for a in 0..=300i64 {
for b in a..=300 {
for c in b..=300 {
let abc = (a, b, c);
let y = a.pow(3) + b.pow(3) + c.pow(3);
if let Some(v) = cubes.get(&y) {
let mut u = v.clone();
u.push(abc);
cubes.insert(y, u);
}else {
cubes.insert(y, vec![abc]);
}
}
}
}
let mut ans = 0;
for (&y, def_vec) in cubes.iter() {
if let Some(v) = cubes.get(&(x - y)) {
for &abc in v {
for def in def_vec {
if abc.2 <= def.0 { ans += 1; eprintln!("{:?} {:?}", abc, def); }
}
}
}
}
eprintln!("{}", cubes.len());
return ans;
}
fn input() -> String {
let mut buffer = String::new();
io::stdin().read_line(&mut buffer).unwrap();
return buffer.trim().to_string();
}
fn main() {
println!("{}", solve());
}