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

相关文章推荐

Problem 1000

  • 2013年02月04日 20:14
  • 197B
  • 下载

数据结构实验之二叉树一:树的同构数据结构实验之二叉树一:树的同构 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem D

数据结构实验之二叉树一:树的同构 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Descript...

贪心算法 Problem A 1000

STL Problem A  Problem ID:1000  题意:共有编号为1-400的房间,400个房间分布在一条走廊的两边,从左到右按编号大小依次排开,且1和2相对,3和4相对,依次类推。...

Problem 1:Find the sum of all the multiples of 3 or 5 below 1000.

Problem 1: Multiples of 3 and 5If we list all the natural numbers below 10 that are multiples of 3 o...
  • xyh421
  • xyh421
  • 2017年07月09日 18:16
  • 684

hiho 1624 最短游览路线 [Offer收割]编程练习赛35 Problem B

题目2 : 最短游览路线 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 十一期间小Hi被朋友拉去某座名山旅游。这座山上...
  • qdbszsj
  • qdbszsj
  • 2017年11月12日 14:52
  • 106

嘻唰唰第六批Problem G: B 求类中数据成员的最大值-类模板

Description 声明一个类模板,类模板中有三个相同类型的数据成员,有一函数来获取这三个数据成员的最大值。 类模板声明如下: template class Max { publi...

【莫比乌斯函数+除法分块】BZOJ2301(HAOI2011)[Problem b]题解

题目概述求 a≤x≤b,c≤y≤da\le x\le b,c\le y\le d 中 (x,y)=k(x,y)=k 的个数。解题报告好像很多人说是莫比乌斯反演……但是我感觉只用到了狄利克雷卷积和莫比乌...

LintCode-第一题:A+B problem (不用“+”等运算符)(位运算实现加法)

位运算实现加法运算

BZOJ 2301 HAOI2011 Problem b 容斥原理+莫比乌斯反演

题目大意:多次询问有多少个数对(x,y)满足a 首先利用容斥原理将询问分解 问题转化为求有多少个数对(x,y)满足x 这里就可以利用到莫比乌斯反演: 我们令F(d)为GCD(x,y)=d...
  • PoPoQQQ
  • PoPoQQQ
  • 2014年12月16日 11:25
  • 1974

Problem B: 立体空间中的点(II)

Problem B: 立体空间中的点(II) Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 1662  Solved: 1299 [Submit...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:problem 1000: A+B problem
举报原因:
原因补充:

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