Submission #19698

# Submission time Handle Problem Language Result Execution time Memory
19698 2016-02-25T04:41:36 Z Namnamseo 순열 (kriii4_T) C++14
8 / 100
2000 ms 16708 KB
#include<cstdio>
long long mans,c,mul[1000003],fac[1000003],a,b,i,j,s=1,ans,X=1e9+7;
main()
{
    scanf("%lld%lld",&a,&b);
    if(b>=a)
    {
        printf("0");return 0;
    }
    for(;b<=a-1;){
    b++;ans=0;
    mul[a-b+1]=1;
    for(i=a-b;i>=1;i--)
    {
        mul[i]=mul[i+1]*i%X;
    }
    fac[0]=1;
    for(i=1;i<=a;i++)fac[i]=fac[i-1]*i%X;
    for(i=1;i<=a&&a-i>=0&&a-b+2-i>=1;i++)
    {
        ans+=i*b%X*fac[a-i]%X*mul[a-b+2-i]%X;
        ans%=X;
    }

    mans+=ans*(a-b+1)%X;
    mans%=X;
    }
    printf("%lld",mans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16708 KB Output is correct
2 Correct 0 ms 16708 KB Output is correct
3 Correct 0 ms 16708 KB Output is correct
4 Correct 0 ms 16708 KB Output is correct
5 Correct 0 ms 16708 KB Output is correct
6 Correct 0 ms 16708 KB Output is correct
7 Correct 0 ms 16708 KB Output is correct
8 Correct 0 ms 16708 KB Output is correct
9 Correct 0 ms 16708 KB Output is correct
10 Correct 0 ms 16708 KB Output is correct
11 Correct 0 ms 16708 KB Output is correct
12 Correct 0 ms 16708 KB Output is correct
13 Correct 0 ms 16708 KB Output is correct
14 Correct 0 ms 16708 KB Output is correct
15 Correct 0 ms 16708 KB Output is correct
16 Correct 0 ms 16708 KB Output is correct
17 Correct 16 ms 16708 KB Output is correct
18 Correct 3 ms 16708 KB Output is correct
19 Correct 9 ms 16708 KB Output is correct
20 Correct 14 ms 16708 KB Output is correct
21 Correct 18 ms 16708 KB Output is correct
22 Correct 0 ms 16708 KB Output is correct
23 Correct 0 ms 16708 KB Output is correct
24 Correct 30 ms 16708 KB Output is correct
25 Correct 0 ms 16708 KB Output is correct
26 Correct 23 ms 16708 KB Output is correct
27 Correct 0 ms 16708 KB Output is correct
28 Correct 66 ms 16708 KB Output is correct
29 Correct 64 ms 16708 KB Output is correct
30 Correct 13 ms 16708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2000 ms 16704 KB Program timed out
2 Halted 0 ms 0 KB -