Wednesday, June 8, 2016

UVA 10050 : Hartals - solution

Unknown
#include<cstdio>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        int n,q,p,r,count;
        scanf("%d",&n);
        int a[n+1]={0};
        scanf("%d",&p);
        count=0;
        while (p--)
        {
            scanf("%d",&q);
            for (int i=q;i<=n;i+=q)
            {
                r=i%7;
                if (a[i]==0 && r!=0 && r!=6)
                {
                    count++;
                    a[i]=1;
                }
            }
        }
        printf("%d\n",count); 
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,