3
5
2015
0

UVa 10050 Hartals

#include <iostream>
using namespace std;

int main() {
	int t,n,p,h[100],ans;
	cin>>t;
	while (t--){
		cin>>n>>p; ans=0;
		for (int i=0;i<p;++i)
			cin>>h[i];
		for (int i=1;i<=n;++i)
			if (i%7!=6 && i%7!=0)
				for (int j=0;j<p;++j)
					if (i%h[j]==0){
						++ans;
						break;
					}
		cout<<ans<<endl;//让人发火的是,最后一个输出如果不加空行会判错
	}
	return 0;
}
Category: 题解 | Tags: UVa 挑战编程 模拟 | Read Count: 210

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com