結果

問題 No.442 和と積
ユーザー tj_0612tj_0612
提出日時 2016-11-18 02:15:42
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-04 15:17:46
合計ジャッジ時間 2,487 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:23:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%llu %llu",&A,&B);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

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_ab,gcd_aa,calc;
	a=A+B;

	gcd_aa=gcd(a,A);
	gcd_ab=gcd(a,B);

	calc = gcd_ab*gcd_aa;

	unsigned long long int i,prime_mul=1;
	unsigned long long int prime[100000];
	int j,k,num=0;
	prime[0] = 0;
	while(1){
		if(gcd(a,calc)==calc)
			break;
		i=2;
		while(1){
			if(prime[0]!=0){
				while(1){
					if(gcd(i,prime_mul)==1)
						break;
					i++;
				}
			}else i++;
			if(calc % i == 0){
				calc /= i;
				prime[num] = i;
				prime_mul*=prime[num];
				break;
			}
			//printf("%llu ",i);

		}
		//printf("%llu\n",calc);
		num++;
	}

	//printf("%llu\n",calc);
	return 0;
}
0