程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> ZOJ 3644 Kitty's Game(DP)

ZOJ 3644 Kitty's Game(DP)

編輯:C++入門知識

ZOJ 3644 Kitty's Game(DP)


Description

Kitty is a little cat. She is crazy about a game recently.

There are n scenes in the game(mark from 1 to n). Each scene has a number pi. Kitty's score will become least_common_multiple(x,pi) when Kitty enter the ith scene. x is the score that Kitty had previous. Notice that Kitty will become mad If she go to another scene but the score didn't change.

Kitty is staying in the first scene now(with p1 score). Please find out how many paths which can arrive at the nth scene and has k scores at there. Of course, you can't make Kitty mad.

We regard two paths different if and only if the edge sequence is different.

Input

There are multiple test cases. For each test case:

The first line contains three integer n(2 ≤ n ≤ 2000), m(2 ≤ m ≤ 20000), k(2 ≤ k ≤ 106). Then followed by m lines. Each line contains two integer u, v(1 ≤ u, v ≤ n, u ≠ v) indicate we can go to vth scene from uth scene directly. The last line of each case contains n integer pi(1 ≤pi ≤ 106).

Process to the end of input.

Output

One line for each case. The number of paths module 1000000007.

Sample Input

5 6 84
1 2
2 5
1 3
3 5
1 4
4 5
1 5 4 12 21

Sample Output

2

馬丹,map不太會用,看的別人的
題意:n:n個點 m:m條路  k:值,每個點有一個值,要求從起點到終點的不同方案。中間不用許出現LCM不變的情況

#include
#include
#include
#include
#include
#include
typedef long long LL;
using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )
const int maxn=2010;
const int MOD=1e9+7;
vectorv[maxn];
mapM;
LL dp[maxn][maxn],p[maxn],k;
int n,m;
LL gcd(LL a,LL b)
{
    return b?gcd(b,a%b):a;
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}
LL dfs(LL u,LL s)
{
//    cout<<"madan  "<


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved