| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11191 | I2P(I)2016_Yang_hw4-1 |
|
| 11192 | find palindrome |
|
| 11200 | Tower of Hanoi |
|
| 11201 | I2P(I)2016_Yang_hw4-4 |
|
Description
Calculate the addition of big numbers.
The ASCII code of digits
|
character |
ASCII code (in decimal) |
|
character |
ASCII code (in decimal) |
|
0 |
048 |
5 |
053 |
|
|
1 |
049 |
6 |
054 |
|
|
2 |
050 |
7 |
055 |
|
|
3 |
051 |
8 |
056 |
|
|
4 |
052 |
9 |
057 |
Input
The form of input is {A + B}.
There is a blank space between A and '+' as well as between '+' and B.
A new line character at the end of input.
0<=A, B<=10100
Output
The result of calculation.
No new line character at the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Palindrome is a string that is identical to its reverse, like "level" or "aba". Given a string, find the longest palindrome in the string.
Input
Output
In each test case, output the longest palindrome in the string. If there are many palindromes of the same length, output the first one in the string.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The Tower of Hanoi is a mathematical game puzzle. It consists of three rods, which are A, B and C. The puzzle starts with n disks in ascending order of size on rod A, the smallest at the top.
The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:
1. Only one disk can be moved at a time.
2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.
3. No disk may be placed on top of a smaller disk.
Write a program to simulate the moves of the disks. Print the number of disk which is moved in each step.
For example, if n = 3, the moves of each steps are:
move disk 1 from rod A to rod C
move disk 2 from rod A to rod B
move disk 1 from rod C to rod B
move disk 3 from rod A to rod C
move disk 1 from rod B to rod A
move disk 2 from rod B to rod C
move disk 1 from rod A to rod C
You should print out:
1
2
1
3
1
2
1
HINT : You can modify this sample code and implement the function 'hanoi'
#include <stdio.h>
void hanoi(int n, char A, char B, char C);
int main(){
int n;
scanf("%d", &n);
hanoi(n, 'A', 'B', 'C');
return 0;
}
Input
An integer n (0<n<20), which means the number of disk.
Output
Print out the number of disk which is moved in each step, and there is a '\n' at the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given two positive integers x and y, compute their greatest common divisor (GCD) and least common multiple (LCM). The GCD of two numbers is the largest positive integer that can divide the numbers without a reminder. The LCM of two numbers is the smallest positive integer that can be divided by the two numbers without a reminder.
For example, if x=15 and y=50, you should print:
5 150
since the GCD of 15 and 50 is 5, and the LCM of 15 and 50 is 150.
HINT : You can modify this sample code and implement the function 'gcd' and 'lcm'
#include <stdio.h>
int gcd(int a,int b);
int lcm(int a,int b);
int main(void)
{
int x,y;
scanf("%d %d",&x,&y);
printf("%d %d",gcd(x,y),lcm(x,y));
return 0;
}
Input
Two positive integer x and y, where 0<x,y<5000.
Output
GCD and LCM of x and y, which are separated by a space.
Note that you DO NOT need to print ‘\n’ at the end of the output.