1. 程式人生 > >CSU 1000/1001/1002 A+B問題

CSU 1000/1001/1002 A+B問題

1000:

Description

Your task is to Calculate a + b.

Input

Input contains multiple test cases. Each test case consists of a pair of integers a and b0<=a,b<=20, separated by a space, one pair of integers per line.

Output

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.

Sample Input

1 1

Sample Output

2

程式碼:

#include<iostream>
using namespace std;
 
int main()
{
    inta, b;
    while(cin >> a >> b)
    {
        cout << a + b << endl;
    }
    return 0;
}

1001:

Description

Your task is to Calculate a + b.

Input

There are multiple test cases. Each test case contains only one line. Each line consists of a pair of real number a and b(0<=a,b<=1000000), separated by a space.

Output

For each case, output the answer in one line rounded to 4 digits after the decimal point.

Sample Input

1 510 200.1 1.5

Sample Output

6.000030.00001.6000
程式碼:
#include<iostream>
using namespace std;
 
int main()
{
    double a, b;
    while(cin >> a >> b)
    {
        printf("%.4f"
,a+b); cout << endl; } return 0; }

1002:

Description

Your task is to Calculate a + b.

Input

There are multiple test cases. Each test case contains only one line. Each line consists of a pair of integers a and b1=< a,b <=1016, separated by a space. Input is followed by a single line with a = 0, b = 0, which should not be processed.

Output

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.

Sample Input

1 5
10 20
10000000000000000 10000000000000000
0 0

Sample Output

6
30
20000000000000000

程式碼:

#include<iostream>
using namespace std;
 
int main()
{
    long long a, b;
    while(cin >> a >> b)
    {
        if(a == 0 && b == 0)break;
        cout << a + b<<endl;
    }
    return 0;
}

相關推薦

CSU 1000/1001/1002 A+B問題

1000: Description Your task is to Calculate a + b. Input Input contains multiple test cases.

HPU 1002 A + B Problem II【大數】

lar 保存 memory positive test size mod ack auth A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/327

甲級1002 A+B for Polynomials (25)

指數 lines term ios esp printf contains n) lin 題目描述: This time, you are supposed to find A+B where A and B are two polynomials. Input Ea

PAT 甲級1002 A+B for Polynomials (25)

文本 please terms struct suppose 作者 notice opera and 1002. A+B for Polynomials (25) 時間限制 400 ms 內存限制 65536 kB 代碼長度限制 16000 B 判題程序 S

1002. A+B for Polynomials (25)

min nta 文本 sum 結果 color printf rms %d 1002. A+B for Polynomials (25) 時間限制 400 ms 內存限制 65536 kB 代碼長度限制 16000 B 判題程序 Standard 作者 C

hduoj 1002 A + B Problem II

hdu cin http short ins line include RoCE problem 原題鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 題目描述如下: A + B Problem II Time Limit

PAT甲級 1002 A+B for Polynomials (25)(25 分)

pac list i++ lease find and for pan put 1002 A+B for Polynomials (25)(25 分) This time, you are supposed to find A+B where A and B are

PAT甲級1002.A+B for Polynomials (25)

font color str 修改 col problem ack 比較 out 題目鏈接:https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000 解題思路: 由

題解報告:hdu 1002 A + B Problem II(大數加法)

return 大數類 class family HERE contains urn integer ons Problem Description I have a very simple problem for you. Given two integers A and

1002 A+B for Polynomials

這一 src image 做了 com sets 提交 分享圖片 bubuko   試著用python做了一點PAT甲級的題目,前幾題不難,比如1002 A+B for Polynomials,地址:https://pintia.cn/problem-sets/994805

1002 A+B for Polynomials (25 分)

This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each

【PAT甲級】1002 A+B for Polynomials

This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each input file cont

1002 A+B for Polynomials - 模擬

思路:普通模擬一下就ok 程式碼如下: #include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<cstring> #incl

PAT 甲級 1002 A+B for Polynomials (25 分)

1002 A+B for Polynomials (25 分) This time, you are supposed to find A+B where A and B are two polynomials.

PAT 1002 A+B for Polynomials (25 分)Java實現

1. 題意 給兩個多項式,把它們加起來 樣例分析: A多項式 2 1 2.4 0 3.2 第一個2指得是2個非0係數項 然後的兩個數,1是項數,2.4是係數 最後兩個數,0是項數,3.2是係數 所以就有f(x) = 2.4x + 3.2 B多項式 2 2 1.5 1 0.5 f(x)

1002. A+B for Polynomials

PS:這道題上週日就寫好了,但是忘了發上來。 題解 題目是把兩個多項式相加再按格式輸出,我用的方法是用一個結構體陣列儲存指數和係數,其實就是一個順序連結串列。 這道題因為之前在陳越姥姥的資料結構課做過類似的,所以做起來思路很清晰。不過還是卡了一會兒,甚至找了別人的程式碼看。最終發現自己的思路有以下缺

HDOJ——1002 A + B Problem II

A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 432906

(甲) 1002 A+B for Polynomials

This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each input file contains one test case.

PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分)

This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case

PAT 甲級 1002 A+B for Polynomials

Description This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file contains multiple test