Showing posts with label TJU. Show all posts
Showing posts with label TJU. Show all posts

Sunday, November 13, 2011

TJU 2346 Gauß in Elementary School Solution

Problem Statement :
Difficulty : Easy.
Problem Type : Mathematics,Gauss Sum.

Johann Carl Friedrich Gauß(1777-1855) was one of the most important German mathematicians . For those of you who remember the Deutsche Mark, a picture of him was printed on the 10,-DM bill. In elementary school, his teacher J. G. Buttner tried to occupy the pupils by making them add up the integers from 1 to 100. The young Gauß surprised everybody by producing the correct answers (5050) within seconds. Can you write a computer program that can compute such sums really quickly?

Thursday, November 3, 2011

TJU 3108 Common item Solution

Problem Description :
    The problem is about to find Intersection of two sets of number. We have to  just find out number of common elements of two sets.

    Idea 1:(Naive)
        Just for every elements of set A we can find out is there any element of set B is equal to that number or not. Finally,as the problem set ,we will print the common elements in increasing order. It will take O(N*M)times where  N is the number of elements of set A and M is the number of elements of set B. And finally sorting cost.

Tuesday, October 11, 2011

TJU 1156 Niven Numbers Solution




Problem Link

Solution :
    As there is no information about input number, the number can have 100 digits. So, I used string to take input. Then finding digit some will be done simply for all bases 2 <= b <= 10. After that finding modulus of a big number is the issue.
   I have used the idea that,