Last active
August 29, 2015 14:19
-
-
Save na-o-ys/e9a1e04718c57d788605 to your computer and use it in GitHub Desktop.
TCO 2015 Round 1A Med
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define loop(n, i) for(int i=0;i<n;i++) | |
#define all(v) v.begin(),v.end() | |
using namespace std; | |
using ll = long long; | |
const ll MOD = 1000000007; | |
class Autogame | |
{ | |
public: | |
int wayscnt(vector <int> a, int K) { | |
int N = a.size(); | |
K = min(N, K); | |
vector<int> cnt(N); | |
loop (N, i) { | |
int p = i+1; | |
loop (K, j) p = a[p-1]; | |
cnt[p-1]++; | |
} | |
ll ans = 1; | |
for (int v : cnt) { | |
ans *= v + 1; | |
ans %= MOD; | |
} | |
return ans; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment