結果

問題 No.816 Beautiful tuples
ユーザー CoohCooh
提出日時 2019-06-02 01:31:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 1,262 ms
コンパイル使用メモリ 62,080 KB
実行使用メモリ 11,360 KB
最終ジャッジ日時 2023-10-17 22:53:48
合計ジャッジ時間 3,981 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:15: warning: ignoring return value of ‘int system(const char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |         system("pause");
      |         ~~~~~~^~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
using namespace std;

int Enjapma(int A, int B) {
	if (A == B) {
		return -1;
	}

	int D = A + B;
	vector<int> div;
	for (int i = 1; i < (D / 2); i++) {
		if (D%i == 0) {
			div.insert(div.begin(), i);
		}
	}
	
	vector<int> Bans;
	vector<int>::iterator a = div.begin();
	while (a != div.end()) {
		if ((A + *a) % B == 0) {
			Bans.insert(Bans.begin(), *a);
		}
		a++;
	}
	int ans = -1;
	vector<int>::iterator b = Bans.begin();
	while (b != Bans.end()) {
		if ((B + *b) % A == 0) {
			ans = *b;
		}
		b++;
	}

	if (A == ans) { ans = -1; }
	if (B == ans) { ans = -1; }
	return ans;

}
int main() {
	int A, B;
	cout << "A B > "; cin >> A >> B;

	cout << Enjapma(A, B) << endl;

	system("pause");
	return 0;

}
0