NUS Home9
Home | Up


“Around here, however, we do not look backwards for very long. We keep moving forward, opening up new doors and doing new things… and curiosity keeps leading us down new paths.” - Walt Disney and the theme of the movie: "Meet the Robinsons".

Last updated on: 10 November 2008 03:54:32 PM

Comment on this volume: N/A.

No

Problem Name

*

Algorithm

10900-10999

10921

Find the Telephone

*

Haven't try yet

10922

2 the 9s

*

Haven't try yet

10924

Prime Words

*

Haven't try yet

10925

Krakovia

*

Haven't try yet

10926

How Many Dependencies?

*

Haven't try yet

10929

You can say 11

*

Haven't try yet

10931

Parity

*

Haven't try yet

10935

Throwing cards away I

*

Haven't try yet

10940

Throwing cards away II

*

Haven't try yet

10945

Mother Bear

*

Haven't try yet

10948

The primary problem

*

Haven't try yet

10959

The Party, Part I

*

Haven't try yet

10970

Big Chocolate

*

Haven't try yet

Total submit-able problems in this volume: 100
Solved problems: 15
Problems in Wrong Answer list from this volume: 0
Unattempted problems: 85
Total hints in this volume: 13


10921 - Find the Telephone (by: Niaz Morshed Chowdhury)

Very easy problem. Assign the given Numerical value in an array of size 26 according to the given table. These 26 value will actually indicate letters from A to Z.

Now,

Let ‘S’ is the input string.
Loop i = 0 to length –1  of S.
  if (S[i]== any letter)
    output the corresponding value from the table.
  else
    output the original value from S (See the note)

Note : The problem statement tells that other than A-Z there will be only three characters in the input, those are 1,0 and ‘-‘. In my solution I checked them specially and if there is any blank space because of this check still this method will work.

10922 - 2 the 9s (by: Niaz Morshed Chowdhury)

This is actually not a Big Number problem. This problem can be solved very easily by using the divisibility testing by 9. This question has two parts. 1. Divisibility, 2. If so then Degree.

For Divisibility

Let a is number. Then, a is divisible by 9 if and only if the sum of the digits a(n) + a(n-1) + ... + a(1) + a(0) is divisible by 9.

For Degree

Degree means, how many times it is needed to add the digits together to convert the given number from the original form to an one digit number. Interestingly, you can see that if a number is divisible by 9 then after converting it to a one digit number it will be 9.

So, to solve this problem, convert the given number in an one digit number and track the degree while doing this process and finally if the number is 9 just output the statement according to the problem with number and the degree else tell this is not a multiple of 9.

Example

999
9+9+9 = 27 -> 2 + 7 = 9

So, its a multiple of 9 and having 9-degree of 2 as we needed to add it twice.

10924 - Prime Words (by: Niaz Morshed Chowdhury)

Probably the easiest prime related problem of this judge. According to this problem, a=1, b=2 ... z=26, A=27, B=28 ... Z=52. Given a string consist of these letters. Convert them to their corresponding numerical values and then add them all. If the sum is a prime number then it will be a prime word otherwise not. Note that the maximum sum can be 1020 (52 x 20). So, just generate the primes up to this limit and get it accepted.

10925 - Krakovia (by: Niaz Morshed Chowdhury)

A Big Number problem. Add the given number and then find the average. In case of finding the average, just ignore the remainder part.

Example

540
540
454

Sum = 1534 and Average is 511.33 or 1533 and 1 will remain as remainder. So, output only 1533. 

10926 - How Many Dependencies? (by: Niaz Morshed Chowdhury)

You can solve this problem very easily by using modified DFS.
1. At first take the input and convert it to a graph.
2. Call DFS_visit function with each node of the graph individually.
3. Track how many nodes it visits while traversing through the Recursion.
4. Output the node number that visited most nodes.

Note

1. Initialize your color flag before calling each DFS_visit.
2. Start calling DVS_visit from 1. It will automatically handle the case if there is any tie.     

10929 - You can say 11 (by: Niaz Morshed Chowdhury)

Another problem that can be solved by using divisibility testing.

Let a is the number. Then, a is divisible by 11 if and only if the alternating sum of the digits is divisible by 11.

More clearly, add all the even position digits and odd position digits separately. Then subtract even sum from the odd sum. If the subtracted value is divisible by 11 then the number will be divisible by 11.

Example

2937

If we look from the left side (as C array looks), then we will get 2 at zero, 9 at 1, 3 at 2 and 7 at 3 rd position. So, odd sum = 9 + 7 = 16 and even sum = 5. So the subtracted value will be 16-5 = 11 which is divisible by 11.   

10931 - Parity (by: Niaz Morshed Chowdhury)

One of the easiest problem of this judge.

Task to do:
1. Divide each number by 2 until it will become zero.
2. At each step check whether the remainder is zero or one and also print the value.
3. If one then increase your count (initialized by zero) and finally it will hold the parity.

Note : Be careful about the least/most significant bit while printing.

10935 - Throwing cards away I (by: Niaz Morshed Chowdhury)

This is basically a simulation problem. According to the problem statement - “Throw away the top card and move the card that is now on the top of the deck to the bottom of the deck.”. Just simulate this process.

You can also find the result by some tricky calculation as the time limit of this problem is quite fine to do the simulation. We can keep the energy to find that tricky calculation for the problem 10940 which is actually an extended version of this one.

10940 - Throwing cards away II (by: Niaz Morshed Chowdhury)

This problem is actually an extended version of the problem 10935. Here we have been asked to find the last card after doing the simulation that we did in problem 10935. This time the input size to too big and we can not just do a simulation. We need to find some tricky way to get the last card at the end of the process without doing any simulation. Here is my algorithm.

Algorithm

Take the input n.
Let x is an integer initialized by 1.
Loop until x>=n
  x = x*2
s = x%n
Result = n – s
Output = Result.

How does it work ?
1. By multiplying x with 2, we are actually tracking the cards after throwing and moving at the bottom.
2. By s = x%n and Result = n – s,  we are getting the card position and card number.

NB : During the contest time, all on a sudden I discovered this algorithm and I don’t have any proof for it. But it works pretty nicely.

10945 - Mother Bear (by: Niaz Morshed Chowdhury)

Simple problem. You need to find whether the given string is a palindrome or not. But you must consider some extra thing while need to ignore some other things.

To Consider : You need to consider the string as a case non-sensitive one.
To Ignore :  '.', ',', '!', '?' and blank spaces.

Example

Madam, Im adam!
After removing the ignoring items we get,
MadamImadam
As they are all case non-sensitive, it looks,
madamimadam
which is a palindrome.

10948 - The primary problem (by: Niaz Morshed Chowdhury)

An easy prime related problem. Here goes my algorithm.
1. Generate prime up to 1,000,000 using sieve.
2. Let n is the input.
3. Now start I from 2 to up to n/2 + 1.
4. If  I is a prime and n – I is also a prime then break.
5. Else No Way !

Note : “If there are more than one set of sums for which this is true, choose the set of sum the maximizes the difference between them.” As we start from a smaller side, in each step we get the numbers with maximum difference. As a result this statement will automatically be maintained by the algorithm. 

10959 - The Party, Part I (by: Niaz Morshed Chowdhury)

A simple BFS problem. Here is the process:
1. Take the input.
2. Form the input as a bi-directional graph, which means if a is connected with b and b will also be connected with a.
3. 0 is Don Giovanni’s number. Call BFS with 0.
4. In the distance matrix, you will get all the distance from 0. Print this matrix.

10970 - Big Chocolate (by: Niaz Morshed Chowdhury)

Smallest problem I have ever solved. If you look at the chocolate matrix then you can easily find the formula. Still giving here, Simple formula, result = m*n – 1. My accepted solution took just 2 core lines of code !

My Code:

#include<stdio.h>
int main() {
  int m,n;
  while (scanf("%d%d",&m,&n) == 2)
    printf("%d\n",m*n-1);
  return 0;
}


This document, volC9.html, has been accessed 4271 times since 04-May-07 19:50:43 SGT. This is the 8th time it has been accessed today.

A total of 2355 different hosts have accessed this document in the last 579 days; your host, 38.103.63.56, has accessed it 1 times.

If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.