QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#860252#9675. 电池检测Grain_Depot08Compile Error//C++14284b2025-01-18 11:38:562025-01-18 11:39:05

Judging History

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

  • [2025-01-18 11:39:05]
  • 评测
  • [2025-01-18 11:38:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,a,b,n;
int f(int x){return x*(x-1)/2;}
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&a,&b);n=a+b;
        else printf("%d\n",f(n/(a-1))*(a-1-(n%(a-1)))+f(n/(a-1)+1)*(n%(a-1)));
    }
    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:9:9: error: ‘else’ without a previous ‘if’
    9 |         else printf("%d\n",f(n/(a-1))*(a-1-(n%(a-1)))+f(n/(a-1)+1)*(n%(a-1)));
      |         ^~~~
answer.code:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
answer.code:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d%d",&a,&b);n=a+b;
      |         ~~~~~^~~~~~~~~~~~~~