結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2015-04-05 15:40:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 731 bytes |
コンパイル時間 | 787 ms |
コンパイル使用メモリ | 92,788 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 01:13:47 |
合計ジャッジ時間 | 1,777 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; int main() { string s, t; cin >> s >> t; if(t == "0"){ cout << 1 << endl; return 0; } t = "0" + t; int n = stoi(s.substr(s.size() - 1)); int m = stoi(t.substr(t.size() - 2)) + 4; int x = n; for(int i=1; i<m; ++i){ x *= n; x %= 10; } cout << x << endl; return 0; }