Submission #995061
Source Code Expand
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int INF = 1<<29; const double EPS = 1e-8; typedef vector<int> vec; typedef pair<int,int> P; typedef long long ll; int main(){ ll N, M; cin >> N >> M; // n_1[k] = (N - 1)^k, n_2[k] = (N - 2) ^ k vector<ll> n_1(M), n_2(M); n_1[0] = 1; n_2[0] = 1; for(ll i=1;i<M;i++){ n_1[i] = (n_1[i-1] * (N - 1)) % MOD; n_2[i] = (n_2[i-1] * (N - 2)) % MOD; } // np[k] = n^k vector<ll> np(M+1); np[0] = 1; for(int i=1;i<=M;i++){ np[i] = (np[i-1] * N) % MOD; } ll ans = 0; for(ll k=N-1;k<=M-1;k++){ ll left = ((N - 1) * (n_1[k - 1] - n_2[k] + MOD) % MOD); ll right = np[M - k - 1]; ans = (ans + left * right) % MOD; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | zaburo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 885 Byte |
Status | WA |
Exec Time | 3 ms |
Memory | 256 KB |
Judge Result
Set Name | sample | all | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1000 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt |
all | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 3 ms | 256 KB |
01-02.txt | AC | 3 ms | 256 KB |
01-03.txt | WA | 3 ms | 256 KB |
01-04.txt | AC | 3 ms | 256 KB |
01-05.txt | WA | 3 ms | 256 KB |
01-06.txt | WA | 3 ms | 256 KB |
01-07.txt | WA | 3 ms | 256 KB |
01-08.txt | WA | 3 ms | 256 KB |
01-09.txt | WA | 3 ms | 256 KB |
01-10.txt | WA | 3 ms | 256 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | WA | 3 ms | 256 KB |
sample-03.txt | AC | 3 ms | 256 KB |