結果
問題 |
No.435 占い(Extra)
|
ユーザー |
![]() |
提出日時 | 2023-04-26 02:51:11 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 291 ms / 2,000 ms |
コード長 | 1,938 bytes |
コンパイル時間 | 13,955 ms |
コンパイル使用メモリ | 382,740 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 11:35:47 |
合計ジャッジ時間 | 18,067 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
warning: unnecessary parentheses around `while` condition --> src/main.rs:51:19 | 51 | while (x%3==0){ | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 51 - while (x%3==0){ 51 + while x%3==0 { | warning: unnecessary parentheses around `while` condition --> src/main.rs:60:19 | 60 | while (x%3==0){ | ^ ^ | help: remove these parentheses | 60 - while (x%3==0){ 60 + while x%3==0 { | warning: unused variable: `tests` --> src/main.rs:10:9 | 10 | for tests in 0..t{ | ^^^^^ help: if this is intentional, prefix it with an underscore: `_tests` | = note: `#[warn(unused_variables)]` on by default warning: variable `INV` should have a snake case name --> src/main.rs:8:9 | 8 | let INV=vec![0,1,5,0,7,2,0,4,8]; | ^^^ help: convert the identifier to snake case: `inv` | = note: `#[warn(non_snake_case)]` on by default
ソースコード
fn main() { let t: usize = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse().unwrap() }; let INV=vec![0,1,5,0,7,2,0,4,8]; for tests in 0..t{ let (n,x,a,b,m): (usize, i32, i32, i32, i32) = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap() ) }; let mut now=x; let mut flag0=0; if now%10==0{ flag0=1; } let mut ans=0; let mut two: i32=1; let mut three=0; for i in 0..n{ if i==0{ ans=(ans+now%10)%9; continue; } now=((now^a)+b)%m; if (now%10)!=0{ flag0=0; } if i==n-1{ ans=(ans+now%10)%9; continue; } let mut x:i32=i as i32; while (x%3==0){ x/=3; three-=1; } two=two*INV[(x%9) as usize]%9; x=(n-i) as i32; while (x%3==0){ x/=3; three+=1; } two=two*x%9; if three==0{ ans=(ans+(now%10)*two)%9; } else if three==1{ ans=(ans+(now%10)*two*3)%9; } } if flag0==1{ println!("0"); continue; } if ans==0{ ans=9; } println!("{}", ans); } }