結果
| 問題 |
No.480 合計
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-13 16:05:42 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 3,748 bytes |
| コンパイル時間 | 16,278 ms |
| コンパイル使用メモリ | 392,548 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-15 02:32:07 |
| 合計ジャッジ時間 | 17,339 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
コンパイルメッセージ
warning: unnecessary parentheses around method argument
--> src/main.rs:122:35
|
122 | let j = i + self.next((a.len() - i)) as usize;
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
122 - let j = i + self.next((a.len() - i)) as usize;
122 + let j = i + self.next(a.len() - i) as usize;
|
warning: constant `SEED` is never used
--> src/main.rs:130:7
|
130 | const SEED: u32 = 890482;
| ^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: constant `TIME_LIMIT` is never used
--> src/main.rs:131:7
|
131 | const TIME_LIMIT: f64 = 0.98;
| ^^^^^^^^^^
ソースコード
#[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
#[cfg(feature = "single_testcase")]
{
eprint!("[line:{}] ", line!());
eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
}
}
}
fn get_time() -> f64 {
static mut STIME: f64 = -1.0;
let t = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap();
let ms = t.as_secs() as f64 + t.subsec_nanos() as f64 * 1e-9;
unsafe {
if STIME < 0.0 {
STIME = ms;
}
ms - STIME
}
}
//--------------------------------------------------------------------------------
// https://atcoder.jp/contests/intro-heuristics/submissions/14832097
// let D = read!(usize);
// let c = read!([i64]);
// let s = read!([i64]; D);
#[allow(dead_code)]
fn readln() -> String {
let mut line = String::new();
::std::io::stdin()
.read_line(&mut line)
.unwrap_or_else(|e| panic!("{}", e));
line
}
#[allow(unused_macros)]
macro_rules! read {
($($t:tt),*; $n:expr) => {{
let stdin = ::std::io::stdin();
let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
let line = line.unwrap();
let mut it = line.split_whitespace();
_read!(it; $($t),*)
}).collect::<Vec<_>>();
ret
}};
($($t:tt),*) => {{
let line = readln();
let mut it = line.split_whitespace();
_read!(it; $($t),*)
}};
}
macro_rules! _read {
($it:ident; [char]) => {
_read!($it; String).chars().collect::<Vec<_>>()
};
($it:ident; [u8]) => {
Vec::from(_read!($it; String).into_bytes())
};
($it:ident; usize1) => {
$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
};
($it:ident; [usize1]) => {
$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
};
($it:ident; [$t:ty]) => {
$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
};
($it:ident; $t:ty) => {
$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
};
($it:ident; $($t:tt),+) => {
($(_read!($it; $t)),*)
};
}
//--------------------------------------------------------------------------------
// https://atcoder.jp/contests/hokudai-hitachi2017-1/submissions/1797182
// u32 -> usize
pub struct XorShift {
pub x: [usize; 4],
}
impl XorShift {
pub fn new(mut seed: usize) -> XorShift {
let mut x = [0; 4];
for i in 0..4 {
seed = 1812433253usize
.wrapping_mul(seed ^ (seed >> 30))
.wrapping_add(i as usize);
x[i] = seed;
}
XorShift { x: x }
}
pub fn next_usize(&mut self) -> usize {
let t = self.x[0] ^ (self.x[0] << 11);
for i in 0..3 {
self.x[i] = self.x[i + 1]
}
self.x[3] = self.x[3] ^ (self.x[3] >> 19) ^ t ^ (t >> 8);
self.x[3]
}
/// [0, n)
pub fn next(&mut self, n: usize) -> usize {
loop {
let t = self.next_usize();
let r = t % n;
if (t - r).checked_add(n).is_some() {
return r;
}
}
}
pub fn shuffle<T>(&mut self, a: &mut [T]) {
for i in 0..a.len() {
let j = i + self.next((a.len() - i)) as usize;
a.swap(i, j);
}
}
}
//--------------------------------------------------------------------------------
const SEED: u32 = 890482;
const TIME_LIMIT: f64 = 0.98;
fn main() {
get_time();
let n = read!(i32);
let mut sm = 0;
for i in 1..=n {
sm += i;
}
println!("{}", sm);
eprintln!("time_elapsed: {:.3}", get_time());
}