6138:Hours and Minutes

問題文
https://icpcarchive.ecs.baylor.edu/external/61/6138.pdf

与えられた数字が、時計の短針と長針が作る角度に含まれるかどうかを判定せよ。短針は長針が12進んだときに1進む。




































短針と長針が作る角度を全て生成しておく。工夫は必要ない。

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define all(c) (c).begin(),(c).end()

using namespace std;

int main(void){
	
	vector<int>dg;
	
	for(int m=0,h=0;h<60;m++){
		if(m%12==0)h++,m=0;
		int res=6*abs(h-m);
		res=min(res,360-res);
		dg.push_back(res);
	}
	
	sort(all(dg));
	dg.erase(unique(all(dg)),dg.end());
	
	int n;
	while(cin >> n){
		if(binary_search(all(dg),n))cout << "Y" << endl;
		else cout << "N" << endl;
	}
	
	return 0;
}