CodeChef submission 738306 (C++ 4.3.2) plaintext list. Status: WA, problem COLCHAIN, contest . By kostroma (kostroma), 2011-11-23 17:03:09.

#include <iostream> #include <stdio.h> #include <vector> #include <string> #include <algorithm> #include <set> #include <memory.h> using namespace std; #define pb push_back #define mp make_pair typedef pair <int, int> pi; typedef long long li; void solve(); int main () { #ifndef ONLINE_JUDGE #endif int t=1; cin>>t; while (t--) solve(); return 0; } #define int li int n, m; int mod=1000000007; int dp[100500][2]; { if (!w) return 1; if (w%2) } void solve() { cin>>n>>m; int fact=1; for (int i=1; i<=m; i++) fact=(fact*i)%mod; dp[m+1][0]=(fact*( (m*(m-1)/2) %mod ))%mod; dp[m+1][1]=(fact*m)%mod; for (int i=m+1; i<n; i++) { dp[i+1][false]=(((m-1)*dp[i][true])%mod)+((((m-2)*dp[i][false])%mod)*pow(m, mod-2))%mod; dp[i+1][false]%=mod; } cout<<(dp[n][true]+dp[n][false])%mod<<endl; }

## Comments

**Please login at the top to post a comment.**