結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2023-01-03 10:56:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 1,000 ms |
コード長 | 400 bytes |
コンパイル時間 | 1,817 ms |
コンパイル使用メモリ | 192,220 KB |
最終ジャッジ日時 | 2025-02-09 23:09:59 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>using namespace std;char s[10010],t[10010];int n,m,ans=1;int main(){cin>>s>>t;n=s[strlen(s)-1]-'0';if(strcmp(t,"0")==0){cout<<1<<endl;return 0;}int len=strlen(t);if(len==1) m=t[0]-'0';else m=(t[len-2]-'0')*10+t[len-1]-'0';m=m%4+4;for(int i=0;i<m;++i)ans=ans*n%10;cout<<ans<<endl;return 0;}