結果
問題 | No.1022 Power Equation |
ユーザー |
![]() |
提出日時 | 2020-04-10 22:17:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,099 bytes |
コンパイル時間 | 15,110 ms |
コンパイル使用メモリ | 378,936 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 20:43:01 |
合計ジャッジ時間 | 14,881 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 8 |
ソースコード
#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let t = read::<usize>(); let mut ns = vec![]; for _ in 0..t { let n = read::<i64>(); ns.push(n); } for n in ns { let mut ans = n * n; // 1 ans += (n - 1) * n; for p in 2..31i64 { let mut i = 1i64; while i.pow(p as u32) <= n { i += 1; } let inc = (i - 2) * (n + 1 - p) * 2; if n == 5 { debug!(i, p, inc); } ans += (i - 2) * (n / p) * 2; } println!("{}", ans); } } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() }