ACM——A + B Problem (3)

  1. Home
  2. Problems
  3. 1086

A + B Problem (3)

时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte
总提交:2317            测试通过:1452

描述

Calculate a + b.

输入

The input will consist of an integer N in the first line, and N pairs of integers a and b,separated by a space, one pair of integers per line.

输出

For each pair of input integers a and b you should output the sum of a and b in one line,and with one line of output for each line in input.

样例输入

2
1 5
3 3

样例输出

6
6

题目来源

#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int* r=new int[n];
    int i,a,b;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        r[i]=a+b;
    }
    for(i=0;i<n;i++)
        cout<<r[i]<<endl;
    return 0;
}

ACM——A + B Problem (3)

时间: 2024-11-10 14:29:41

ACM——A + B Problem (3)的相关文章

ACM: A + B Problem II (两个大整数相加)

Code: #include <stdlib.h> #include <stdio.h> #include <string.h> #define MAX 1000 //给数组赋值 void arrV(int a[],int len,int p){ int i; for(i=0;i<len;i++){ a[i]=p; } } //打印数组中的运算结果 void printRverse(int a[]){ int len=0,i=0; while(a[i]!=-1){

ACM——A + B Problem (2)

A + B Problem (2) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2600            测试通过:1372 描述 Calculate a + b. 输入 The input will consist of a series of pairs of integers a and b,separated by a space, one pair of integers per line. A line c

ACM——A + B Problem (4)

A + B Problem (4) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2496            测试通过:1249 描述 Calculate the sum of some integers. 输入 The input will consist of multiple test cases. Each test case consist of an integer N and then N integers

ACM - a + b Problem

前几天看了ACM的第一题,映入眼帘的是一个“简单”的题目: 输入两个数,a,b 输出他们的和. 本着,此乃ACM的原则,便有了如下的思考: ACM的题目肯定很难,a+b,怎么可能直接printf,不行,应该不是这么简单. 是否可以利用字符串的方式进行解答,思路我都想好了. 思路如下: ================================================================= 1.用字符串来获取输入的数字. 2.两个字符串相加,将其限定在0-9表示的范围内.

杭电 ACM HDU Train Problem I

Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25008    Accepted Submission(s): 9435 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays

ACM——A Simple Problem with Integers(线段树的精华版)

Description 给出了一个序列,你需要处理如下两种询问. "C a b c"表示给[a, b]区间中的值全部增加c (-10000 ≤ c ≤ 10000). "Q a b" 询问[a, b]区间中所有值的和. Input 第一行包含两个整数N, Q.1 ≤ N,Q ≤ 100000. 第二行包含n个整数,表示初始的序列A (-1000000000 ≤ Ai ≤ 1000000000). 接下来Q行询问,格式如题目描述. Output 对于每一个Q开头的询问

hdu acm 1023 Train Problem II -&gt;卡特兰(Catalan大数)

#include<iostream> using namespace std; struct Node //节点 { int num[105]; int len; //数的长度 } a[105]; void CalCatalen() //卡特兰数计算 { int i,j,len,c,t; //len长度,c进位 a[1].num[0]=a[1].len=1; len=1; for(i=2;i<=100;i++) { for(j=0;j<len;j++) //乘法,分子部分 a[i]

[ACM] POJ 2947 Widget Factory (高斯消元)

Widget Factory Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 4436   Accepted: 1502 Description The widget factory produces several different kinds of widgets. Each widget is carefully built by a skilled widgeteer. The time required to

ural 1113,jeep problem

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1113 网上的解答铺天盖地.我硬是花了两天才懂了点. wiki上的解释:https://en.wikipedia.org/wiki/Jeep_problem 解答:每个点的油量是500,500*2,500*3... ... 每次的距离是500,500/3,500/5,... ...,500/2n-1; #include <bits/stdc++.h> using namespace s