結果
| 問題 |
No.1359 [Zelkova 3rd Tune] 四人セゾン
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-01-22 22:43:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 352 ms / 2,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 1,827 ms |
| コンパイル使用メモリ | 196,888 KB |
| 最終ジャッジ日時 | 2025-01-18 05:01:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 75 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%d%d",&N,&K,&M);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:14:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | rep(i,4){ rep(j,N) scanf("%d",&A[i][j]); sort(A[i],A[i]+N); }
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
ULL powm(ULL a,ULL i,ULL m){ ULL r=1; while(i){ if(i%2) r=r*a%m; a=a*a%m; i/=2; } return r; }
int N,K,M;
int A[4][200000];
int main() {
scanf("%d%d%d",&N,&K,&M);
rep(i,4){ rep(j,N) scanf("%d",&A[i][j]); sort(A[i],A[i]+N); }
ULL ans=0;
rep(i,N){
int x[4]; rep(j,4) x[j]=A[j][i]; sort(x,x+4);
ans+=powm(x[3]-x[0],K,M);
}
ans%=M;
printf("%llu\n",ans);
return 0;
}
Nachia