QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21309#2820. 令人难以忘记的题目名称DaBenZhongXiaSongKuaiDi#WA 58ms4832kbC++20597b2022-03-04 14:56:542022-05-08 02:52:00

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 02:52:00]
  • Judged
  • Verdict: WA
  • Time: 58ms
  • Memory: 4832kb
  • [2022-03-04 14:56:54]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,p;
int a[N];
int main(){
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]%=p;
	}
	if(n%p){
		for(int i=1;i<=n;i++){
			if(a[i]!=a[1]){
				cout<<"-1\n";
				return 0;
			}
		}
		cout<<"1\n";
		return 0;
	}
	int T=0;
	while(T<=p){
		bool flg=true;
		for(int i=1;i<=n-T;i++){
			if(a[i]!=a[1]){
				flg=false;
				break;
			}
		}
		if(flg){
			cout<<T+1;
			return 0;
		}
		for(int i=1;i<n-T;i++){
			a[i]=(a[i+1]-a[i]+p)%p;
		}
		T++;
	}
	cout<<-1;
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 58ms
memory: 4832kb

input:

297910 31
113232 54750 68197 111096 34111 93605 123591 18035 81089 116592 24694 31596 60286 93804 59021 38782 20907 112337 52523 99808 71474 60598 132242 65758 78755 58580 4515 138889 92332 154059 2039 74180 53778 93861 30218 87862 32418 153778 129564 113461 138995 154233 145061 44213 116624 72685 8...

output:

-1

result:

wrong answer 1st lines differ - expected: '29019', found: '-1'