結果
問題 | No.141 魔法少女コバ |
ユーザー |
![]() |
提出日時 | 2015-11-23 20:50:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,825 ms / 5,000 ms |
コード長 | 852 bytes |
コンパイル時間 | 846 ms |
コンパイル使用メモリ | 107,576 KB |
実行使用メモリ | 26,008 KB |
最終ジャッジ日時 | 2024-09-13 17:19:15 |
合計ジャッジ時間 | 14,464 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 93 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;class Program{static void Main(){var tmp = Console.ReadLine().Split();int m = int.Parse(tmp[0]);int n = int.Parse(tmp[1]);int d = Gcd(m, n);m /= d;n /= d;int cnt = 0;while (true){if (m == 1 && n == 1) break;if (n > m){int l = m;m = n;n = l;cnt++;}else{m -= n;cnt++;}}Console.WriteLine(cnt);}static int Gcd(int a, int b){if (a < b) return Gcd(b, a);int d = 0;do{d = a % b;a = b;b = d;} while (d != 0);return a;}}