結果

問題 No.356 円周上を回る3つの動点の一致
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-04-01 23:58:14
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 639 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 58,780 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-24 19:13:44
合計ジャッジ時間 27,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,595 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1,726 ms
4,376 KB
testcase_05 AC 1,932 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 371 ms
4,380 KB
testcase_08 AC 977 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 987 ms
4,380 KB
testcase_13 AC 1,972 ms
4,380 KB
testcase_14 AC 986 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1,962 ms
4,380 KB
testcase_17 AC 125 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 877 ms
4,504 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 23 ms
4,376 KB
testcase_22 AC 512 ms
4,376 KB
testcase_23 AC 722 ms
4,380 KB
testcase_24 AC 72 ms
4,380 KB
testcase_25 AC 229 ms
4,376 KB
testcase_26 AC 193 ms
4,376 KB
testcase_27 AC 1,264 ms
4,376 KB
testcase_28 AC 1,277 ms
4,376 KB
testcase_29 AC 1,350 ms
4,380 KB
testcase_30 AC 168 ms
4,380 KB
testcase_31 AC 25 ms
4,380 KB
testcase_32 AC 26 ms
4,376 KB
testcase_33 AC 320 ms
4,380 KB
testcase_34 AC 888 ms
4,376 KB
testcase_35 AC 57 ms
4,376 KB
testcase_36 AC 383 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 26 ms
4,380 KB
testcase_39 AC 47 ms
4,380 KB
testcase_40 AC 3 ms
4,376 KB
testcase_41 AC 39 ms
4,380 KB
testcase_42 AC 8 ms
4,376 KB
testcase_43 AC 398 ms
4,380 KB
testcase_44 AC 70 ms
4,376 KB
testcase_45 AC 222 ms
4,380 KB
testcase_46 AC 130 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 7 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:17: warning: ‘ans2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  long long ans1,ans2;
                 ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>

using namespace std;

long long gcd(long long a,long long b){
	if(a<b) return gcd(b,a);
	if(b!=0) return gcd(b,a%b);
	return a;
}

int main(){

	long long T1,T2,T3;
	long long ans1,ans2;

	cin>>T1>>T2>>T3;

	long long N=gcd(T1,T2);
	long long A=T1*T2/N;
	N=gcd(A,T3);
	A=A*T3/N;

	ans1=A;

	long long K1=A/T1;
	long long K2=A/T2;
	long long K3=A/T3;

	for(long long i=max(max(K1,K2),K3);i>=1;i--){
		if(K1%i==K2%i&&K2%i==K3%i){
			ans2=i;
			break;
		}
	}

	for(long long i=2;i<min(ans1,ans2);i++){
		if(ans1%i==0&&ans2%i==0){
			ans1/=i;
			ans2/=i;
			i--;
		}
	}
	cout<<ans1<<"/"<<ans2<<endl;
}

0