problem 1000: A+B problem

原创 2012年03月29日 02:12:57

又趁着兴趣,把这个problem 1000看了看,发觉这道题纯粹是为了介绍acm代码提交方面问题的example,但还是用C做了一下,题目在这里(摸我),代码如下:

#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a, &b);
    printf("%d\n",a+b);
    return 0;
}
没想到的是提交之后,提示“Wrong Answer”,检查了之后再提交,发现还是提示“Wrong Answer”,截图如下,甚是气恼:


于是,开始仔细的把题目看了几遍,发现ustcpku的题目不同,zju给出了正确的答案:

#include <stdio.h>

int main()
{
    int a,b;
    while(scanf("%d %d",&a, &b) != EOF) //注意此处的循环输入!
        printf("%d\n",a+b);
    return 0;
}


最后,提交,终于成功了!

这里提醒了我要注意scanf函数的用法,scanf函数返回从键盘缓冲区读取的字符数,如果在与其格式化输入参数不匹配的时候会返回EOF(-1);

同样的道理,当键盘缓冲区无数据时,scanf函数会阻塞,直到用户从键盘中输入,(回车符);

注意第二段代码中的循环输入!


PS:关于acm代码提交,ustc没找到说明,可以参考zju(点我)的说明,以下是摘录的一些错误说明:

Q:What is the meaning of the judge's reply XXXXX?
A:Here is a list of the judge's replies and their meaning:

Queuing : The judge is so busy that it can't judge your submit at the moment, usualy you just need to wait a minute and your submit will be judged.

Accepted : OK! Your program is correct!.

Presentation Error : Your output format is not exactly the same as the judge's output, although your answer to the problem is correct. Check your output for spaces, blank lines,etc against the problem output specification.

Wrong Answer : Correct solution not reached for the inputs. The inputs and outputs that we use to test the programs are not public (it is recomendable to get accustomed to a true contest dynamic ;-).

Time Limit Exceeded : Your program tried to run during too much time.

Memory Limit Exceeded : Your program tried to use more memory than the judge default settings.

Output Limit Exceeded: Your program tried to write too much information. This usually occurs if it goes into a infinite loop. Currently the output limit is 1M bytes.

Non-zero Exit Code: Your program exited returning a non-zero value to the shell. For languages such as C, this probably means you forgot to add "return 0" at the end of the program. For interpreted languages NZEC will usually mean that your program either crashed or raised an uncaught exception.

Compile Error : The compiler (gcc, g++, fpc, etc) could not compile your program. Of course, warning messages are not error messages. Click the link at the judge reply to see the actual error message.

Out Of Contest Time: this message can only appear during a contest, if a program is submitted out of contest time.

No such problem: Either you have submitted a wrong problem id or the problem is unavailable.

Segmentation Fault : The possible cases of your encountering this error are:

  • 1.buffer overflow --- usually caused by a pointer reference out of range.
  • 2.stack overflow --- please keep in mind that the default stack size is 8192K.

Floating Point Error : Divide by 0

Runtime Error : See FAQ below

杭电1000- A+B Problem

A + B Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)...
  • nvliba
  • nvliba
  • 2015年09月16日 21:49
  • 700

从零开始刷HDOJ(1)【HDOJ1000 - a+b problem】

从零开始刷HDOJ(1)【HDOJ1000 - a+b problem】题面A + B ProblemTime Limit: 2000/1000 MS (Java/Others) Memory ...
  • edward00324258
  • edward00324258
  • 2017年05月19日 16:32
  • 175

HDU 1000 A+B problem

第一篇题解:“水”题A+B的正确解读 #include//万能头文件 using namespace std; int a,b; int main(){ while(cin>>a>>b){ ...
  • Dota_Air
  • Dota_Air
  • 2018年01月26日 00:06
  • 15

被玩坏的题目——A+B Problem

普通方法:C++: #include using namespace std; int a,b; int main(){ cin>>a>>b; cout
  • hh_cnyali
  • hh_cnyali
  • 2016年07月18日 09:36
  • 2862

BZOJ 1000: A+B Problem

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1000 题目大意:输入a,b,输出a+b. 关键字:/ 算法讨论: 作为BZOJ的第一题,目...
  • u013703661
  • u013703661
  • 2014年02月19日 12:09
  • 883

POJ 1000 A+B Problem

A+B Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 382869   ...
  • liangzhaoyang1
  • liangzhaoyang1
  • 2016年03月31日 21:51
  • 777

ZOJ 1001 A + B Problem(Java解法)

import java.util.Scanner; public class Main{     public static void main(String[] args) {      ...
  • CZJCC
  • CZJCC
  • 2014年03月03日 11:03
  • 2025

2016 acm香港网络赛 A题. A+B Problem

题目链接:https://open.kattis.com/problems/aplusb题意:给你一堆数,然后求ai+aj=ak的组成的(i,j,k)对有多少个,并且保证i,j,k小标互不相同。个人感...
  • zzz805
  • zzz805
  • 2016年09月20日 10:13
  • 1680

【网络流+可持久化线段树】[UOJ#77/BZOJ3218]A+B Problem

题目题目链接UOJ#77 BZOJ3218题目描述 分析感谢VFleaKing的博客中的讲解和geng4512的博客中的代码,涨了不少知识。网络流的做法首先我们来看看答案是怎么得到的 ans=∑...
  • outer_form
  • outer_form
  • 2016年03月10日 16:03
  • 1339

BZOJ3218 UOJ#77 A+B Problem(最小割+主席树)

竟然在BZOJ上拿了Rank1太给力啦。 传送门(BZOJ) 传送门(UOJ) 说说这道题目吧: 首先是说说这个构图吧。因为有选择关系,我们很容易想到最小割。 Ans = sigma(i为白色){w[...
  • geng4512
  • geng4512
  • 2016年02月24日 00:34
  • 1418
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:problem 1000: A+B problem
举报原因:
原因补充:

(最多只允许输入30个字)