1:A+B Problem

总时间限制: 
1000ms 
内存限制: 
65536kB
描述

Calculate a + b

输入
Two integer a,,b (0 ≤ a,b ≤ 10)
输出
Output a + b
样例输入
1 2
样例输出
3
提示
Q: Where are the input and the output?

A: Your program shall always read input from stdin (Standard Input) and write output to stdout (Standard Output). For example, you can use ‘scanf‘ in C or ‘cin‘ in C++ to read from stdin, and use ‘printf‘ in C or ‘cout‘ in C++ to write to stdout.

You shall not output any extra data to standard output other than that required by the problem, otherwise you will get a "Wrong Answer".

User programs are not allowed to open and read from/write to files. You will get a "Runtime Error" or a "Wrong Answer" if you try to do so.

Here is a sample solution for problem 1000 using C++/G++:

[cpp] view plaincopyprint?

  1. #include <iostream>
  2. using namespace std;
  3. int  main()
  4. {
  5. int a,b;
  6. cin >> a >> b;
  7. cout << a+b << endl;
  8. return 0;
  9. }

It‘s important that the return type of main() must be int when you use G++/GCC,or you may get compile error.

Here is a sample solution for problem 1000 using C/GCC:

[cpp] view plaincopyprint?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a,b;
  5. scanf("%d %d",&a, &b);
  6. printf("%d\n",a+b);
  7. return 0;
  8. }

Here is a sample solution for problem 1000 using PASCAL:

[plain] view plaincopyprint?

  1. program p1000(Input,Output);
  2. var
  3. a,b:Integer;
  4. begin
  5. Readln(a,b);
  6. Writeln(a+b);
  7. end.

Here is a sample solution for problem 1000 using JAVA:

Now java compiler is jdk 1.5, next is program for 1000

[java] view plaincopyprint?

  1. import java.io.*;
  2. import java.util.*;
  3. public class Main
  4. {
  5. public static void main(String args[]) throws Exception
  6. {
  7. Scanner cin=new Scanner(System.in);
  8. int a=cin.nextInt(),b=cin.nextInt();
  9. System.out.println(a+b);
  10. }
  11. }

Old program for jdk 1.4

[java] view plaincopyprint?

  1. import java.io.*;
  2. import java.util.*;
  3. public class Main
  4. {
  5. public static void main (String args[]) throws Exception
  6. {
  7. BufferedReader stdin =
  8. new BufferedReader(
  9. new InputStreamReader(System.in));
  10. String line = stdin.readLine();
  11. StringTokenizer st = new StringTokenizer(line);
  12. int a = Integer.parseInt(st.nextToken());
  13. int b = Integer.parseInt(st.nextToken());
  14. System.out.println(a+b);
  15. }
  16. }

源代码:



[java] view plaincopyprint?

  1. <pre name="code" class="cpp">int main(void)
  2. {
  3. int a, b;
  4. scanf("%d%d", &a, &b);
  5. printf("%d", a+b);
  6. return 0;
  7. }

1:A+B Problem,布布扣,bubuko.com

时间: 2024-10-02 04:38:47

1:A+B Problem的相关文章

A Math Problem

A Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 237    Accepted Submission(s): 117 Problem Description You are given a positive integer n, please count how many positive integers

Water Problem

water problem 发布时间: 2015年10月10日 15:34   时间限制: 1000ms   内存限制: 256M 描述 题意很简单 给你N个数, Q个查询 每次查询给你一个区间[L, R] 你要找出 [L, R] 这个区间里面取模M后的最大值. 输入 第一行一个T,表示测试数据组数.第二行两个整数N, M (1<=N<=10^5, 1<=M<=10^9).第三行给你N个整数 整数范围在1到10^9之间.第四行给你一个整数Q. ( 1<=Q<=10^5)

FOJ Problem 2261 浪里个浪

                                                                                                                                                           Problem 2261 浪里个浪 Accept: 40    Submit: 106Time Limit: 1500 mSec    Memory Limit : 32768 KB Pro

XJTUOJ wmq的A&#215;B Problem FFT

wmq的A×B Problem 发布时间: 2017年4月9日 17:06   最后更新: 2017年4月9日 17:07   时间限制: 3000ms   内存限制: 512M 描述 这是一个非常简单的问题. wmq如今开始学习乘法了!他为了训练自己的乘法计算能力,写出了n个整数,并且对每两个数a,b都求出了它们的乘积a×b.现在他想知道,在求出的n(n−1)2个乘积中,除以给定的质数m余数为k(0≤k<m)的有多少个. 输入 第一行为测试数据的组数. 对于每组测试数据,第一行为2个正整数n,

hidden node and exposed node problem

Exposed node problem In wireless networks, theexposed node problem occurs when a node is prevented from sending packets to other nodes because of a neighboring transmitter. Consider an example of 4 nodes labeled R1, S1, S2, and R2, where the two rece

南阳524 A-B Problem

A-B Problem 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 A+B问题早已经被大家所熟知了,是不是很无聊呢?现在大家来做一下A-B吧. 现在有两个实数A和B,聪明的你,能不能判断出A-B的值是否等于0呢? 输入 有多组测试数据.每组数据包括两行,分别代表A和B. 它们的位数小于100,且每个数字前中可能包含+,- 号. 每个数字前面和后面都可能有多余的0. 每组测试数据后有一空行. 输出 对于每组数据,输出一行. 如果A-B=0,输出YES,否则输出NO

Lab 1: Write a java program for the triangle problem and test the program with Junit.

Tasks: 1. Install Junit(4.12), Hamcrest(1.3) with Eclipse 将两个jar包添加到工程中 2. Install Eclemma with Eclipse 3. Write a java program for the triangle problem and test the program with Junit. [Description of triangle problem]Function triangle takes three i

HDU 1016 Prime Ring Problem(DFS)

题目链接 Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number of first circle should always

poj 3320 Jessica&#39;s Reading Problem(尺取法+map/hash)

题目:http://poj.org/problem?id=3320 题意:给定N个元素的数组,找出最短的一段区间使得区间里面的元素种类等于整个数组的元素种类. 分析:暴力枚举区间的起点x,然后找到最小的y,使得区间[x,y]满足条件,x向有移位后变成x',现在的y'肯定不至于在y的左边.存状态的话map和hash都可以. map代码: #include <iostream> #include <set> #include <map> #include <cstdi

hdu 5293 Tree chain problem(树链剖分+树形dp)

题目链接:hdu 5293 Tree chain problem 维护dp[u], sum[u],dp[u]表示以u为根节点的子树的最优值.sum[u]表示以u节点的所有子节点的dp[v]之和.对于边a,b,w,在LCA(a,b)节点的时候进行考虑.dp[u] = min{dp[u], Sum(a,b) - Dp(a,b) + sum[u] | (ab链上的点,不包括u } #pragma comment(linker, "/STACK:1024000000,1024000000")