結果

問題 No.2510 Six Cube Sum Counting
ユーザー 👑 KA37RIKA37RI
提出日時 2023-09-25 08:33:57
言語 Rust
(1.77.0)
結果
AC  
実行時間 900 ms / 4,000 ms
コード長 1,155 bytes
コンパイル時間 1,051 ms
コンパイル使用メモリ 184,988 KB
実行使用メモリ 309,220 KB
最終ジャッジ日時 2023-10-19 16:35:29
合計ジャッジ時間 26,998 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 765 ms
309,220 KB
testcase_01 AC 781 ms
309,220 KB
testcase_02 AC 884 ms
309,220 KB
testcase_03 AC 823 ms
309,220 KB
testcase_04 AC 820 ms
309,220 KB
testcase_05 AC 797 ms
309,220 KB
testcase_06 AC 771 ms
309,220 KB
testcase_07 AC 801 ms
309,220 KB
testcase_08 AC 761 ms
309,220 KB
testcase_09 AC 756 ms
309,220 KB
testcase_10 AC 777 ms
309,220 KB
testcase_11 AC 812 ms
309,220 KB
testcase_12 AC 825 ms
309,220 KB
testcase_13 AC 764 ms
309,220 KB
testcase_14 AC 813 ms
309,220 KB
testcase_15 AC 780 ms
309,220 KB
testcase_16 AC 809 ms
309,220 KB
testcase_17 AC 729 ms
309,220 KB
testcase_18 AC 721 ms
309,220 KB
testcase_19 AC 729 ms
309,220 KB
testcase_20 AC 762 ms
309,220 KB
testcase_21 AC 819 ms
309,220 KB
testcase_22 AC 900 ms
309,220 KB
testcase_23 AC 890 ms
309,220 KB
testcase_24 AC 868 ms
309,220 KB
testcase_25 AC 789 ms
309,220 KB
testcase_26 AC 795 ms
309,220 KB
testcase_27 AC 801 ms
309,220 KB
testcase_28 AC 777 ms
309,220 KB
testcase_29 AC 832 ms
309,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io;
use std::collections::HashMap;

fn solve() -> i32 {
  // input! {
  //   x: i64,
  // }
  let x: i32 = input().parse().unwrap();
  let mut cubes: HashMap<i32, u128> = HashMap::new();
  for a in 0..=300i32 {
    for b in a..=300 {
      for c in b..=300 {
        let y = a.pow(3) + b.pow(3) + c.pow(3);
        if let Some(v) = cubes.get_mut(&y) {
          *v <<= 9;
          *v |= c as u128;
        }else {
          cubes.insert(y, c as u128);
        }
      }
    }
  }
  let mut ans = 0;
  for d in 0..=300i32 {
    for e in d..=300 {
      for f in e..=300 {
        let y = d.pow(3) + e.pow(3) + f.pow(3);
        if let Some(v) = cubes.get(&(x - y)) {
          let mut zero = true;
          let mut u = *v;
          while u > 0 || zero {
            let c = (u & 0x1ff) as i32;
            if c <= d {
              ans += 1;
            }
            u >>= 9;
            zero = false;
          }
        }
      }
    }
  }
  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());
}
0