結果
問題 |
No.167 N^M mod 10
|
ユーザー |
|
提出日時 | 2018-10-13 23:40:46 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 689 bytes |
コンパイル時間 | 12,886 ms |
コンパイル使用メモリ | 401,028 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 18:14:40 |
合計ジャッジ時間 | 11,390 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 16 |
ソースコード
#![allow(non_snake_case)] use std::io::{ self }; use std::iter::{ FromIterator }; fn readline() -> Vec<char> { let mut s = String::new(); io::stdin().read_line(&mut s).expect("i/o error"); s.trim().chars().collect() } fn main() { let N = readline(); let M = readline(); let x = N.last().unwrap().to_digit(10).unwrap(); if M == &['0'] { println!("1"); return; } let y = match M.len() { 1 => String::from_iter(M[M.len()-1..].iter()).parse::<u32>().unwrap(), _ => String::from_iter(M[M.len()-2..].iter()).parse::<u32>().unwrap(), } % 4; let ans = x.pow(if y == 0 { 4 } else { y }); println!("{}", ans); }