結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2015-05-25 19:06:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 349 bytes |
コンパイル時間 | 1,292 ms |
コンパイル使用メモリ | 159,660 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 01:16:06 |
合計ジャッジ時間 | 2,212 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ string a,b; cin>>a>>b; if (b == "0") { cout << 1 << endl; return 0; } int x = a[a.length() -1] - '0'; int y = b[b.length() -1] - '0'; if(b.length() >= 2) y += 10 * (b[b.length() -2] - '0'); if (b.length() >= 3) y+=100; int s = 1; for(int i=0;i<y;i++){ s *= x; s %= 10; } cout << s << endl; }