标签:枚举 namespace ble color print using for std pac
http://acm.xidian.edu.cn/problem.php?id=1119
求最小公倍数问题,直接暴力枚举1-1000。
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; int a[1005],n,k; bool ok(int x) { int cnt = 0; for(int i = 1;i <= n;i++) { if(x%a[i] == 0) cnt++; } if(cnt >= k) return 1; return 0; } int main() { while(~scanf("%d%d",&n,&k)) { for(int i = 1;i <= n;i++) scanf("%d",&a[i]); int ans = 1; for(;ans <=1000;ans++) { if(ok(ans)) break; } if(ans <= 1000) printf("%d\n",ans); else printf("Orz\n"); } return 0; }
标签:枚举 namespace ble color print using for std pac
原文地址:http://www.cnblogs.com/zhurb/p/6034617.html