結果

問題 No.442 和と積
ユーザー tj_0612tj_0612
提出日時 2016-11-18 03:57:13
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 574 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 24,300 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 06:30:48
合計ジャッジ時間 1,255 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 0 ms
4,380 KB
testcase_17 AC 0 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

unsigned long long int gcd(unsigned long long int a,unsigned long long int b){
	unsigned long long int temp,r;
	while(1){
		if(a>b){
			temp=a;
			a=b;
			b=temp;
		}
		else{
			r=b%a;
			if(r==0)
				break;
			b=r;
		}
	}
	return a;
}

int main(){
	unsigned long long int A,B;
	scanf("%llu %llu",&A,&B);

	unsigned long long int a,gcd_aA,gcd_aB,eq_gcd,calc,temp;
	a=A+B;

	gcd_aA=gcd(a,A);
	gcd_aB=gcd(a,B);
	eq_gcd=gcd(gcd_aA,gcd_aB);
	calc = a;
	if(a%eq_gcd==0){
		a/=eq_gcd;
		eq_gcd*=gcd(gcd(a,A),gcd(a,B));
	}
	printf("%llu\n",eq_gcd);
	return 0;
}
0