結果

問題 No.141 魔法少女コバ
ユーザー kou6839
提出日時 2015-02-23 16:27:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 74,052 KB
実行使用メモリ 54,784 KB
最終ジャッジ日時 2024-06-23 22:02:48
合計ジャッジ時間 16,673 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 93
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y=sc.nextInt();
		int ans=0;
		while(x!=y){
			if(x>y){
				if(y==1){
				int temp=x/y-1;
				x-=temp*y;
				ans+=temp;
				}else{
					int temp=x/y;
					x-=temp*y;
					ans+=temp;
				}
				if(x==0){ ans--;
				 break;
				}
			}else if(x<y){
				int temp=x;
				x=y;
				y=temp;
				ans++;
			}
		}
		System.out.println(ans);
	}
}
0