結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
tetsuzuki1115
|
| 提出日時 | 2018-02-15 00:29:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 816 bytes |
| コンパイル時間 | 593 ms |
| コンパイル使用メモリ | 81,332 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-23 11:35:25 |
| 合計ジャッジ時間 | 1,477 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 11 WA * 16 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000000007;
int main() {
string N,M;
cin >> N >> M;
if ( M == "0" ) { cout << 1 << endl; return 0; }
int a = N[N.length()-1] - '0';
int b[4];
int n = a;
for ( int i = 0; i < 4; i++ ) {
b[i] = n;
n *= a;
n %= 10;
}
string s;
for ( int i = M.length()-1; i >= 0; i-- ) {
s += M[i];
if ( s.length() == 2 ) { break; }
}
if ( s.length() == 2 ) { swap( s[0], s[1] ); };
int m = stoi(s);
cout << b[m%4 + 4 - 1] << endl;
return 0;
}
tetsuzuki1115