結果

問題 No.358 も~っと!門松列
ユーザー umaumax
提出日時 2017-05-01 21:52:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 660 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 58,916 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-14 02:13:35
合計ジャッジ時間 1,284 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, const char* argv[])
{
	int A[3];
	cin >> A[0] >> A[1] >> A[2];

	{
		int _A[3] = {A[0], A[1], A[2]};
		sort(&_A[0], &_A[2 + 1]);
		if (_A[0] == _A[1] || _A[1] == _A[2]) {
			cout << 0 << endl;
			return 0;
		}
	}

	if (A[1] < A[0] && A[1] < A[2] || A[1] > A[0] && A[1] > A[2]) {
		cout << "INF" << endl;
		return 0;
	}

	int cnt = 0;
	int p   = 1;
	while (p <= 1001) {
		if (A[0] % p != A[1] % p && A[0] % p != A[2] % p && (A[1] % p < A[0] % p && A[1] % p < A[2] % p || A[1] % p > A[0] % p && A[1] % p > A[2] % p)) {
			cnt++;
		}
		p++;
	}

	cout << cnt << endl;
	return 0;
}
0