結果

問題 No.1010 折って重ねて
ユーザー bluemegane
提出日時 2020-03-21 08:52:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 1,214 ms
コンパイル使用メモリ 109,220 KB
実行使用メモリ 28,284 KB
最終ジャッジ日時 2024-12-17 20:57:30
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)
        {
            while (a > h)
            {
                if (a % 2 == 0) { a /= 2; h *= 2; }
                else { b *= 2; h *= 4; }
                count++;
            }
            while (b > 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