結果

問題 No.442 和と積
ユーザー olpheolphe
提出日時 2016-11-11 22:46:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 524 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 57,932 KB
実行使用メモリ 12,056 KB
最終ジャッジ日時 2023-08-24 18:09:27
合計ジャッジ時間 4,923 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "math.h"
using namespace std;

long long int a, b,c;
long long int ans=1;
int num[2] = {};

int min(int x, int y) {
	if (x > y)return y;
	return x;
}

int main() {
	cin >> a >> b;
	c = a + b;
	int z = 2;
	while ((a!=1||b!=1)&&c!=1) {
		num[0] = 0;
		num[1] = 0;
		while (a % z == 0) {
			a /= z;
			num[0]++;
		}
		while (b % z == 0) {
			b /= z;
			num[0]++;
		}
		while (c % z == 0) {
			c /= z;
			num[1]++;
		}
		ans *= pow(z, min(num[0], num[1]));
		z++;
	}
	cout << ans<<"\n";
	return 0;
}
0