結果

問題 No.1010 折って重ねて
ユーザー bluemegane
提出日時 2020-03-21 09:06:57
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 2,889 ms
コンパイル使用メモリ 109,920 KB
実行使用メモリ 33,204 KB
最終ジャッジ日時 2024-12-17 21:57:33
合計ジャッジ時間 6,350 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]) * 1000L;
        var b = long.Parse(line[1]) * 1000L;
        var h = long.Parse(line[2]);
        var g1 = gcd(a, b);
        var g2 = gcd(h, g1);
        a /= g2;
        b /= g2;
        h /= g2;
        var count = 0;
        while (a > h | b > h)
        {
            if ((a < b && a > h) | (b <= a && b < h))
            {
                if (a % 2 == 0) { a /= 2; h *= 2; }
                else { b *= 2; h *= 4; }
                count++;
            }
            else if ((b <= a && b > h) | (a <= b && a < h))
            {
                if (b % 2 == 0) { b /= 2; h *= 2; }
                else { a *= 2; h *= 4; }
                count++;
            }
        }
        Console.WriteLine(count);
    }
    public static long gcd(long a, long b)
    {
        if (a < b) return gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}

0