[URI ONLINE JUDGE] – 1943 – Top N

The regional phase of the SBC Programming Contest happened recently, where more than 600 teams participated in more than 40 cities around Brazil. Your friend competed, and when asked about his position he told you: “I got placed in the top 10”.

You were happy for your friend, but you could not stop asking yourself about what was his real position. “Top 10” could mean any position between first and tenth placed, however if he had placed first he would have said “Top 1”, if he had placed second or third he would have said “Top 3”, and if he had placed fourth or fifth he would have said “Top 5”. Therefore, his real position was between sixth and tenth, because people tend to put themselves in the lowest category they belong.

You gathered all the categories people most use: 1, 3, 5, 10, 25, 50 and 100. Given a position K, write an algorithm that says the number of the lowest category this position belongs.

Input

Each test case has one integer K, representing a position (1 ≤ K ≤ 100).

Output

For each test case you should print one line with the sentence “Top N”, and replace N by the number of the lowest category the position K belongs.

Input Samples Output Samples
7 Top 10
25 Top 25
26 Top 50

 

very simple like this:

 

#include <stdio.h>
int main(int argc, char const *argv[]){
    int k;
    scanf("%d", &k);
    if(k == 1) printf("Top 1\n");
    else if(k > 1 && k <= 3) printf("Top 3\n");
    else if(k > 3 && k <= 5) printf("Top 5\n");
    else if(k > 5 && k <= 10) printf("Top 10\n");
    else if(k > 10 && k <= 25) printf("Top 25\n");
    else if(k > 25 && k <= 50) printf("Top 50\n");
    else printf("Top 100\n");
    return 0;
}

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s