Time Limit: 2 sec / Memory Limit: 256 MiB
Problem
This contest is named CODE FESTIVAL 2014.
Though, Alice has too bad memory that she always forgets to put "2014" in it.
Help her by making a program that concatenates “2014” after any given string.
You are given a string S. Output the string S followed by a string “2014”.
Input
The input will be given in the following format from the Standard Input.
S
- On the first line, you will be given the string S (1 ≦ |S| ≦ 20).
- Each character in the string S will be an uppercase English alphabet letter.
Output
Output the string S with 2014
concatenated afterwards in one line. Make sure to insert a line break at the end of the output.
Input Example 1
CODEFESTIVAL
Output Example 1
CODEFESTIVAL2014
When you put 2014
after CODEFESTIVAL
, it will be CODEFESTIVAL2014
. Note that the given input will not have any whitespace in it.
Input Example 2
CHOKUDAI
Output Example 2
CHOKUDAI2014
Time Limit: 2 sec / Memory Limit: 256 MiB
Problem
The string S is exactly the same as the string A repeated 10^{100} times.
Output the B-th letter of the string S.
Input
Input will be given in the following format from the Standard Input.
A B
- On the first line, you will be given a string A (1 ≦ |A| ≦ 50). Each character in the string A will be a lowercase English alphabet letter.
- On the second line, you will be given a integer B (1 ≦ B ≦ 1,000,000,000).
Achievements and Points
- When you pass every test case where 1 ≦ B ≦ 100,000 , you will be awarded 20 points.
- In addition, if you pass all the rest test cases you will be awarded 80 more points.
Output
Output the B-th letter of the string S in one line. Make sure to insert a line break at the end of the output.
Input Example 1
abc 7
Output Example 1
a
The beggining of string S is abcabcabcabc
...
Therefore, the 7th letter is a
.
Input Example 2
bbb 9
Output Example 2
b
Each letter in the string S is b
, so the 9th letter is also b
.
Input Example 3
kljhasdfkjahfadfakhsdfaklh 1000000000
OutPut Example 3
h
Note that a large number could be in the input.
Time Limit: 2 sec / Memory Limit: 256 MiB
Problem
Charlie was born January 1st of the year A, on the Earth. He will leave the Earth on December 31st of the year B.
He wants to know how many times he passes February 29th on the Earth.
February 29th is a leap day. A year that contains a leap day is called a leap year. You can determine if a year is leap year or not by following rules.
- If the year is divisible by 4, it is a leap year except the following case.
-
If the year is divisible by 100, it is
NOT
a leap year except the following case. - If the year is divisible by 400, it is a leap year.
Output how many times Charlie passes February 29th on the Earth. Note that Charlie lives very long.
Input
The input will be given in the following format from the Standard Input.
A B
- On the first line, you will be given the year A(1 ≦ A ≦ 2,000,000,000), when Charlie born, followed by a space and the year B (A ≦ B ≦ 2,000,000,000), when he leaves the Earth.
Achievements and Points
- When you pass every test case where 1 ≦ A ≦ B ≦ 3,000 , you will be awarded 25 points.
- In addition, if you pass all the rest test cases you will be awarded 25 more points.
Output
Output how many times Charlie passes February 29th on the Earth in one line. Make sure to insert a line break at the end of the output.
Inout Example 1
1988 2014
Output Example 1
7
Charlie can pass February 29th of 1988, 1992, 1996, 2000, 2004, 2008, 2012. The total is 7 times.
Input Example 2
997 1003
Output Example 2
0
Note that the year 1000 is NOT
a leap year.
Input Example 3
1 2000000000
Output Example 3
485000000
Note that Charlie lives very long.
Time Limit: 2 sec / Memory Limit: 256 MiB
Problem
Dave's calculator is broken. His calculator halts when put more than K kinds of number.
Dave wants to input an integer A, but if he put this number correctly the calculator might halt. Instead, he inputs the closest integer that won't halts the calculator.
Output the difference between Dave's input and the integer A.
Input
The input will be given in the following format from the Standard Input.
A K
- On the first line, you will be given the integer A (1 ≦ A ≦ 10^{15}), the integer Dave wants to input, followed by a space and K (1 ≦ K ≦ 10), the kinds of number his calculator can recognize.
Acheivements and Points
- When you pass every test case where 1 ≦ A ≦ 100,000, you will be awarded 30 points.
- In addition, if you pass all the rest test cases you will be awarded 70 more points.
Output
Output the minimum difference between Dave's input and the integer A in one line. Make sure to insert a line break at the end of the output.
Input Example 1
1234 2
Output Examle 1
12
In this case Dave can only use up to 2 kinds of numbers.
He will input the closest integer 1222, so the difference is 12.
Input Example 2
800000 1
Output Example 2
22223
Dave can use only 1 number, so 777777 is the closest integer.
Inout Example 3
7328495 10
Output Example 3
0
In this case Dave's calculator is not broken at all.
He can input the given integer A as is.
Input Example 4
262004 2
Output Example 4
218
The closest integer is 262222.