結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
|
| 提出日時 | 2015-12-03 16:40:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 941 bytes |
| コンパイル時間 | 525 ms |
| コンパイル使用メモリ | 57,768 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 08:27:56 |
| 合計ジャッジ時間 | 1,363 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 WA * 6 |
ソースコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/* */
/* mod_pow(x,n)はx^nを返すよ! */
/* modを定義してから使ってね! */
#define mod 10
ll mod_pow(ll x,ll n) {
ll res = 1;
while(n > 0) {
if(n&1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
int n;
void suuzi(char s[],int i,int& j)
{
for(; j < n/2; j++) {
if(s[i+j] < '0' || '9' < s[i+j]) break;
}
}
int main(void)
{
int i,j,k,l;
static char s[10005];
int n,m;
cin >> s;
n = s[strlen(s)-1] - '0';
cin >> s;
if(strlen(s) == 1) m = s[strlen(s)-1] - '0';
else m = atoi(s+strlen(s)-2);
if(m == 0) cout << "1\n" ;
else cout << mod_pow(n%10,m%4+4)%10 << endl;
return 0;
}