結果

問題 No.1010 折って重ねて
ユーザー ntk3264
提出日時 2020-04-03 02:59:27
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 42,124 KB
最終ジャッジ日時 2024-06-28 17:38:39
合計ジャッジ時間 8,572 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        double x = sc.nextDouble()*1000;
        double y = sc.nextDouble()*1000;
        double h = sc.nextDouble();

        int ans = 0;

        label:
        while (x>h || y>h) {
            if (y<x) {
                double tmp = y;
                y = x;
                x = tmp;
            }
            if (x>h) {
                x /= (double)2;
                h *= 2;
                ans++;
                continue label;
            }
            y /= (double)2;
            h *= 2;
            ans++;
        }

        out.print(ans);
        out.flush();

    }

}
0