結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
Bantako
|
| 提出日時 | 2017-07-07 21:38:10 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,188 bytes |
| 記録 | |
| コンパイル時間 | 105 ms |
| コンパイル使用メモリ | 38,656 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-11 01:33:13 |
| 合計ジャッジ時間 | 1,928 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 WA * 10 |
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | main(){
| ^~~~
ソースコード
#include<stdio.h>
#include<string.h>
main(){
char N[10001];
char M[10001];
scanf("%s %s",N,M);
if(strlen(M)==1){
M[1] = M[0];
M[0] = '0';
M[2] = '\0';
}
int base = N[strlen(N)-1] - '0';
int exp = (M[strlen(M)-2] - '0')*10 + M[strlen(M)-1] - '0';
int ans;
if(exp == 0){
ans = 1;
}else{
if(base == 0){
ans = 0;
}
if(base == 1){
ans = 1;
}
if(base == 2){
int num[] = {6,2,4,8};
ans = num[exp%4];
}
if(base == 3){
int num[] = {1,3,6,9,7};
ans = num[exp%5];
}
if(base == 4){
int num[] = {6,4};
ans = num[exp%2];
}
if(base == 5){
ans = 5;
}
if(base == 6){
ans = 6;
}
if(base == 7){
int num[] = {1,7,9,3};
ans = num[exp%4];
}
if(base == 8){
int num[] = {6,8,4,2};
ans = num[exp%4];
}
if(base == 9){
int num[] = {1,9};
ans = num[exp%2];
}
}
printf("%d\n",ans);
}
Bantako