結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー kotatsugame
提出日時 2021-01-29 22:59:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 630 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 70,016 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-06-27 09:28:21
合計ジャッジ時間 38,874 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 75
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,K;
long M;
long p(long a,long b){return b?p(a*a%M,b/2)*(b%2?a:1)%M:1;}
int A[4][2<<17];
main()
{
	cin>>N>>K>>M;
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<N;j++)cin>>A[i][j];
		sort(A[i],A[i]+N);
	}
	long ans=0;
	for(int i=0;i<N;i++)
	{
		int B[4];
		for(int j=0;j<4;j++)B[j]=A[j][i];
		sort(B,B+4);
		(ans+=p(B[3]-B[0],K))%=M;
	}
	cout<<ans<<endl;
}
0