Competitive Programming Solutions

GitHub
back to dashboard

U. Float or int

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

input

234.000

output

int 234
Main.java
static void solve() {

        // Write your solution here
        String input = in.next();
        float x = Float.parseFloat(input);
        short y = (short) x;
        if (x == y){
            out.println("int " + y);
        } 
        else {
            out.printf("float %d %.3f",y, (x - y));
        }
    }