結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2017-03-27 08:26:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 549 ms |
コンパイル使用メモリ | 64,640 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 01:41:25 |
合計ジャッジ時間 | 1,414 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | main() | ^~~~ main.cpp: In function 'int main()': main.cpp:41:15: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized] 41 | cout<<ans<<endl; | ^~~ main.cpp:7:13: note: 'ans' was declared here 7 | int ans,m=(t[t.length()-2]-48)*10+t[t.length()-1]-48; | ^~~
ソースコード
#include<iostream>using namespace std;main(){string s,t;cin>>s>>t;int n=s[s.length()-1]-48;int ans,m=(t[t.length()-2]-48)*10+t[t.length()-1]-48;switch(n){case 0:ans=t=="0"?1:0;break;case 1:ans=1;break;case 2:ans=t=="0"?1:m%4?m%4<2?2:m%4<3?4:8:6;break;case 3:ans=m%4?m%4<2?3:m%4<3?9:7:1;break;case 4:ans=t=="0"?1:m%2?4:6;break;case 5:ans=t=="0"?1:5;break;case 6:ans=t=="0"?1:6;break;case 7:ans=m%4?m%4<2?7:m%4<3?9:3:1;break;case 8:ans=t=="0"?1:m%4?m%4<2?8:m%4<3?4:2:6;break;case 9:ans=m%2?9:1;break;}cout<<ans<<endl;}