UVA 10050罢工题

来源:互联网 发布:创意淘宝店铺头像图片 编辑:程序博客网 时间:2024/06/14 22:09
  1. 每日一水
  2. 这题 就是遍历所有天数,模拟一下全过程
  3. #include <bits/stdc++.h> using namespace std;int nums[101]; //政党总数 int days[3655]; //总天数 int main(){//freopen("d:\\input.txt" , "r" , stdin);int n , t , p;while (~scanf("%d",&t))while (t--){scanf("%d%d",&n,&p);  memset(days , 0 , sizeof(days));//cout << sizeof(days)<< " " << sizeof(int) <<endl;    for (int i = 0 ; i < p ; ++ i)              scanf("%d",&nums[i]);                  for (int i = 0 ; i < p ; ++ i)          for (int j = 0 ; j <= n ; j += nums[i])  //遍历天数和党派             days[j] = 1;          for (int j = 0 ; j <= n ; j += 7)  //去掉礼拜六             days[j] = 0;          for (int j = 6 ; j <= n ; j += 7)  //去掉礼拜五             days[j] = 0;          int sum = 0;          for (int i = 1 ; i <= n ; ++ i)  //遍历天数, 有就相加              sum += days[i]; printf("%d\n",sum); }return 0;}


0 0
原创粉丝点击