結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー ohreitetsu
提出日時 2017-11-20 17:52:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 306 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 53,852 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 03:21:54
合計ジャッジ時間 1,234 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef unsigned long long LL;
int main(int argc, char* argv[])
{
	int M;
	cin>>M;
	if (M==0 || M%2017==0){
		cout<<0<<endl;
		return 0;
	}
	int i=0;
	LL S=1;
	LL s1=2017*2017;
	for (i=0;i<2017;i++){
		S*=s1;
		S%=M;
	}
	S+=2017;
	S%=M;
	cout<<S<<endl;
	return 0;
}
0