結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2022-12-14 23:52:16 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 13,624 ms |
コンパイル使用メモリ | 379,632 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 16:20:09 |
合計ジャッジ時間 | 15,358 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
fn main() { let mut xx = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok(); let xx: Vec<&str> = xx.split_whitespace().collect(); let n_mod_10 = xx[0].chars().last().unwrap().to_digit(10).unwrap(); let m_mod_100: usize = xx[1][(xx[1].len().max(2) - 2)..].parse().unwrap(); if xx[1] == "0" { println!("1"); } else { println!( "{}", match n_mod_10 { 0 | 1 | 5 | 6 => n_mod_10, 2 => [6, 2, 4, 8][m_mod_100 % 4], 3 => [1, 3, 9, 7][m_mod_100 % 4], 4 => [6, 4][m_mod_100 % 2], 7 => [1, 7, 9, 3][m_mod_100 % 4], 8 => [6, 8, 4, 2][m_mod_100 % 4], 9 => [1, 9][m_mod_100 % 2], _ => unreachable!(), } ); } }