結果

問題 No.167 N^M mod 10
コンテスト
ユーザー saytakaPC
提出日時 2015-03-20 00:03:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 272 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 157,708 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-28 23:29:41
合計ジャッジ時間 3,967 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 15 TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,data=1;
	scanf("%d%d",&n,&m);
	n=n*n%10;
	if(m%2==0){
		for(int i=0;i<m/2;i++){
			data*=n;data%=10;
		}
	}else{
		for(int i=0;i<m/2;i++){
			data*=n;data%=10;
		}
		data*=n;
	}
	printf("%d\n",data%10);
}
0