About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

বুধবার, ১০ ফেব্রুয়ারী, ২০১৬

uva 10616 - Divisible Group Sums solution

#include <bits/stdc++.h>
#define pb push_back
#define MAX 10006
#define mod 1000000009
#define read freopen("input.txt","r",stdin);
#define base 10
using namespace std;
typedef long long ll;
typedef unsigned long long llu;

int n,Q,d,m,ary[300];
int dp[201][11][50];
int call(int i,int c,int sum)
{

    if(c==m)
    {
        if(sum) return 0;
        else return 1;
    }
    if(i>=n) return 0;
    if(dp[i][c][sum]!=-1) return dp[i][c][sum];

    return dp[i][c][sum]=call(i+1,c+1,(sum+ary[i])%d)+call(i+1,c,sum);
}



int main()
{
    // read;
    int cas=0;
    while(~scanf("%d %d",&n,&Q)&&n&&Q)
    {
        for(int i=0; i<n; i++) scanf("%d",&ary[i]);
        printf("SET %d:\n",++cas);

        for(int q=1; q<=Q; q++)
        {
            memset(dp,-1,sizeof(dp));
            scanf("%d %d",&d,&m);
            printf("QUERY %d: %d\n",q,call(0,0,0));
        }
    }


    return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন