UVA – 10696 – f91

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws 
                            NumberFormatException, 
                            IOException {
        BufferedReader in = new BufferedReader(new 
                            InputStreamReader(System.in));
        String s = "";
        while (!(s = in.readLine()).equals("0")) {
            int N = Integer.parseInt(s);
            System.out.printf("f91(%d) = %d\n", N, (N > 100 
                              ? N - 10 : 91));
        }
    }
}
Advertisements

2 thoughts on “UVA – 10696 – f91

  1. Alhussain says:

    Dear Adel,
    I tried this solution on my PC, but it takes more then 30 seconds for 250,000 test cases.
    I think it will give a TLE error on Uva online judge.

    I tried to find a better solution, but I did not find it until now.
    What is your opinion?

    Best regards

  2. werey says:

    we will have to use stringbuffer

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

%d bloggers like this: