Problem Type : Ad hoc
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
bool arr1[100000];
int main()
{
int arr[100000],n,t,i,j ,p,d,sum,k,add,s=0,bac,l;
scanf("%d",&t);
while(t--)
{
cin >> d;
cin >> p;
for(j=1; j<=p; j++)
{
cin >> arr[j];
}
k=1;
s=0;
l=0;
while(k<=p)
{
sum=0;
for(j=1; ; j++)
{
if(d<j*arr[k])
break;
if(j*arr[k]<=d)
{
arr1[j*arr[k]] = 1;
}
}
k++;
}
for(j=1;j<=d;j++)
{
sum = j*7;
if(sum-1>d)
break;
else
{
arr1[sum]=0;
arr1[sum-1] = 0;
}
}
s=0;
for(j=1;j<=d;j++)
{
if(arr1[j]==1)
s++;
}
cout << s <<endl;
memset(arr1,0,sizeof(arr1));
}
return 0;
}
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
bool arr1[100000];
int main()
{
int arr[100000],n,t,i,j ,p,d,sum,k,add,s=0,bac,l;
scanf("%d",&t);
while(t--)
{
cin >> d;
cin >> p;
for(j=1; j<=p; j++)
{
cin >> arr[j];
}
k=1;
s=0;
l=0;
while(k<=p)
{
sum=0;
for(j=1; ; j++)
{
if(d<j*arr[k])
break;
if(j*arr[k]<=d)
{
arr1[j*arr[k]] = 1;
}
}
k++;
}
for(j=1;j<=d;j++)
{
sum = j*7;
if(sum-1>d)
break;
else
{
arr1[sum]=0;
arr1[sum-1] = 0;
}
}
s=0;
for(j=1;j<=d;j++)
{
if(arr1[j]==1)
s++;
}
cout << s <<endl;
memset(arr1,0,sizeof(arr1));
}
return 0;
}
No comments:
Post a Comment