Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Working Days
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int i,t,k,j;
- cin>>t;
- for(i=0;i<t;i++){
- int total=0;
- int n,p;
- cin>>n>>p;
- int a[n+2]={0};
- int h[p+2];
- for(k=1;k<=p;k++) cin>>h[k];
- for(j=6;j<=n;j=j+7){
- a[j]=1;
- a[j+1]=1;
- }
- for(k=1;k<=p;k++){
- for(j=h[k];j<=n;j=j+h[k]){
- if(a[j]==0) {
- total++;
- a[j]=1;
- }
- }
- }
- cout<<total<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement