제출 #491770

#제출 시각아이디문제언어결과실행 시간메모리
491770shahriarkhan캥거루 (CEOI16_kangaroo)C++14
100 / 100
27 ms22988 KiB
#include<bits/stdc++.h>
using namespace std ;

const long long mod = 1e9 + 7 , mx = 2005 ;

long long dp[mx][mx] ;

int main()
{
    int n , cs , cf ;
    scanf("%d%d%d",&n,&cs,&cf) ;
    dp[1][1] = 1 ;
    int in = ((1==cf) || (1==cs)) ;
    for(int i = 1 ; i < n ; ++i)
    {
        if(((i+1)==cf) || ((i+1)==cs)) ++in ;
        for(int j = 1 ; j <= i ; ++j)
        {
            if(((i+1)==cs) || ((i+1)==cf))
            {
                dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j])%mod ;
                dp[i+1][j] = (dp[i+1][j] + dp[i][j])%mod ;
            }
            else
            {
                dp[i+1][j+1] = (dp[i+1][j+1] + ((dp[i][j]*(j+1-in))%mod))%mod ;
                dp[i+1][j-1] = (dp[i+1][j-1] + ((dp[i][j]*(j-1))%mod))%mod ;
            }
        }
    }
    printf("%lld\n",dp[n][1]) ;
    return 0 ;
}

컴파일 시 표준 에러 (stderr) 메시지

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d%d",&n,&cs,&cf) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...