結果
問題 |
No.557 点対称
|
ユーザー |
|
提出日時 | 2022-11-26 01:07:01 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 13,917 ms |
コンパイル使用メモリ | 375,572 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 07:12:35 |
合計ジャッジ時間 | 14,336 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
const MOD: usize = 1e9 as usize + 7; fn power(base: usize, times: usize) -> usize { if times == 0 { return 1usize; } if times == 1 { return base; } let temp = power(base, times/2); temp * temp % MOD * power(base, times%2) % MOD } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); if n == 1 { println!("2"); return; } let mut result = if n % 2 == 1 { 3 } else { 1 }; if n > 1 { result *= 4; } if n > 3 { result *= power(5, n / 2 - 1); } result %= MOD; println!("{}", result); }