結果
| 問題 | No.3388 Sum of Function |
| コンテスト | |
| ユーザー |
northward
|
| 提出日時 | 2025-12-04 20:55:32 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,042 bytes |
| 記録 | |
| コンパイル時間 | 11,606 ms |
| コンパイル使用メモリ | 402,556 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-04 20:55:46 |
| 合計ジャッジ時間 | 12,860 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 3 |
ソースコード
#![allow(non_snake_case, unused_must_use, unused_imports)]
use std::io::{self, prelude::*};
fn main() {
let (stdin, stdout) = (io::read_to_string(io::stdin()).unwrap(), io::stdout());
let (mut stdin, mut buffer) = (stdin.split_whitespace(), io::BufWriter::new(stdout.lock()));
macro_rules! input {
($t: tt, $n: expr) => {
(0..$n).map(|_| input!($t)).collect::<Vec<_>>()
};
(Chars) => {
input!(String).chars().collect::<Vec<_>>()
};
(Usize1) => {
stdin.next().unwrap().parse::<usize>().unwrap() - 1
};
($t: ty) => {
stdin.next().unwrap().parse::<$t>().unwrap()
};
}
let A = input!(u128);
let B = input!(u128);
let f = |x| x * x * x - x * x + x + 1;
let ans = (A..=B).filter(|&x| is_prime(x)).map(|x| f(x)).sum::<u128>();
writeln!(buffer, "{}", ans);
}
fn is_prime(x: u128) -> bool {
for i in 2..x {
if x % i == 0 {
return false;
}
}
return true;
}
northward