結果

問題 No.442 和と積
ユーザー kashi3215
提出日時 2018-06-06 17:23:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 327 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 14,904 KB
最終ジャッジ日時 2024-06-30 10:16:40
合計ジャッジ時間 4,768 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |         scanf("%lld %lld", &A, &B);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:9:11: warning: ‘X’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 |         Y = A * B%X;
      |         ~~^~~~~~~~~

ソースコード

diff #

#include<cstdio>
int main(void) {
	long long int A, B, X, Y;
	scanf("%lld %lld", &A, &B);

	if (A == 1 || B == 1) { printf("1"); }
	else
	X = A + B;
	Y = A * B%X;
	while (X%Y != 0 && Y % X != 0) {
		if (X > Y) { X = X % Y; }
		else { Y = Y % X; }
	}

	if (X > Y) {printf("%lld",Y );}
	else { printf("%lld", X); }

	return 0;

}
0