結果

問題 No.358 も~っと!門松列
ユーザー ohreitetsuohreitetsu
提出日時 2018-09-05 22:54:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 617 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 63,724 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-09 20:06:29
合計ジャッジ時間 1,842 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
bool IsMenShong(int B1,int B2,int B3)
{
	if (B1==B2 || B1==B3 || B2==B3){
		return false;
	}
	if (B2==min(B1,min(B2,B3))){
		return true;
	}
	if (B2==max(B1,max(B2,B3))){
		return true;
	}
	return false;
}
int main(int argc, char* argv[])
{
	int A1,A2,A3;
	cin>>A1>>A2>>A3;

	int maxA=max(A1,max(A2,A3))+1;

	int B1=A1%maxA;
	int B2=A2%maxA;
	int B3=A3%maxA;
	if (IsMenShong(B1,B2,B3)){
		cout<<"INF"<<endl;
		return 0;
	}
	int ans=0;
	int p;
	for (p=1;p<=maxA;p++){
		B1=A1%p;
		B2=A2%p;
		B3=A3%p;
		if (IsMenShong(B1,B2,B3)){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0