ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1493. One Step from Happiness

Why Test_1 Failed?
Posted by Alireza_Keshmiri 18 Feb 2009 22:19
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        int[] ints = ReadInts(in);

        int first = ints[0] + ints[1] + ints[2];
        int second = ints[3] + ints[4] + ((ints[5] == 9) ? 1 : ints[5] + 1);
        int third = ints[3] + ints[4] + ((ints[5] == 0) ? 8 : ints[5] - 1);

        System.out.println((first == second) || (first == third) ? "YES" : "NO");
    }

    public static int[] ReadInts(BufferedReader in) throws IOException {
        int[] result = new int[6];

        String input = in.readLine();

        for (int i = 0; i < input.length(); i++) {
            result[i]=Integer.parseInt(input.substring(i, i + 1));
        }

        return result;
    }
}
Re: Why Test_1 Failed?
Posted by Vladimir Yakovlev (USU) 18 Feb 2009 23:00
Maybe Yes/No instread of YES/NO?
Re: Why Test_1 Failed?
Posted by Alireza_Keshmiri 19 Feb 2009 10:24
yap :)
thanks

Edited by author 19.02.2009 10:24

Edited by author 19.02.2009 10:24