QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#416844#8723. 乘二char_miiiCompile Error//C89543b2024-05-22 09:33:082024-05-22 09:33:08

Judging History

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

  • [2024-05-22 09:33:08]
  • 评测
  • [2024-05-22 09:33:08]
  • 提交

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%ld",&n,&k);
	getchar();
	for(int i=0;i<n;i++){
		scanf("%ld",&a[i]);
		if(a[i]<a[min]) min=i;
	}
	int 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(int j=0;j<k-i;j+=n){
		sum=(sum*2)%MOD;
	}
	printf("%ld",sum);
	return 0;
}

详细

answer.code: In function ‘main’:
answer.code:7:13: warning: format ‘%ld’ expects argument of type ‘long int *’, but argument 3 has type ‘long long int *’ [-Wformat=]
    7 |  scanf("%d%ld",&n,&k);
      |           ~~^     ~~
      |             |     |
      |             |     long long int *
      |             long int *
      |           %lld
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:10:12: warning: format ‘%ld’ expects argument of type ‘long int *’, but argument 2 has type ‘long long int *’ [-Wformat=]
   10 |   scanf("%ld",&a[i]);
      |          ~~^  ~~~~~
      |            |  |
      |            |  long long int *
      |            long int *
      |          %lld
answer.code:13:6: error: redeclaration of ‘i’ with no linkage
   13 |  int 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(int j=0;j<k-i;j+=n){
      |  ^~~
answer.code:30:12: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
   30 |  printf("%ld",sum);
      |          ~~^  ~~~
      |            |  |
      |            |  long long int
      |            long int
      |          %lld
answer.code:7:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%d%ld",&n,&k);
      |  ^~~~~~~~~~~~~~~~~~~~
answer.code:10:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   10 |   scanf("%ld",&a[i]);
      |   ^~~~~~~~~~~~~~~~~~