锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久天天躁狠狠躁夜夜2020,久久国产福利免费,久久久精品免费国产四虎http://www.shnenglu.com/y346491470/category/18524.html涓烘ⅵ鎯寵屽鏂楋紒zh-cnThu, 19 Apr 2012 14:58:46 GMTThu, 19 Apr 2012 14:58:46 GMT60CF 161D - 鏍慸phttp://www.shnenglu.com/y346491470/articles/171726.htmly @ The Angry Teletubbiesy @ The Angry TeletubbiesTue, 17 Apr 2012 03:04:00 GMThttp://www.shnenglu.com/y346491470/articles/171726.htmlhttp://www.shnenglu.com/y346491470/comments/171726.htmlhttp://www.shnenglu.com/y346491470/articles/171726.html#Feedback0http://www.shnenglu.com/y346491470/comments/commentRss/171726.htmlhttp://www.shnenglu.com/y346491470/services/trackbacks/171726.html
銆愰瑙c戯細鐢ㄦ爲鐨勫垎娌誨彲瑙o紝浣嗘槸鍐欒搗鏉ユ瘮杈冮夯鐑︺?br />               璁劇姸鎬乨p[i][j]琛ㄧず浠涓烘牴鐨勫瓙鏍戠殑鑺傜偣鍒癷鐨勮窛紱繪伆涓簀鐨勪釜鏁般?br />               鐒跺悗鍒╃敤涔樻硶鍘熺悊姹傚嚭絳旀錛屽啀鎶婂効瀛愮殑淇℃伅浼犵粰鐖朵翰銆?br />
銆愪唬鐮併戯細
 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "algorithm"
 5 #include "vector"
 6 #include "queue"
 7 #include "cmath"
 8 #include "string"
 9 #include "cctype"
10 #include "map"
11 #include "iomanip"
12 using namespace std;
13 #define pb push_back
14 #define lc(x) (x << 1)
15 #define rc(x) (x << 1 | 1)
16 #define lowbit(x) (x & (-x))
17 #define ll long long
18 #define maxn 50050
19 
20 int n, k;
21 ll dp[50050][505];
22 ll ans;
23 vector<int> vec[maxn];
24 
25 void dfs(int u, int fa) {
26     memset(dp[u], 0, sizeof(dp[u]));
27     dp[u][0] = 1;
28     int size = vec[u].size();
29     for(int i = 0; i < size; i++) {
30         int v = vec[u][i];
31         if(v == fa) continue;
32         dfs(v, u);
33         for(int j = 1; j <= k; j++) 
34             ans += dp[u][j-1] * dp[v][k-j];
35         for(int j = 1; j <= k; j++)
36             dp[u][j] += dp[v][j-1];
37     }
38 }
39 
40 int main() {
41     int u, v;
42     while(cin >> n >> k) {
43         for(int i = 0; i < maxn; i++) vec[i].clear();
44         for(int i = 1; i < n; i++) {
45             cin >> u >> v;
46             vec[u].pb(v);
47             vec[v].pb(u);
48         }
49         ans = 0;
50         dfs(1, -1);
51         cout << ans << endl;
52     }
53     return 0;
54 }
55 


y @ The Angry Teletubbies 2012-04-17 11:04 鍙戣〃璇勮
]]>
CF 152E - 鐘舵佸帇緙ヾp + 鏂潶綰蟲爲 + 璁板綍鏂規http://www.shnenglu.com/y346491470/articles/171718.htmly @ The Angry Teletubbiesy @ The Angry TeletubbiesTue, 17 Apr 2012 02:50:00 GMThttp://www.shnenglu.com/y346491470/articles/171718.htmlhttp://www.shnenglu.com/y346491470/comments/171718.htmlhttp://www.shnenglu.com/y346491470/articles/171718.html#Feedback0http://www.shnenglu.com/y346491470/comments/commentRss/171718.htmlhttp://www.shnenglu.com/y346491470/services/trackbacks/171718.html
銆愰瑙c戯細鍙渶瑕佺敤spfa dp涓嬈″嵆鍙紝瑕佽褰曠姸鎬佺殑鍓嶉┍鐘舵佷繚瀛樻柟妗堛?br />
銆愪唬鐮併戯細
  1 #include "iostream"
  2 #include "cstdio"
  3 #include "cstring"
  4 #include "algorithm"
  5 #include "vector"
  6 #include "queue"
  7 #include "cmath"
  8 #include "string"
  9 #include "cctype"
 10 #include "map"
 11 #include "iomanip"
 12 using namespace std;
 13 #define pb push_back
 14 #define mp make_pair
 15 #define fi first
 16 #define se second
 17 #define lc(x) (x << 1)
 18 #define rc(x) (x << 1 | 1)
 19 #define lowbit(x) (x & (-x))
 20 #define ll long long
 21 const int inf = 1 << 29;
 22 int dp[210][1<<7], pre[210][1<<7];
 23 int n, m, k, nn, mm;
 24 int hash[210];
 25 int maz[110][110];
 26 char g[110][110];
 27 bool visit[210][1<<7];
 28 int dx[] = {0, 0, -1, 1};
 29 int dy[] = {-1, 1, 0, 0};
 30 
 31 struct Node {
 32     int u, st;
 33     Node(){}
 34     Node(int _u, int _st) {
 35         u = _u, st = _st;
 36     }
 37 };
 38 queue<Node> que;
 39 
 40 bool check(int x, int y) {
 41     if(x >= 0 && x < n && y >= 0 && y < m) return true;
 42     return false;
 43 }
 44 
 45 void update(int u, int st, int w, int fa) {
 46     if(dp[u][st] > w) {
 47         dp[u][st] = w;
 48         pre[u][st] = fa;
 49         if(!visit[u][st]) {
 50             que.push(Node(u, st));
 51             visit[u][st] = true;
 52         }
 53     }
 54 }
 55 
 56 void dfs(int u, int st) {
 57     int x = u / m, y = u % m;
 58     g[x][y] = 'X';
 59     if(pre[u][st] == -1) return;
 60     else {
 61         int v = pre[u][st] / 1000, stt = pre[u][st] % 1000;
 62         dfs(v, stt);
 63         if(stt - st) dfs(v, st - stt);//鐗涘弶鐨勮褰曪紝鎷嗗垎褰撳墠鐘舵?/span>
 64     }
 65 }
 66 
 67 void solve() {
 68     while(!que.empty()) {
 69         Node now = que.front();
 70         que.pop();
 71         int u = now.u, x = now.u / m, y = now.u % m, st = now.st;
 72         visit[u][st] = false;
 73         for(int i = 0; i < 4; i++) {
 74             int xx = x + dx[i], yy = y + dy[i];
 75             if(!check(xx, yy)) continue;
 76             int v = xx * m + yy;
 77             update(v, st, dp[u][st] + maz[xx][yy], u * 1000 + st);
 78         }
 79         int t = mm - 1 - st;
 80         for(int i = t; i; i = (i-1) & t) {
 81             update(u, i | st, dp[u][i] + dp[u][st] - maz[x][y], u * 1000 + st);
 82         }
 83     }
 84     int ans = inf, u;
 85     for(int i = 0; i < nn; i++) {
 86         if(ans > dp[i][mm-1]) {
 87             ans = dp[i][mm-1];
 88             u = i;
 89         }
 90     }
 91     dfs(u, mm - 1);
 92     cout << ans << endl;
 93     for(int i = 0; i < n; i++) {
 94         for(int j = 0; j < m; j++)
 95             cout << g[i][j];
 96         cout << endl;
 97     }
 98 }
 99 
100 int main() {
101     while(cin >> n >> m >> k) {
102         while(!que.empty()) que.pop();
103         for(int i = 0; i < n; i++) {
104             for(int j = 0; j < m; j++) {
105                 cin >> maz[i][j];
106                 g[i][j] = '.';
107             }
108         }
109         nn = n * m, mm = 1 << k;
110         memset(hash, 0, sizeof(hash));
111         memset(visit, falsesizeof(visit));
112         for(int i = 0; i < nn; i++) 
113             for(int j = 0; j < mm; j++)
114                 dp[i][j] = inf;
115         for(int i = 0, a, b; i < k; i++) {
116             cin >> a >> b;
117             a--, b--;
118             int u = a * m + b;
119             hash[u] = 1 << i;
120             update(u, hash[u], maz[a][b], -1);
121         }
122         solve();
123     }
124     return 0;
125 }
126 


y @ The Angry Teletubbies 2012-04-17 10:50 鍙戣〃璇勮
]]>
CF 150A - 鍗氬紙 + 璁板繂鍖栨悳绱?/title><link>http://www.shnenglu.com/y346491470/articles/165943.html</link><dc:creator>y @ The Angry Teletubbies</dc:creator><author>y @ The Angry Teletubbies</author><pubDate>Sat, 18 Feb 2012 16:32:00 GMT</pubDate><guid>http://www.shnenglu.com/y346491470/articles/165943.html</guid><wfw:comment>http://www.shnenglu.com/y346491470/comments/165943.html</wfw:comment><comments>http://www.shnenglu.com/y346491470/articles/165943.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/y346491470/comments/commentRss/165943.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/y346491470/services/trackbacks/165943.html</trackback:ping><description><![CDATA[銆愰鎰忋戯細緇欏嚭涓涓綋鍓嶅紂(q <= 10^13)錛屼袱涓漢杞祦鍐欏嚭涓涓綋鍓嶅肩殑闈炲鉤鍑″洜瀛愭潵鍙栦唬褰撳墠鍊鹼紝璋佷笉鑳藉啓璋佽儨鍑恒備竴涓暟鐨勯潪騫沖嚒鍥犲瓙鏄寚闄?鍜屾湰韜箣澶栫殑鍥犲瓙銆備袱涓漢閮介噰鍙栨渶浼樺喅絳栵紝闂渶鍚庤皝鑳滃嚭銆?br /><br />銆愰瑙c戯細鍗氬紙錛岀洿鎺ヨ蹇嗗寲鎼滅儲鍗沖彲錛屽彧瑕佹悳鍒扮涓涓繀璐ユ佸氨鍙互璺沖嚭銆?br />               鍒╃敤map鏉ュ鐞嗗彲浠ユ妸浠g爜鍐欏緱寰堢煭銆?br /><br />銆愪唬鐮併戯細<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> #include "iostream"<br /><span style="color: #008080; "> 2</span> #include "cstdio"<br /><span style="color: #008080; "> 3</span> #include "cstring"<br /><span style="color: #008080; "> 4</span> #include "algorithm"<br /><span style="color: #008080; "> 5</span> #include "vector"<br /><span style="color: #008080; "> 6</span> #include "queue"<br /><span style="color: #008080; "> 7</span> #include "cmath"<br /><span style="color: #008080; "> 8</span> #include "string"<br /><span style="color: #008080; "> 9</span> #include "cctype"<br /><span style="color: #008080; ">10</span> #include "map"<br /><span style="color: #008080; ">11</span> #include "iomanip"<br /><span style="color: #008080; ">12</span> <span style="color: #0000FF; ">using</span> <span style="color: #0000FF; ">namespace</span> std;<br /><span style="color: #008080; ">13</span> <span style="color: #0000FF; ">#define</span> pb push_back<br /><span style="color: #008080; ">14</span> <span style="color: #0000FF; ">#define</span> lc(x) (x << 1)<br /><span style="color: #008080; ">15</span> <span style="color: #0000FF; ">#define</span> rc(x) (x << 1 | 1)<br /><span style="color: #008080; ">16</span> <span style="color: #0000FF; ">#define</span> lowbit(x) (x & (-x))<br /><span style="color: #008080; ">17</span> <span style="color: #0000FF; ">#define</span> ll long long<br /><span style="color: #008080; ">18</span> <span style="color: #0000FF; ">#define</span> MAX 10000000<br /><span style="color: #008080; ">19</span> map<ll, <span style="color: #0000FF; ">bool</span>> win;<br /><span style="color: #008080; ">20</span> map<ll, ll> ans;<br /><span style="color: #008080; ">21</span> ll q;<br /><span style="color: #008080; ">22</span> <br /><span style="color: #008080; ">23</span> <span style="color: #0000FF; ">bool</span> dfs(ll x) {<br /><span style="color: #008080; ">24</span>     <span style="color: #0000FF; ">if</span>(win.find(x) == win.end()) {<br /><span style="color: #008080; ">25</span>         <span style="color: #0000FF; ">bool</span> isprime = <span style="color: #0000FF; ">true</span>, WIN = <span style="color: #0000FF; ">false</span>;<br /><span style="color: #008080; ">26</span>         ans[x] = 0;<br /><span style="color: #008080; ">27</span>         <span style="color: #0000FF; ">for</span>(ll i = 2; i * i <= x && !WIN; i++) {<br /><span style="color: #008080; ">28</span>             <span style="color: #0000FF; ">if</span>(x % i == 0) {<br /><span style="color: #008080; ">29</span>                 isprime = <span style="color: #0000FF; ">false</span>;<br /><span style="color: #008080; ">30</span>                 <span style="color: #0000FF; ">if</span>(!dfs(i)) WIN = <span style="color: #0000FF; ">true</span>, ans[x] = i;<br /><span style="color: #008080; ">31</span>                 <span style="color: #0000FF; ">if</span>(WIN) <span style="color: #0000FF; ">break</span>;<br /><span style="color: #008080; ">32</span>                 <span style="color: #0000FF; ">if</span>(!dfs(x / i)) WIN = <span style="color: #0000FF; ">true</span>, ans[x] = x / i;<br /><span style="color: #008080; ">33</span>             }<br /><span style="color: #008080; ">34</span>         }<br /><span style="color: #008080; ">35</span>         win[x] = WIN || isprime;<br /><span style="color: #008080; ">36</span>     } <br /><span style="color: #008080; ">37</span>     <span style="color: #0000FF; ">return</span> win[x];<br /><span style="color: #008080; ">38</span> }<br /><span style="color: #008080; ">39</span> <br /><span style="color: #008080; ">40</span> <span style="color: #0000FF; ">int</span> main() {<br /><span style="color: #008080; ">41</span>     ans.clear(), win.clear();<br /><span style="color: #008080; ">42</span>     <span style="color: #0000FF; ">while</span>(cin >> q) {<br /><span style="color: #008080; ">43</span>         <span style="color: #0000FF; ">if</span>(dfs(q)) cout << 1 << endl << ans[q] << endl;<br /><span style="color: #008080; ">44</span>         <span style="color: #0000FF; ">else</span> cout << 2 << endl;<br /><span style="color: #008080; ">45</span>     }<br /><span style="color: #008080; ">46</span>     <span style="color: #0000FF; ">return</span> 0;<br /><span style="color: #008080; ">47</span> }<br /><span style="color: #008080; ">48</span> </div><img src ="http://www.shnenglu.com/y346491470/aggbug/165943.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/y346491470/" target="_blank">y @ The Angry Teletubbies</a> 2012-02-19 00:32 <a href="http://www.shnenglu.com/y346491470/articles/165943.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>CF 149D - 鍖洪棿dphttp://www.shnenglu.com/y346491470/articles/165484.htmly @ The Angry Teletubbiesy @ The Angry TeletubbiesMon, 13 Feb 2012 06:55:00 GMThttp://www.shnenglu.com/y346491470/articles/165484.htmlhttp://www.shnenglu.com/y346491470/comments/165484.htmlhttp://www.shnenglu.com/y346491470/articles/165484.html#Feedback0http://www.shnenglu.com/y346491470/comments/commentRss/165484.htmlhttp://www.shnenglu.com/y346491470/services/trackbacks/165484.html               緇欏嚭涓変釜鏉′歡錛?br />                  1.姣忎釜鎷彿鍙互涓嶆煋鑹詫紝鏌撹摑鑹叉垨鑰呮煋綰㈣壊錛?br />                  2.鍖歸厤鐨勬嫭鍙峰鏈変笖浠呮湁涓涓煋鑹詫紱
                  3.鐩擱偦鐨勬嫭鍙蜂笉鑳芥煋鐩稿悓鐨勯鑹層?br />               闂紝婊¤凍浠ヤ笂涓変釜鏉′歡鐨勬煋鑹叉柟妗堟湁澶氬皯縐嶃?br />
銆愰瑙c戯細濂芥槑鏄劇殑dp棰橈紝鍥犱負涓鑸繖縐嶆眰鏂規鏁扮殑棰樼洰濡傛灉鐢ㄧ函鏁板鐭ヨ瘑鏉ヨВ鏄В涓嶅嚭鐨勶紝鑰屼笖闄愬埗鏉′歡涓澶у爢銆?br />               璁劇姸鎬乨p[l][r][c1][c2]琛ㄧず[l,r]涔嬮棿涓攍鏌撴垚c1,r鏌撴垚c2鐨勫悎娉曟柟妗堟暟銆?br />               鐒跺悗杞Щ瑕佸垎涓ょ鎯呭喌璁ㄨ錛?.l涓巖鍖歸厤錛?.l涓巖涓嶅尮閰?br />               杞Щ灝辨槸榪愮敤涔樻硶鍘熺悊錛岃鍏堥澶勭悊鎷彿鐨勫尮閰嶆儏鍐點?br />
銆愪唬鐮併戯細
 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "algorithm"
 5 #include "vector"
 6 #include "queue"
 7 #include "cmath"
 8 #include "string"
 9 #include "cctype"
10 #include "map"
11 #include "iomanip"
12 #include "stack"
13 using namespace std;
14 #define pb push_back
15 #define lc(x) (x << 1)
16 #define rc(x) (x << 1 | 1)
17 #define lowbit(x) (x & (-x))
18 #define ll long long
19 #define MAX 710
20 const int MOD = 1000000007;
21 string str;
22 ll dp[MAX][MAX][3][3];
23 int mat[MAX];
24 int s[MAX], top;
25 
26 void pretreatment() {
27     top = 0;
28     for(int i = 0; i < str.length(); i++) {
29         if(str[i] == '(') s[top++] = i;
30         else mat[s[--top]] = i;
31     }
32 }
33 
34 bool check(int a, int b) {
35     if(a == 0 || b == 0 || a != b) return true;
36     return false;
37 }
38 
39 ll func(int l, int r, int c1, int c2) {
40     if(dp[l][r][c1][c2] != -1) return dp[l][r][c1][c2];
41     ll res = 0;
42     if(mat[l] == r) {
43         if((c1 == 0) ^ (c2 == 0)) {
44             if(l + 1 == r) return dp[l][r][c1][c2] = 1;
45             for(int i = 0; i < 3; i++) {
46                 for(int j = 0; j < 3; j++) {
47                     if(check(c1, i) && check(j, c2)) {
48                         res += func(l + 1, r - 1, i, j);
49                     }
50                 }
51             } 
52         } else return dp[l][r][c1][c2] = 0;
53     } else {
54         for(int i = 0; i < 3; i++) {
55             for(int j = 0; j < 3; j++) {
56                 if(check(i, j)) 
57                     res += func(l, mat[l], c1, i) * func(mat[l] + 1, r, j, c2);
58             }
59         }
60     }
61     return dp[l][r][c1][c2] = res % MOD;
62 }
63 
64 int main() {
65     while(cin >> str) {
66         pretreatment();
67         memset(dp, -1, sizeof(dp));
68         ll ans = 0;
69         for(int i = 0; i < 3; i++)
70             for(int j = 0; j < 3; j++)
71                     ans += func(0, str.length() - 1, i, j);
72         cout << ans % MOD << endl;
73     }
74     return 0;
75 }
76 


y @ The Angry Teletubbies 2012-02-13 14:55 鍙戣〃璇勮
]]>
CF 148D - 姒傜巼dphttp://www.shnenglu.com/y346491470/articles/164919.htmly @ The Angry Teletubbiesy @ The Angry TeletubbiesFri, 03 Feb 2012 18:20:00 GMThttp://www.shnenglu.com/y346491470/articles/164919.htmlhttp://www.shnenglu.com/y346491470/comments/164919.htmlhttp://www.shnenglu.com/y346491470/articles/164919.html#Feedback0http://www.shnenglu.com/y346491470/comments/commentRss/164919.htmlhttp://www.shnenglu.com/y346491470/services/trackbacks/164919.html
銆愰瑙c戯細濂芥槑鏄劇殑姒傜巼dp錛屾瘮璧涙椂灞呯劧涓嶅鑳嗗紑錛屾檿浜嗭紝姘村鉤榪樻槸涓嶅銆?br />               浠婂ぉ璁ょ湡鎯充簡涓涓嬶紝鍙戠幇鏄緢綆鍗曠殑姒傜巼dp錛屼簭浜嗐?br />               璁緁[i][j] 琛ㄧず褰撳墠琚嬪瓙鏈?i 鍙櫧榧犲拰 j 鍙粦榧狅紝鍏富鎽稿畬鍚庤儨鍑虹殑鏈虹巼銆?br />                  g[i][j] 琛ㄧず褰撳墠琚嬪瓙鏈?i 鍙櫧榧犲拰 j 鍙粧榧狅紝榫欐懜瀹屽悗鑳滃嚭鐨勬満鐜囥?br />               
               鐘舵佽漿縐?
                     f[i][j] = i / (i + j) + j * (1 - g[i][j-1]) / (i + j);
                     g[i][j] = i / (i + j) + j / (i + j) * (i / (i + j - 1) * (1 - f[i-1][j-1]) + (j - 1) / (i + j - 1) * (1 - f[i][j-2]));

               閫掓帹涓嬈?O(n*n), 絳旀鍗充負f[w][b].

銆愪唬鐮併戯細
 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "algorithm"
 5 #include "vector"
 6 #include "queue"
 7 #include "cmath"
 8 #include "string"
 9 #include "cctype"
10 #include "map"
11 #include "iomanip"
12 using namespace std;
13 #define pb push_back
14 #define lc(x) (x << 1)
15 #define rc(x) (x << 1 | 1)
16 #define lowbit(x) (x & (-x))
17 #define ll long long
18 #define MAX 1005
19 int w, b;
20 double f[MAX][MAX], g[MAX][MAX];
21 int main() {
22     while(cin >> w >> b) {
23         for(int i = 0; i <= b; i++) f[0][i] = 0.0, g[0][i] = 1.0;
24         for(int i = 1; i <= w; i++) f[i][0] = g[i][0] = 1.0;
25         for(int i = 1; i <= w; i++) {
26             for(int j = 1; j <= b; j++) {
27                 double tmp = 0.0;
28                 f[i][j] = 1.0 * i / (i + j) + 1.0 * j * (1 - g[i][j-1]) / (i + j);
29                 if(j >= 2) tmp = 1.0 * (j - 1) / (i + j - 1) * (1 - f[i][j-2]);
30                 g[i][j] = 1.0 * i / (i + j) + 1.0 * j * (i * (1 - f[i-1][j-1]) / (i + j - 1) + tmp) / (i + j);
31             }
32         }
33         printf("%.10f\n", f[w][b]);
34     }
35     return 0;
36 }
37 


y @ The Angry Teletubbies 2012-02-04 02:20 鍙戣〃璇勮
]]>
CF 145C - 紱繪暎dp + 閫嗗厓澶勭悊緇勫悎鏁?/title><link>http://www.shnenglu.com/y346491470/articles/164614.html</link><dc:creator>y @ The Angry Teletubbies</dc:creator><author>y @ The Angry Teletubbies</author><pubDate>Sat, 28 Jan 2012 14:25:00 GMT</pubDate><guid>http://www.shnenglu.com/y346491470/articles/164614.html</guid><wfw:comment>http://www.shnenglu.com/y346491470/comments/164614.html</wfw:comment><comments>http://www.shnenglu.com/y346491470/articles/164614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/y346491470/comments/commentRss/164614.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/y346491470/services/trackbacks/164614.html</trackback:ping><description><![CDATA[銆愰鎰忋戯細緇欏嚭n涓暟錛岄棶浠庤繖n涓暟涓塳涓暟涓鍏辨湁澶氬皯縐嶆柟妗堬紝鍏朵腑涓嶈兘鍖呮嫭涓や釜鐩稿悓鐨刲ucky number(lucky number鎸囨暟浣嶄粎鍖呭惈4鍜?鐨勬暟瀛?,1<=k<=n<=100000.<br /><br />銆愰瑙c戯細鍏堟妸lucky number紱繪暎鍖栵紝鐒跺悗瀵筶ucky number榪涜dp銆?br />               璁綿p[i][j]琛ㄧず鍓?i 縐峫ucky number閫変簡 j 縐嶇殑鏂規鏁般?br />                     dp[i][j] = dp[i-1][j] + dp[i-1][j-1] * c[i],鍏朵腑c[i]琛ㄧず絎?i 縐峫ucky number鐨勪釜鏁般?br />               鐒跺悗ans = ∑C(cnt, i) * dp[luckycnt][k-i], cnt 涓洪潪lucky number鏁扮洰錛宭uckycnt 涓簂ucky number 縐嶇被鏁般?br />               娉ㄦ剰錛岀粍鍚堟暟闇瑕佺敤閫嗗厓澶勭悊銆?br /><br />銆愪唬鐮併戯細<br /><div style="font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; border-image: initial; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; background-color: #eeeeee; "><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> #include "iostream"<br /><span style="color: #008080; "> 2</span> #include "cstdio"<br /><span style="color: #008080; "> 3</span> #include "cstring"<br /><span style="color: #008080; "> 4</span> #include "algorithm"<br /><span style="color: #008080; "> 5</span> #include "vector"<br /><span style="color: #008080; "> 6</span> #include "queue"<br /><span style="color: #008080; "> 7</span> #include "cmath"<br /><span style="color: #008080; "> 8</span> #include "string"<br /><span style="color: #008080; "> 9</span> #include "cctype"<br /><span style="color: #008080; ">10</span> #include "map"<br /><span style="color: #008080; ">11</span> <span style="color: #0000FF; ">using</span> <span style="color: #0000FF; ">namespace</span> std;<br /><span style="color: #008080; ">12</span> <span style="color: #0000FF; ">#define</span> pb push_back<br /><span style="color: #008080; ">13</span> <span style="color: #0000FF; ">#define</span> lc(x) (x << 1)<br /><span style="color: #008080; ">14</span> <span style="color: #0000FF; ">#define</span> rc(x) (x << 1 | 1)<br /><span style="color: #008080; ">15</span> <span style="color: #0000FF; ">#define</span> lowbit(x) (x & (-x))<br /><span style="color: #008080; ">16</span> <span style="color: #0000FF; ">#define</span> ll long long<br /><span style="color: #008080; ">17</span> <span style="color: #0000FF; ">#define</span> maxn 100050<br /><span style="color: #008080; ">18</span> <span style="color: #0000FF; ">const</span> ll MOD = 1000000007LL;<br /><span style="color: #008080; ">19</span> map<<span style="color: #0000FF; ">int</span>, <span style="color: #0000FF; ">int</span>> mp;<br /><span style="color: #008080; ">20</span> <span style="color: #0000FF; ">int</span> n, k;<br /><span style="color: #008080; ">21</span> <span style="color: #0000FF; ">int</span> luckycnt, cnt;<br /><span style="color: #008080; ">22</span> ll dp[1500], c[1500], p[maxn];<br /><span style="color: #008080; ">23</span> <br /><span style="color: #008080; ">24</span> <span style="color: #0000FF; ">void</span> init() {<br /><span style="color: #008080; ">25</span>     memset(c, 0, <span style="color: #0000FF; ">sizeof</span>(c));<br /><span style="color: #008080; ">26</span>     luckycnt = cnt = 0;<br /><span style="color: #008080; ">27</span>     mp.clear();<br /><span style="color: #008080; ">28</span> }<br /><span style="color: #008080; ">29</span> <br /><span style="color: #008080; ">30</span> <span style="color: #0000FF; ">bool</span> check(<span style="color: #0000FF; ">int</span> x) {<br /><span style="color: #008080; ">31</span>     <span style="color: #0000FF; ">while</span>(x) {<br /><span style="color: #008080; ">32</span>         <span style="color: #0000FF; ">if</span>(x % 10 != 4 && x % 10 != 7) <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">false</span>;<br /><span style="color: #008080; ">33</span>         x /= 10;<br /><span style="color: #008080; ">34</span>     }<br /><span style="color: #008080; ">35</span>     <span style="color: #0000FF; ">return</span> <span style="color: #0000FF; ">true</span>;<br /><span style="color: #008080; ">36</span> }<br /><span style="color: #008080; ">37</span> <br /><span style="color: #008080; ">38</span> <span style="color: #0000FF; ">void</span> Gcd(ll a, ll b, ll &d, ll &x, ll &y) {<br /><span style="color: #008080; ">39</span>     <span style="color: #0000FF; ">if</span> (!b) {<br /><span style="color: #008080; ">40</span>         d = a, x = 1, y = 0;<br /><span style="color: #008080; ">41</span>         <span style="color: #0000FF; ">return</span>;<br /><span style="color: #008080; ">42</span>     }<br /><span style="color: #008080; ">43</span>     Gcd(b, a % b, d, y, x);<br /><span style="color: #008080; ">44</span>     y -= x * (a / b);<br /><span style="color: #008080; ">45</span> }<br /><span style="color: #008080; ">46</span> <br /><span style="color: #008080; ">47</span> ll inv(ll a, ll n) {<br /><span style="color: #008080; ">48</span>     ll d, x, y;<br /><span style="color: #008080; ">49</span>     Gcd(a, n, d, x, y);<br /><span style="color: #008080; ">50</span>     <span style="color: #0000FF; ">if</span> (d == 1) <span style="color: #0000FF; ">return</span> (x % n + n) % n;<br /><span style="color: #008080; ">51</span>     <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">return</span> -1;<br /><span style="color: #008080; ">52</span> }<br /><span style="color: #008080; ">53</span> <br /><span style="color: #008080; ">54</span> ll C(ll n, ll m) {<br /><span style="color: #008080; ">55</span>     <span style="color: #0000FF; ">if</span>(m == 0) <span style="color: #0000FF; ">return</span> 1;<br /><span style="color: #008080; ">56</span>     <span style="color: #0000FF; ">if</span>(m > n) <span style="color: #0000FF; ">return</span> 0;<br /><span style="color: #008080; ">57</span>     ll res = (p[n] * inv(p[m], MOD)) % MOD;<br /><span style="color: #008080; ">58</span>     res = (res * inv(p[n-m], MOD)) % MOD;<br /><span style="color: #008080; ">59</span>     <span style="color: #0000FF; ">return</span> res;<br /><span style="color: #008080; ">60</span> }<br /><span style="color: #008080; ">61</span> <br /><span style="color: #008080; ">62</span> <span style="color: #0000FF; ">void</span> solve() {<br /><span style="color: #008080; ">63</span>     memset(dp, 0, <span style="color: #0000FF; ">sizeof</span>(dp));<br /><span style="color: #008080; ">64</span>     dp[0] = 1;<br /><span style="color: #008080; ">65</span>     <span style="color: #0000FF; ">for</span>(<span style="color: #0000FF; ">int</span> i = 1; i <= luckycnt; i++)<br /><span style="color: #008080; ">66</span>         <span style="color: #0000FF; ">for</span>(<span style="color: #0000FF; ">int</span> j = i; j; j--)<br /><span style="color: #008080; ">67</span>             dp[j] = (dp[j] + dp[j-1] * c[i]) % MOD;<br /><span style="color: #008080; ">68</span>     ll ans = 0;<br /><span style="color: #008080; ">69</span>     <span style="color: #0000FF; ">for</span>(<span style="color: #0000FF; ">int</span> i = 0; i <= k && i <= cnt; i++) {<br /><span style="color: #008080; ">70</span>         <span style="color: #0000FF; ">if</span>(k - i > luckycnt) <span style="color: #0000FF; ">continue</span>;<br /><span style="color: #008080; ">71</span>         ans = (ans + C(cnt, i) * dp[k-i]) % MOD;<br /><span style="color: #008080; ">72</span>     }<br /><span style="color: #008080; ">73</span>     cout << ans << endl;<br /><span style="color: #008080; ">74</span> }<br /><span style="color: #008080; ">75</span> <br /><span style="color: #008080; ">76</span> <span style="color: #0000FF; ">int</span> main() {<br /><span style="color: #008080; ">77</span>     p[0] = 1;<br /><span style="color: #008080; ">78</span>     <span style="color: #0000FF; ">for</span>(<span style="color: #0000FF; ">int</span> i = 1; i < maxn; i++) p[i] = (p[i-1] * i) % MOD;<br /><span style="color: #008080; ">79</span>     <span style="color: #0000FF; ">while</span>(cin >> n >> k) {<br /><span style="color: #008080; ">80</span>         init();<br /><span style="color: #008080; ">81</span>         <span style="color: #0000FF; ">for</span>(<span style="color: #0000FF; ">int</span> i = 0, val; i < n; i++) {<br /><span style="color: #008080; ">82</span>             cin >> val;<br /><span style="color: #008080; ">83</span>             <span style="color: #0000FF; ">if</span>(check(val)) {<br /><span style="color: #008080; ">84</span>                 <span style="color: #0000FF; ">if</span>(mp.find(val) == mp.end()) mp[val] = ++luckycnt;<br /><span style="color: #008080; ">85</span>                 c[mp[val]]++;<br /><span style="color: #008080; ">86</span>             } <span style="color: #0000FF; ">else</span> cnt++;<br /><span style="color: #008080; ">87</span>         }<br /><span style="color: #008080; ">88</span>         solve();<br /><span style="color: #008080; ">89</span>     }<br /><span style="color: #008080; ">90</span>     <span style="color: #0000FF; ">return</span> 0;<br /><span style="color: #008080; ">91</span> }<br /><span style="color: #008080; ">92</span> </div><img src ="http://www.shnenglu.com/y346491470/aggbug/164614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/y346491470/" target="_blank">y @ The Angry Teletubbies</a> 2012-01-28 22:25 <a href="http://www.shnenglu.com/y346491470/articles/164614.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.ghmsgs.cn" target="_blank">很黄很污的网站久久mimi色 </a>| <a href="http://www.dm233.cn" target="_blank">久久精品人人槡人妻人人玩AV</a>| <a href="http://www.inconfont.cn" target="_blank">av无码久久久久不卡免费网站 </a>| <a href="http://www.hao266.cn" target="_blank">久久人人爽人人爽人人片AV不</a>| <a href="http://www.youk6.cn" target="_blank">亚洲欧美另类日本久久国产真实乱对白</a>| <a href="http://www.zzyes.cn" target="_blank">久久免费视频网站</a>| <a href="http://www.114best.com.cn" target="_blank">久久久久久毛片免费播放</a>| <a href="http://www.wubaili.com.cn" target="_blank">国产毛片欧美毛片久久久</a>| <a href="http://www.ihi7113575.cn" target="_blank">国内精品伊人久久久影院</a>| <a href="http://www.iceplaza.cn" target="_blank">一本久久a久久精品综合香蕉</a>| <a href="http://www.worktrotter.cn" target="_blank">国产激情久久久久影院小草</a>| <a href="http://www.yixue77.cn" target="_blank">66精品综合久久久久久久</a>| <a href="http://www.ha-jc.cn" target="_blank">中文字幕亚洲综合久久2</a>| <a href="http://www.lenticular3d.cn" target="_blank">久久精品国产99国产精品澳门</a>| <a href="http://www.jsjdzz.cn" target="_blank">99久久99久久久精品齐齐</a>| <a href="http://www.qdog.com.cn" target="_blank">国内精品久久久久影院优</a>| <a href="http://www.bjhswt.com.cn" target="_blank">人妻精品久久无码区</a>| <a href="http://www.obsessions.cn" target="_blank">久久99精品国产麻豆</a>| <a href="http://www.bosot.cn" target="_blank">国产叼嘿久久精品久久</a>| <a href="http://www.zhoucheng888.cn" target="_blank">久久亚洲精品无码播放</a>| <a href="http://www.qhylhsk.cn" target="_blank">久久久久久久久久久久久久</a>| <a href="http://www.lebow01.cn" target="_blank">久久午夜伦鲁片免费无码</a>| <a href="http://www.dogff.cn" target="_blank">久久香蕉综合色一综合色88</a>| <a href="http://www.789ff.cn" target="_blank">久久久久久久亚洲精品</a>| <a href="http://www.linux123.cn" target="_blank">综合人妻久久一区二区精品</a>| <a href="http://www.epcinet.cn" target="_blank">久久久久久国产精品无码超碰</a>| <a href="http://www.t421.cn" target="_blank">51久久夜色精品国产</a>| <a href="http://www.cs556.cn" target="_blank">欧美日韩精品久久久久</a>| <a href="http://www.yangshuohappy.cn" target="_blank">久久婷婷五月综合97色</a>| <a href="http://www.510dpw.cn" target="_blank">精品九九久久国内精品</a>| <a href="http://www.hx0451.cn" target="_blank">色综合久久天天综线观看</a>| <a href="http://www.bjxisaa.cn" target="_blank">色妞色综合久久夜夜</a>| <a href="http://www.wodedaxue.com.cn" target="_blank">狠狠色丁香久久综合婷婷</a>| <a href="http://www.v1175.cn" target="_blank">中文精品99久久国产</a>| <a href="http://www.deshizhai.cn" target="_blank">国产精品美女久久久久久2018</a>| <a href="http://www.mijie5.cn" target="_blank">久久久久久青草大香综合精品</a>| <a href="http://www.fuxingjiguang.cn" target="_blank">97精品伊人久久久大香线蕉</a>| <a href="http://www.u3h1.cn" target="_blank">91久久福利国产成人精品</a>| <a href="http://www.byvet.com.cn" target="_blank">欧美久久一区二区三区</a>| <a href="http://www.szsantong.com.cn" target="_blank">99久久人妻无码精品系列 </a>| <a href="http://www.aving.com.cn" target="_blank">青青草原综合久久大伊人导航</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>