3195: [Jxoi2012] Strange road time limit:10 Sec Memory limit:128 MB
submit:336 solved:209
[Submit] [Status] [Discuss] Description
Xiaoyu learned an ancient civilization from the history book. This civilization is highly developed in all aspects, and transportation is no exception. Archaeologists already know that this civilization in its heyday had n cities numbered 1. N. M road links between these cities, each road connects two cities, making it easy for the residents of the two places to travel. There may be many roads between a pair of cities.
According to historical records, this civilized traffic network satisfies two strange characteristics. First of all, this civilization worships the number k, so for any road, set it to connect the two cities are U and V, then must meet 1 <=|u-v| <= K. In addition, any city is connected to exactly the even number of roads (0 is also considered an even one). However, because of the time is too long, the specific traffic network we have no way to know. Xiaoyu was curious about the number of possible connections between these n cities, and she asked you for help.
The number of methods can be large, and you only need to output the result after the method number modulo 1000000007.
Input
Enter a total of 3 integers n,m,k.
Output
Outputs 1 integers that represent the result of a scheme number modulo 1000000007.
Sample Input"Input Sample 1"
3 4 1
"Input Sample 2"
4 3 3
Sample Output"output Example 1"
3
"Output Example 2"
4
HINT
"Data Size"
100% of the data meet 1<= N <=, 0 <= m <=, 1 <= K <= 8.
"topic description"
Two possible connection methods are different when and only if there is a pair of cities, the number of roads between them differs between the two methods.
It is possible that two cities cannot reach each other in a traffic network.
Source [Submit] [Status] [Discuss]
Like pressure, too lazy to move the brain ...
1#include <bits/stdc++.h>2 Const intMoD =1000000007;3 intN, M, T, bit[ the], f[ +][ to][1024x768][Ten];4Signed Main (void) {5f[2][0][0][0] =1;6scanf"%d%d%d", &n, &m, &t);7 for(inti = bit[0] =1; I <Ten; ++i)8Bit[i] = bit[i-1] <<1;9 for(inti =2; I <= N; ++i)Ten for(intj =0; J <= M; ++j) One for(intK =0; K < Bit[t +1]; ++k) { A for(intL =0; L < T; ++l) - if(F[i][j][k][l]) { -(F[i][j][k][l +1] + = F[i][j][k][l])%=MoD; the if(I-t + L >0&& J <m) -(F[i][j +1][k ^ bit[l] ^ Bit[t]][l] + + f[i][j][k][l])%=MoD; - } - if(! (K &1) && F[i][j][k][t]) F[i +1][j][k >>1][0] =F[i][j][k][t]; + } -printf"%d\n", F[n +1][m][0][0]); +}
@Author: Yousiki
Bzoj 3195: [Jxoi2012] Strange Road