結果

問題 No.280 歯車の問題(1)
ユーザー 37zigen37zigen
提出日時 2016-05-18 20:36:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 182 ms / 1,000 ms
コード長 717 bytes
コンパイル時間 2,405 ms
コンパイル使用メモリ 76,848 KB
実行使用メモリ 55,384 KB
最終ジャッジ日時 2024-04-15 22:57:29
合計ジャッジ時間 10,761 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
54,976 KB
testcase_01 AC 172 ms
54,664 KB
testcase_02 AC 179 ms
54,648 KB
testcase_03 AC 175 ms
54,612 KB
testcase_04 AC 175 ms
55,112 KB
testcase_05 AC 176 ms
55,052 KB
testcase_06 AC 165 ms
54,896 KB
testcase_07 AC 175 ms
55,156 KB
testcase_08 AC 176 ms
54,748 KB
testcase_09 AC 177 ms
54,636 KB
testcase_10 AC 175 ms
54,924 KB
testcase_11 AC 170 ms
54,772 KB
testcase_12 AC 178 ms
55,012 KB
testcase_13 AC 169 ms
55,092 KB
testcase_14 AC 173 ms
55,148 KB
testcase_15 AC 173 ms
55,088 KB
testcase_16 AC 178 ms
54,932 KB
testcase_17 AC 176 ms
54,836 KB
testcase_18 AC 174 ms
55,076 KB
testcase_19 AC 182 ms
54,848 KB
testcase_20 AC 178 ms
54,964 KB
testcase_21 AC 177 ms
55,108 KB
testcase_22 AC 177 ms
54,916 KB
testcase_23 AC 180 ms
54,848 KB
testcase_24 AC 173 ms
54,836 KB
testcase_25 AC 177 ms
55,112 KB
testcase_26 AC 177 ms
55,068 KB
testcase_27 AC 165 ms
54,732 KB
testcase_28 AC 173 ms
54,744 KB
testcase_29 AC 179 ms
55,384 KB
testcase_30 AC 171 ms
54,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] z=new long[n];
		for(int i=0;i<n;i++)z[i]=sc.nextLong();
		long gcd=gcd(z[0],z[n-1]);
		System.out.println(z[n-1]/gcd+"/"+z[0]/gcd);
		/*
		 *θ1 = z2/z1 * θ2
		 * 	 = z2/z1 * z3/2 * θ3
		 *   = z3/z1 * θ3
		 *...
		 *=zn/z1 * θn
		 *
		 *gr=θ1/θn=zn/z1
		 */
	}
	long lcm(long t1,long t2){
		long a=gcd(t1,t2);
		long tt1=t1/a;
		long tt2=t2/a;
		return tt1*tt2*a;
	}
	long gcd(long t1,long t2){
		if(t1<t2){
			long d=t2;
			t2=t1;
			t1=d;
		}
		if(t2==0)return t1;
		return gcd(t2,t1%t2);
	}
}
0