結果

問題 No.141 魔法少女コバ
ユーザー 37zigen
提出日時 2016-05-02 00:11:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 650 bytes
コンパイル時間 2,526 ms
コンパイル使用メモリ 74,736 KB
実行使用メモリ 41,624 KB
最終ジャッジ日時 2024-10-05 01:13:17
合計ジャッジ時間 16,608 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 93
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		long m=sc.nextLong();
		long n=sc.nextLong();
		
		long gcd=GCD(m,n);
		m/=gcd;
		n/=gcd;
		
		count=0;
		GCD(m,n);
		System.out.println(count-2);
	}
	int count=0;
	long LCM(long t1,long t2){
		long a=GCD(t1,t2);
		long tt1=t1/a;
		long tt2=t2/a;
		return tt1*tt2*a;
	}
	//t1>t2
	long GCD(long t1,long t2){
		if(t1<t2){
			long d=t2;
			t2=t1;
			t1=d;
			count++;
		}
		if(t2==0)return t1;
		else{
			count+=t1/t2;
			return GCD(t1%t2,t2);
		}
	}
}
0