結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
|
| 提出日時 | 2015-09-21 15:05:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 582 bytes |
| コンパイル時間 | 411 ms |
| コンパイル使用メモリ | 59,032 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-19 08:26:36 |
| 合計ジャッジ時間 | 1,148 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 WA * 18 |
ソースコード
#include <iostream>
using namespace std;
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lb;
/* ここからが本編 */
int main(void)
{
ll i,j,k;
ll memory[2];
ll n,m;
ll tmp;
ll ans = 0;
cin >> n >> m;
ans = 1;
n %= 10;
tmp = n;
for(i=2;;i++) {
tmp = (tmp*n)%10;
if(tmp == n) break;
}
m %= i;
for(i=0;i<m;i++) ans = (ans*n) % 10;
cout << ans << endl;
return 0;
}