What is ACM ICPC?
Its an international programming contest. Association for Computing Machinery International Collegiate Programming Contest.
Problem A: Numerology
Input (STDIN):
Output (STDOUT):
Constraints:
1 <= A <= B <= 10^18
Time limit: 4 seconds
Sample Input:
100 120
1000 1000
123 456
Sample Output:
0
331
Problem B: Count Dracula
But not all vampires are evil, and the one in the picture has promised to help Harry Potter fight Voldemort, the evil Dark Lord. But instead of learning the magic spells Harry has listed for him, our Count gets distracted and starts to count the letters in the spells.
Can you help the Count count the letters in the spells quickly so that he can move on to actually learning and memorizing the spells?
Constraints
Time limit: 1 second
Input (STDIN):
Output (STDOUT):
Sample Input:
Sample Output:
e 1
h 1
l 3
o 2
r 1
w 1
Problem C: The Way to the Sorcerer's Stone
Note that Harry could be faced with a corridor having no bends (N=1) -- just one single straight section with a flask or a dragon at the start.
Harry has used magic before entering the corridor to determine which bends contain what, but lacks the basic simple mathematical skill to determine what minimum strength he needs to emerge from the corridor alive. Can you help him again with your compooter-thingy?
Input (STDIN):
Output (STDOUT):
Constraints:
1 <= N <= 100
-100 <= S[i] <= 100
Time limit: 2 seconds
Sample Input:
3
0 0 -1
3
-2 -3 -4
4
2 -2 3 -3
Sample Output:
10
1
Problem D: Sub-sequences
You are given a sequence of N numbers A[1..N]. Consider a sub-sequence** such that the bitwise AND of all the numbers of the sub-sequence is equal to the bitwise OR of all the numbers of the sub-sequence. Amongst all such sub-sequences, find the sub-sequence that has the maximum sum of the numbers, and print this maximum sum.
Can you help Harry finish his homework before he chews through all his writing quills in frustration?
*Muggle-born: Magical children born of non-magical parents.
Input (STDIN):
Output (STDOUT):
Constraints:
1 <= N <= 10000
0 <= A[i] <= 10000
Time limit: 3 seconds
Sample Input:
3
1 2 3
2
1 1
Sample Output:
2
Problem E: Append to Divide
Harry Potter to the rescue! Harry suggested using magic to make sure that every bucket contained a number of sweets that were exactly divisible by the number of students in the corresponding House.
Can you tell us how many sweets were in the last bucket, given the way Harry's spell worked:
Given the number of students A[i] in each of the N houses, we define the array B[0..N] as follows. Initialize B[0] = 1 and for i = 1 to N, set B[i] to the smallest integer obtained by appending one or more digits (0-9) to B[i-1] such that B[i] is divisible by A[i]. Find the value of B[N] modulo 1000000007.
Input (STDIN):
Output (STDOUT):
Constraints:
1 <= N <= 1000
1 <= A[i] <= 1,000,000
Time limit : 3 secs
Sample Input:
3
2 3 4
4
1234 56789 12345 6789
Sample Output:
681070756
