Sort by

recency

|

8 Discussions

|

  • + 0 comments

    hint: if your solution is seemingly correct, but fails for 1-2 test cases, then the answer is that 0 is NOT a valid 1-digit number in this problem (just to save some hackos for you :-) )

  • + 0 comments

    Maths is really a complicated subject and many of the students don't like Maths as its complex Coffee beans ireland. Maths is interesting if we learn in such a way. This tutor helps to learn math’s in a funny way and in this they have explained the Permutation Problem very well

  • + 0 comments

    Solution in C++

    #include <bits/stdc++.h>
    #define SZ(X) ((int)(X).size())
    #define ALL(X) (X).begin(), (X).end()
    #define REP(I, N) for (int I = 0; I < (N); ++I)
    #define REPP(I, A, B) for (int I = (A); I < (B); ++I)
    #define RI(X) scanf("%d", &(X))
    #define RII(X, Y) scanf("%d%d", &(X), &(Y))
    #define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
    #define DRI(X) int (X); scanf("%d", &X)
    #define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
    #define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
    #define RS(X) scanf("%s", (X))
    #define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
    #define MP make_pair
    #define PB push_back
    #define MS0(X) memset((X), 0, sizeof((X)))
    #define MS1(X) memset((X), -1, sizeof((X)))
    #define LEN(X) strlen(X)
    #define F first
    #define S second
    typedef long long LL;
    using namespace std;
    const int MOD = 1e9+7;
    int C[1001][1001],dp[10][1001],ha[1001][1001][10],dp2[1001][1001];
    int main(){
        REP(i,1001){
            C[i][0]=1;
            REPP(j,1,i+1){
                C[i][j]=C[i-1][j-1]+C[i-1][j];
                if(C[i][j]>=MOD)C[i][j]-=MOD;
            }
        }
        for(int i=1;i<=1000;i++){
            for(int j=1;j<=i;j++){
                ha[i][j][0]=1;
                for(int k=1;k*j<=i&&k<10;k++){
                    ha[i][j][k]=(LL)ha[i][j][k-1]*C[i-(k-1)*j][j]%MOD;
                }
            }
        }
        int kerker=0;
        REP(i,9)dp[i][0]=1;
        REPP(i,1,1001){
            for(int j=9;j>=1;j--)
                for(int k=min(j*i,1000);k>=i;k--){
                    for(int r=1;r*i<=k&&r<=j;r++){
                        dp[j][k]=(dp[j][k]+(LL)dp[j-r][k-r*i]*ha[k][i][r]%MOD*C[j][r])%MOD;
                    }
                }
            for(int j=0;j<=min(i*9,1000);j++)dp2[i][j]=dp[9][j];
        }
        CASET{
            DRII(n,k);
            k=min(n,k);
            int an=0;
            for(int i=0;i<n&&i<=k;i++)an=(an+(LL)C[n-1][i]*dp2[k][n-i])%MOD;
            printf("%d\n",an);
        }
        return 0;
    }
    
  • + 0 comments

    Editorial is not accessible.

  • + 0 comments

    Editorial is not opening. Please fix