#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
int n,m,count=0,sum=0;
while(scanf("%d %d",&n,&m)!=EOF){
for(n;sum<m;n++){
sum=sum+n;
count++;
}
printf("%d\n",count);
n=m=count=sum=0;
}
return 0;
}
送出後
您的答案為: 0 正確答案為: 202
#include
#include
#include
int main(int argc, char *argv[]) {
int n,m,count=0,sum=0;
while(scanf("%d %d",&n,&m)!=EOF){
for(n;sum<m;n++){
sum=sum+n;
count++;
}
printf("%d\n",count);
n=m=count=sum=0;
}
return 0;
}
送出後
#0: 100% WA (line:5)
您的答案為: 0 正確答案為: 202
你的sum 不能一開始就設0
要是 n = -500 , m = -3
sum > m 會直接true