結果

問題 No.167 N^M mod 10
ユーザー kapo
提出日時 2016-05-21 12:11:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 904 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 56,884 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-22 01:31:05
合計ジャッジ時間 1,326 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int calc(std::string, std::string)’:
main.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
using namespace std;
/*
0 0
1 1
2 4 8 6 2
3 9 7 1 3
4 6 4
5 5
6 6
7 9 3 1 7
8 4 2 6 8
9 1 9
*/
int calc(string s1, string s2)
{
int n, m;
char c;
c = s1[s1.size()-1];
n = (int)c % 48;
c = s2[s2.size() - 1];
m = (int)c % 48;
if(m == 0 && s2.size() == 1) return 1;
if(s2.size() >= 2) {
c = s2[s2.size() - 2];
if ((int)c % 48 == 0 && m == 0) m = 100;
else m += ((int)c % 48) * 10;
}
if(n == 0 || n == 1 || n == 5 || n == 6) return n;
int c4[2] = {6,4};
if(n == 4) return c4[m%2];
int c9[2] = {1,9};
if(n == 9) return c9[m%2];
int c2[4] = {6,2,4,8};
if(n == 2) return c2[m%4];
int c3[4] = {1,3,9,7};
if(n == 3) return c3[m%4];
int c7[4] = {1,7,9,3};
if(n == 7) return c7[m%4];
int c8[4] = {6,8,4,2};
if(n == 8) return c8[m%4];
}
int main(void)
{
string s1, s2;
cin >> s1 >> s2;
cout << calc(s1,s2) << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0