Professional Documents
Culture Documents
Input
The input begins with two positive integers n k (n, k<=10 7). The next n lines of input contain one
positive integer ti, not greater than 109, each.
Output
Write a single integer to output, denoting how many integers ti are divisible by k.
Example
Input:
7 3
1
51
966369
7
9
999996
11
Output:
4
Added by:
Date:
Time limit:
Source limit:
Memory limit:
Cluster:
Languages:
Resource:
Adrian Kosowski
2004-11-09
8s
50000B
256MB
Pyramid (Intel Pentium III 733 MHz)
All except: NODEJS PERL 6
Idea put forward by Michael Mendelsohn
1118. Snowman
Problem code: SNOWMAN
Finally the time of the year has come where children can build snowmans. The children have collected
some snow and ask you how big the snowman is going to be.
Assume that the snowman will consist of three spheres stacked on top of each other. The lower two
spheres are of equal size, the smaller sphere (used for the head) will have a radius of 25 percent of the
radius of the larger spheres.
Input
The first line of the input contains a number t 100, which indicates the number of test cases to
follow. Each test case consists of a line with one integer a 500000, the amount of snow in cm3.
Output
For each test case, print a line with the height of the snowman in cm. Round this number down to the
nextsmaller integer.
Example
Input:
2
100
500000
Output:
10
175
Added by:
Date:
Time limit:
Source limit:
Memory limit:
Cluster:
Languages:
Adrian Kuegel
2006-11-28
5s
5000B
256MB
Pyramid (Intel Pentium III 733 MHz)
Find the sum of the factors of a number including 1 and the given number.
Input
Number of test cases T followed by T lines of number n.
0 < T <= 5000
0 < n <= 999999999
Note: The number will not have a very large prime factor.
Output
The sum of the factors for each test case.
Example
Input:
2
6
5
Output:
12
6
Added by:
Date:
Time limit:
Source limit:
Memory limit:
Cluster:
Languages:
Resource:
Rahul
2007-03-10
1s
4000B
256MB
Pyramid (Intel Pentium III 733 MHz)
All except: ERL JS NODEJS PERL 6
Siddharth Agarwal
2524. Conversions
Problem code: GNY07B
Conversion between the metric and English measurement systems is relatively simple. Often, it
involves either multiplying or dividing by a constant. You must write a program that converts between
the following units:
Type
Weight
Volume
Metric
English equivalent
1.000 kilograms
0.4536 kilograms
1.0000 liter
3.7854 liters
2.2046 pounds
1.0000 pound
0.2642 gallons
1.0000 gallon
Input
The first line of input contains a single integer N, (1 N 1000) which is the number of datasets that
follow.
Each dataset consists of a single line of input containing a floating point (double precision) number, a
space and the unit specification for the measurement to be converted. The unit specification is one of
kg, lb, l, or g referring to kilograms, pounds, liters and gallons respectively.
Output
For each dataset, you should generate one line of output with the following values: The dataset
number as a decimal integer (start counting at one), a space, and the appropriately converted value
rounded to 4decimal places, a space and the unit specification for the converted value.
Example
Input:
5
1 kg
2 l
7 lb
3.5 g
0 l
Output:
1 2.2046 lb
2 0.5284 g
3 3.1752 kg
4 13.2489 l
5 0.0000 g
Added by:
Date:
Time limit:
Source limit:
Memory limit:
Cluster:
Languages:
Marco Gallotta
2008-03-11
60s
50000B
256MB
Pyramid (Intel Pentium III 733 MHz)
All except: ERL JS NODEJS PERL 6
Resource:
In mathematics, a prime number (or a prime) is a natural number which has exactly two distinct
natural number divisors: 1 and itself.
Super-prime numbers are the elements of the subsequence of prime-numbers that occupy primenumbered positions within the sequence of all prime numbers. That is, if p(i) denotes the ith prime
number, the numbers in this sequence are those of the form p(p(i)) or Primes with a prime index in the
sequence of prime numbers (the 2nd, 3rd, 5th, ... prime).
Your task is to generate all super primes &le 10^7.
Input:
There is NO input for this problem.
Output:
Print all super-primes &le 10^7 in ascending order,one per line.
Your task is to read two numbers a and b (0 < a, b <2100000000) and to output their sum.
Input
Input contains two lines, on the first line the number a and on the second line the number b.
Output
Output the sum of the two numbers.
Example
Input:
20
30
Output:
50
The letters b and d are mirror images of each other, as are p and q. No other pairs of letters are
mirrors, except for letters like H that are mirrors of themselves, and whats the interest in a pair thats
just two of the same letter? We refuse to count self-mirrors as mirrored pairs.
Input
Input is a list of lines with two characters on each line. Your program should end immediately when it
encounters a line with two spaces.
Output
The first line of output should contain only Ready. For each pair of characters (prior to a pair of
spaces), print the line Mirrored pair if the characters are mirrors, otherwise print the line Ordinary pair.
Example
Input:
Fr
qp
HH
db
pq
Output:
Ready
Ordinary
Mirrored
Ordinary
Mirrored
pair
pair
pair
pair
Added by:
Date: 2008-11-17
Time limit:
1s
Source limit: 50000B
Memory limit:256MB
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages:
Resource:
Input
The first line of input contains a single integer N (1 N 10 6), denoting the number of lines to follow.
Each of these lines contains two space-separated integers a and b (|a|, |b| 40,000).
Output
For each pair a and b, write a single line of output containing the value of a b.
Example
Input:
5
-1 -1
1 1
0 999
654 321
39999 -39999
Output:
1
1
0
209934
-1599920001
Added by:
Neal Wu
Date: 2008-11-30
Time limit: 20s
Source limit: 50000B
Memory limit:
256MB
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: All except: ERL JS
Added by:
Date: 2009-03-18
Time limit:
3s-10s
Source limit:
50000B
Memory limit: 256MB
Cluster:Pyramid (Intel Pentium III 733 MHz)
Languages:
Resource:
http://icpcres.ecs.baylor.edu/onlinejudge/
4171. DIOPHANTINE
Problem code: DIOEQ
Given a,b,c (where a,b not both zero) your task is to find if there exist any integers x,y that satisify the
equation a*x+b*y=c.
Input
The input consists of several test cases. Each test case contains a line with the three integers a,b,c
(a,b,c <= 10000000). The test case 0 0 0 indicates the end of input.
Output
For each test case you must output "YES" if there exists a solution,otherwise output "NO". (quotes only
for clarity)
Example
Input:
1 9 1
5 10 19
0 0 0
Output:
YES
NO
4190. A plus B
Problem code: APLUSB2
Input
Two integers up to 100000 digits in length
Output
Output their sum
Example
Input:
1
4
Output:
5
Added by:
Saravannan Shaan
Date: 2009-04-09
Time limit: 1s-60s
Source limit: 50000B
Memory limit:
256MB
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: All except: C99 strict ERL JAVA JS NODEJS PERL 6 PYTH 2.7 RUBY
Resource:
Classic
Input
On the first line of input, you are given an integer a such that a 1 and a 10^8 . On the second
line of input, you are given an integer b such that a b and b 10^8 .
Output
The output should be the number of cool numbers in the range a to b (inclusively: that is, a and b
would count as cool numbers in the range if they were actually cool).
Example
Input:
1
100
Output:
2
Input:
100
1000
Output:
1
Input
First line contains an integer T, representing the
follow each containing one integer n, 1 <= n <= 500.
number
of
Output
For each test case output on a line the nth good number in the sequence.
Example
Input:
3
10
5
20
Output:
19
8
38
Added by:
balaji
Date: 2009-09-28
Time limit:
4s
256MB
kruzade 09 main
test-cases.
Then
lines
Input
The first line will contain a single integer N (0 < N <= 10000). Each of the next N lines will contain two
integers A and B (0 < A, B <= 100).
Output
For each test case, output a single line. If a valid C exists, output a line containing the word YES and
the value of C, separated by a space. Otherwise, output the single word NO.
Example
Input:
4
2 2
4 3
4 5
5 12
Output:
NO
YES 5
NO
YES 13
Given positive integers B and N, find an integer A such that A^N is as close as possible to B. (The
result A is an approximation to the Nth root of B.) Note that A^N may be less than, equal to,
or greater than B.
Input
The input consists of one or more pairs of values for B and N. Each pair appears on a single line,
delimited by a single space. A line specifying the value zero for both B and N marks the end of the
input. The value of B will be in the range 1 to 1,000,000 (inclusive), and the value of N will be in the
range 1 to 9 (inclusive).
Output
For each pair B and N in the input, output A as defined above on a line by itself.
Example
Input:
4 3
5 3
27 3
750 5
1000 5
2000 5
3000 5
1000000 5
0 0
Output:
1
2
3
4
4
4
5
16
Added by:
Tamer
Date: 2009-11-16
Time limit: 1s
Source limit: 50000B
Memory limit:
256MB
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: All except: NODEJS PERL 6
Resource:
ACM Mid-Central Regional Programming Contest 2006
5848. Filip
Problem code: FILIP
Mirko has a younger brother, Filip, who just started going to school and is having trouble with
numbers. To help him get the hang for number scale, his teacher writes two three digit numbers. She
asks Filip to compare those numbers, but instead of interpreting them with the leftmost most
significant digit, he needs to interpret them the other way around, with the most significant digit being
the rightmost one. He than has to tell the teacher the larger of the two numbers.
Write a program that will check Filips answers.
Input
The first and only line of input contains two three digit numbers, A and B. A and B will not be equal
and will not contain any zeroes.
Output
First and only line of output should contain the larger of the numbers in the input, compared as
described in the task. The number should be written reversed, to display to Filip how he should
read it.
Example
Input:
734 893
Output:
437
Input:
221 231
Output:
132
Input:
839 237
Output:
938
5873. Rnumber
Problem code: RNUM
In this problem your task is to reduce a given number 'N' to a non-positive number in as little moves
as possible. The moves allowed are : Given an integer 'N' you can subtract one of its factors (excluding
'N' itself) from 'N' and continue the same process with the resulting number until you reach a nonpositive number
Input
First line contains the number of test cases 'T'. 'T' lines follow containing a single integer 'N'
2<=N<100,000.
Output
A single integer denoting the minimum number of moves necessary.
Example
Input:
1
10
Output:
5
7207. Alchemy
Problem code: ALCHE
Alchemy is a discipline that is believed to span at least 2500 years of human history.
It is most known for its intention of transforming matter, typically trying to come up
with a recipe to make gold based on much less valued metals, aided by some non-metal
components.
Most scientists and scholars think that alchemy has failed. They surely do not know that
a particular alchemist named Albert Ainstain, managed to create gold from a simple
combination of ordinary iron (much more common and cheap than gold) and some goodold-fashioned water. However, the combination must have the exact proportion of grams
of iron and centiliters of water to work, otherwise the alchemist would end up with useless
rusty iron.
Many alchemists and bussinessman had tried to recreate Albert Ainstains findings to
achieve recognition, fame, prestige or economical welfare, but none of them have suceeded.
Since you know very little about chemistry, alchemy and ancient practices, you believe
that your chances for success in this task are bounded to using a computer in your benefit.
Therefore, you decide to create a program that automatically tests a given combination
of iron and water, and informs whether that combination has the correct proportion
to produce gold. Of course, once you find the right proportion, you can double both
amounts and get double the gold, cut both in half and get half the gold, or multiply both
by any other real number to obtain the amount of gold you want. Your task is then,
given the number of grams of iron and the number of centiliters of water, say whether
the proportion between both components is the right one.
Input
The input contains several test cases, each one described in a single line. The line
contains two integers I and W separated by a single space, representing grams of iron
and centiliters of water, respectively (1 I, W 106 ). The last line of the input contains
the number 1 twice separated by a single space and should not be processed as a test
case.
Output
For each test case output a single line containing an uppercase Y if the combination
produces gold, or an uppercase N otherwise.
Example
Input:
1000 37
999 37
10000 370
10001 370
-1 -1
Output:
Y
N
Y
N
Resource:
Input
The input file consists of series of numbers one in each line.The input is terminated by EOF.
Output
The next odd number.
Example
Input:
5
2
6
17
Output:
7
3
7
19
PS:Take care about your fingers, do not use more than 100 bytes of code.
Input
First number in the input is t, number of test cases.
After that t lines will follow each with a time in hh:mm format, where hh will mean the hour and mm
will mean the minute. hh will be an integer within 0 to 23, and mm will be an integer within 0 to 59.
Output
Print "Yes" (without quotes) if it's a prime time, "No" (without quotes) if it's not.
Example
Input:
3
07:11
04:17
07:09
Output:
Yes
No
No
Added by:
Iqram Mahmud
Date: 2011-07-03
Time limit:
1s
Source limit: 50000B
Memory limit:256MB
Cluster:
Pyramid (Intel Pentium III 733 MHz)
Languages: All
Resource:
Own