Competitive Programming Solutions

GitHub
back to dashboard

W. Mathematical Expression

Codeforces - Sheet #1 (Data type - Conditions) · limit: 0.25s · memory: 256MB · view on codeforces

input

5 + 10 = 15

output

Yes
Main.java
static void solve() {

        // Write your solution here
        int a = in.nextInt();
        char eval = in.next().charAt(0);
        int b = in.nextInt();
        in.next();
        int c = in.nextInt();
        int result = 0;
        switch(eval){
            case '+':
                result = a + b;
                break;
            case '-':
                result = a-b;
                break;
            case '*':
                result = a*b;
                break;
            case '/':
                result = a/b;
                break;
        }
        
        out.println((result != c) ? result : "Yes");

    }