QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416845#8723. 乘二char_miiiCompile Error//C89558b2024-05-22 09:35:482024-05-22 09:35:48

Judging History

你现在查看的是最新测评结果

  • [2024-05-22 09:35:48]
  • 评测
  • [2024-05-22 09:35:48]
  • 提交

answer

#include<stdio.h>
#define MOD 1000000007
long long a[200000];
int main(){
	int n,flag=0;
	long long k,min=0,sum=0;
	scanf("%d%lld",&n,&k);
	getchar();
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(a[i]<a[min]) min=i;
	}
	long long i;
	for(i=0;i<k;i++){
		a[min]*=2;
		min=0;
		flag=0;
		for(int j=0;j<n;j++){
			if(a[j]<a[min]) min=j;
			if(a[j]<MOD) flag=1;
		}
		if(flag==0) break;
	}
	for(int t=0;t<n;t++){
		sum=(sum+a[t])%MOD;
	}
	for(long long j=0;j<k-i;j+=n){
		sum=(sum*2)%MOD;
	}
	printf("%lld",sum);
	return 0;
}

Details

answer.code: In function ‘main’:
answer.code:9:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    9 |  for(int i=0;i<n;i++){
      |  ^~~
answer.code:9:2: note: use option ‘-std=c99’, ‘-std=gnu99’, ‘-std=c11’ or ‘-std=gnu11’ to compile your code
answer.code:13:12: error: conflicting types for ‘i’
   13 |  long long i;
      |            ^
answer.code:9:10: note: previous definition of ‘i’ was here
    9 |  for(int i=0;i<n;i++){
      |          ^
answer.code:18:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
   18 |   for(int j=0;j<n;j++){
      |   ^~~
answer.code:24:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
   24 |  for(int t=0;t<n;t++){
      |  ^~~
answer.code:27:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
   27 |  for(long long j=0;j<k-i;j+=n){
      |  ^~~
answer.code:7:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%d%lld",&n,&k);
      |  ^~~~~~~~~~~~~~~~~~~~~
answer.code:10:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   10 |   scanf("%lld",&a[i]);
      |   ^~~~~~~~~~~~~~~~~~~