結果

問題 No.358 も~っと!門松列
ユーザー furafura
提出日時 2020-03-31 20:30:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 557 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 192,020 KB
最終ジャッジ日時 2025-01-09 11:20:37
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         rep(i,3) scanf("%d",&a[i]);
      |                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int a[3];
	rep(i,3) scanf("%d",&a[i]);

	if(a[0]==a[1] || a[0]==a[2] || a[1]==a[2]) return puts("0"),0;

	int mx=*max_element(a,a+3);
	int mn=*min_element(a,a+3);
	if(a[1]==mx || a[1]==mn) return puts("INF"),0;

	int ans=0;
	for(int p=1;p<=1000;p++){
		int b[3];
		rep(i,3) b[i]=a[i]%p;
		mx=*max_element(b,b+3);
		mn=*min_element(b,b+3);
		if(b[0]!=b[1] && b[0]!=b[2] && b[1]!=b[2] && (b[1]==mx || b[1]==mn)) ans++;
	}
	printf("%d\n",ans);

	return 0;
}
0