Trang

Chủ Nhật, 2 tháng 1, 2011

3445. Soda Surple

import java.io.*;

public class Main {

    /**
     * http://acm.tju.edu.cn/toj/showp3445.html
     * @author hunglee
     */
    public static void main(String[] args) throws IOException {
        
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(
                new InputStreamReader(System.in)));
        
        int e, f, c;
        in.nextToken();
        e = (int) in.nval;
        in.nextToken();
        f = (int) in.nval;
        in.nextToken();
        c = (int) in.nval;
        
        int res = 0;
        e += f;
        do {
            f = e / c;
            res += f;
            e %= c;
            e += f;
        } while (e >= c);
        System.out.println(res);
    }

}

Không có nhận xét nào:

Đăng nhận xét