BIG NUMBER 算法竞赛入门经典 刘汝佳

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

424-Integer Inquiry

One of the first users of BIT's new supercomputer was Chip Diller.He extended his exploration of powers of3to go from0 to333and he explored taking various sums of those numbers.

``This supercomputer is great,''remarked Chip.``I only wish Timothy were here to see these results.''(Chip moved to a new apartment,once one became available on the third floor of the Lemon Sky apartments on Third Street.)

Input

The input will consist of at most100lines of text,each of which contains a single VeryLongInteger.Each VeryLongInteger will be100or fewer characters in length,and will only contain digits(no VeryLongInteger will be negative).

The final input line will contain a single zero on a line by itself.

Output

Your program should output the sum of the VeryLongIntegers given in the input.

Sample Input

123456789012345678901234567890

123456789012345678901234567890

123456789012345678901234567890

Sample Output

370370367037037036703703703670

10106–Product

The Problem

The problem is to multiply two integers X,Y.(0<=X,Y<10250)

The Input

The input will consist of a set of pairs of lines.Each line in pair contains one multiplyer.

The Output

For each input pair of lines the output line should consist one integer the product.

Sample Input

12

12

2

222222222222222222222222

Sample Output

144

444444444444444444444444

465–Overflow

Write a program that reads an expression consisting of two non-negative integer and an operator.Determine if either integer or the result of the expression is too large to be represented as a``normal''signed integer(type integer if you are working Pascal,type int if you are working in C).

Input

An unspecified number of lines.Each line will contain an integer,one of the two operators+or*,and another integer. Output

For each line of input,print the input followed by0-3lines containing as many of these three messages as are appropriate: ``first number too big'',``second number too big'',``result too big''.

Sample Input

300+3

9999999999999999999999+11

Sample Output

300+3

9999999999999999999999+11

first number too big

result too big

748-ExponentiationProblems involving the computation of exact values of very large magnitude and precision are common.For example,the computation of the national debt is a taxing experience for many computer systems.

This problem requires that you write a program to compute the exact value of Rn where R is a real number(0.0

Input

The input will consist of a set of pairs of values for R and n.The R value will occupy columns1through6,and the n value will be in columns8and9.

Output

The output will consist of one line for each line of input giving the exact value of Rn.Leading zeros and insignificant trailing zeros should be suppressed in the output.

Sample Input

95.12312

0.432120

5.123415

6.75929

98.99910

1.010012

Sample Output

548815620517731830194541.899025343415715973535967221869852721

.00000005148554641076956121994511276767154838481760200726351203835429763013462401 43992025569.928573701266488041146654993318703707511666295476720493953024

29448126.764121021618164430206909037173276672

90429072743629540498.107596019456651774561044010001

1.126825030131969720661201

10494-If We Were a Child Again

Input:standard input

Output:standard output

Time Limit:7seconds

“Oooooooooooooooh!

If I could do the easy mathematics like my school days!!

I can guarantee,that I’d not make any mistake this time!!”

Says a smart university student!!

But his teacher even smarter–“Ok!I’d assign you such projects in your software lab.Don’t be so sad.”

“Really!!”-the students feels happy.And he feels so happy that he cannot see the smile in his teacher’s face.

The Problem

The first project for the poor student was to make a calculator that can just perform the basic arithmetic operations.

But like many other university students he doesn’t like to do any project by himself.He just wants to collect programs from here and there.As you are a friend of him,he asks you to write the program.But,you are also intelligent enough to tackle this kind of people.You agreed to write only the(integer)division and mod(%in C/C++)operations for him.

Input

Input is a sequence of lines.Each line will contain an input number.One or more spaces.A sign(division or mod).Again spaces.And another input number.Both the input numbers are non-negative integer.The first one may be arbitrarily long. The second number n will be in the range(0

Output

A line for each input,each containing an integer.See the sample input and output.Output should not contain any extra space.

Sample Input

110/100

相关文档
最新文档