結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-24 21:54:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 596 bytes |
| コンパイル時間 | 772 ms |
| コンパイル使用メモリ | 83,472 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 01:37:50 |
| 合計ジャッジ時間 | 1,913 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
//#include<bits/stdc++.h>
using namespace std;
int main() {
string a,b;
cin>>a>>b;
if(b=="0"){
{
cout<<1<<endl;
return 0;
}
}
int t=0,n=0;b="0"+b;
n=b[b.size()-1]-'0'+(b[b.size()-2]-'0')*10;
n%=4;
t=a[a.size()-1]-'0';
if(!n)n=4;
int y=t;
//cout<<n;
for(int i=0;i<n-1;i++)
y*=t;
cout<<y%10<<endl;
return 0;
}