日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UESTC 1851 Kings on a Chessboard

發(fā)布時間:2024/6/14 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UESTC 1851 Kings on a Chessboard 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
狀壓DP。。。

Kings on a Chessboard

Time Limit:?10000msMemory Limit:?65535KBThis problem will be judged on UESTC. Original ID:?1851
64-bit integer IO format:?%lld????? Java class name:?MainPrev?Submit?Status?Statistics?Discuss?NextFont Size:?+?-Type:??None?Graph Theory?????2-SAT?????Articulation/Bridge/Biconnected Component?????Cycles/Topological Sorting/Strongly Connected Component?????Shortest Path?????????Bellman Ford?????????Dijkstra/Floyd Warshall?????Euler Trail/Circuit?????Heavy-Light Decomposition?????Minimum Spanning Tree?????Stable Marriage Problem?????Trees?????Directed Minimum Spanning Tree?????Flow/Matching?????????Graph Matching?????????????Bipartite Matching?????????????Hopcroft–Karp Bipartite Matching?????????????Weighted Bipartite Matching/Hungarian Algorithm?????????Flow?????????????Max Flow/Min Cut?????????????Min Cost Max Flow?DFS-like?????Backtracking with Pruning/Branch and Bound?????Basic Recursion?????IDA* Search?????Parsing/Grammar?????Breadth First Search/Depth First Search?????Advanced Search Techniques?????????Binary Search/Bisection?????????Ternary Search?Geometry?????Basic Geometry?????Computational Geometry?????Convex Hull?????Pick's Theorem?Game Theory?????Green Hackenbush/Colon Principle/Fusion Principle?????Nim?????Sprague-Grundy Number?Matrix?????Gaussian Elimination?????Matrix Exponentiation?Data Structures?????Basic Data Structures?????Binary Indexed Tree?????Binary Search Tree?????Hashing?????Orthogonal Range Search?????Range Minimum Query/Lowest Common Ancestor?????Segment Tree/Interval Tree?????Trie Tree?????Sorting?????Disjoint Set?String?????Aho Corasick?????Knuth-Morris-Pratt?????Suffix Array/Suffix Tree?Math?????Basic Math?????Big Integer Arithmetic?????Number Theory?????????Chinese Remainder Theorem?????????Extended Euclid?????????Inclusion/Exclusion?????????Modular Arithmetic?????Combinatorics?????????Group Theory/Burnside's lemma?????????Counting?????Probability/Expected Value?Others?????Tricky?????Hardest?????Unusual?????Brute Force?????Implementation?????Constructive Algorithms?????Two Pointer?????Bitmask?????Beginner?????Discrete Logarithm/Shank's Baby-step Giant-step Algorithm?????Greedy?????Divide and Conquer?Dynamic Programming? ? ?? ?? ?? ?? ???Tag it!

You are given a chessboard of size x * y and k identical kings, and are asked to place all the kings on the board such that no two kings can attack each other. Two kings can attack each other if they are horizontally, vertically or diagonally adjacent.
Write a computer program that calculates the number of possible arrangements of the k kings on the given chessboard. Since the number of feasible arrangements may be large, reduce the number modulo 1,000,000,007.

Input

The first line of the input consists of a single integer T, the number of test cases. Each of the following T lines consists of three integers x; y and k,separated by one space.

0 < T <= 50
2 <= x; y <= 15
1 <= k <= x*y

Output

For each test case, output the number of possibilities modulo 1,000,000,007.

Sample Input

4
8 8 1
7 7 16
7 7 7
3 7 15

Sample Output

64
1
2484382
0

Source

IDI Open 2013 Programming Contest


#include?<iostream>
#include?<cstdio>
#include?<cstring>

using?namespace?std;

const?int?MOD=1000000007;

inline?bool?legal(int?x,int?y)?{return?x&y;}
long?long?int?dp[16][1600][250];
int?r,c,nums,state[1600],people[1600],kth;

bool?isOK(int?xia,int?shang)
{
????int?x=state[xia],y=state[shang];
????if(legal(x,y))?return?false;
????if(legal(x<<1,y)||legal(x>>1,y))?return?false;
????return?true;
}

int?main()
{
????int?t;
????scanf("%d",&t);
????while(t--)
????{
????????memset(dp,0,sizeof(dp));
????????scanf("%d%d%d",&r,&c,&kth);
????????if(kth>(r+1)/2*(c+1)/2)
????????{
????????????puts("0");
????????????continue;
????????}
????????if(c>r)?swap(r,c);
????????///zuangtai
????????nums=0;
????????memset(state,0,sizeof(state));
????????memset(people,0,sizeof(people));
????????for(int?i=0;i<(1<<c);i++)
????????{
????????????if(legal(i,i<<1)||legal(i,i>>1))?continue;
????????????state[nums]=i;
????????????int?k=i;
????????????while(k)
????????????{
????????????????if(k&1)?people[nums]++;
????????????????k=k>>1;
????????????}
????????????nums++;
????????}
????????///the?firstline
????????for(int?i=0;i<nums;i++)
????????{
????????????dp[1][people]=1;
????????}
????????for(int?i=2;i<=r;i++)
????????{
????????????for(int?j=0;j<nums;j++)
????????????{
????????????????for(int?k=0;k<nums;k++)
????????????????{
????????????????????if(!isOK(j,k))?continue;
????????????????????for(int?l=people[k];l<250;l++)
????????????????????{
????????????????????????if(l+people[j]<250)
????????????????????????????dp[j][l+people[j]]=(dp[j][l+people[j]]+dp[i-1][k][l])%MOD;
????????????????????}
????????????????}
????????????}
????????}
????????long?long?int?ans=0;
????????for(int?j=0;j<nums;j++)
????????{
????????????ans=(ans+dp
[j][kth])%MOD;
????????}
????????printf("%lld\n",ans%MOD);
????}
????return?0;
}
* This source code was highlighted by?YcdoiT. ( style: Codeblocks )

轉(zhuǎn)載于:https://www.cnblogs.com/CKboss/p/3350829.html

總結(jié)

以上是生活随笔為你收集整理的UESTC 1851 Kings on a Chessboard的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: www.天天操.com | 97超碰免费在线观看 | 97se在线 | 成人在线网站 | 色综合久久久久综合体桃花网 | 亚洲av无码精品一区二区 | 人妻少妇偷人精品无码 | 91久久精品视频 | 黄色网页在线看 | 天天干天天日 | 亚洲成年网 | 久久综合色视频 | 黄频在线播放 | 色婷婷国产精品久久包臀 | 影音先锋中文在线 | 中文字幕av网 | 国产欧美二区 | 欧美大片在线 | 99热r | 不卡在线一区 | 蜜桃成人无码区免费视频网站 | 国产精品久久国产精品 | 五月天丁香社区 | 校园伸入裙底揉捏1v1h | 午夜精品久久久久久久四虎美女版 | 日韩综合色 | 午夜免费剧场 | 免费啪视频| 尤物视频最新网址 | 欧美成人午夜剧场 | 久久精品视频中文字幕 | 夜夜骑夜夜操 | 婷婷色综合网 | 中文字幕视频在线观看 | 欧美日韩一区二区三区四区五区六区 | 欧美日韩国产大片 | 95看片淫黄大片一级 | 夜晚福利视频 | 黑人添美女bbb添高潮了 | 99操| 午夜精品欧美 | 精品免费观看 | 高跟鞋av | a成人在线| 成人日韩在线观看 | 国产黄色在线网站 | 亚洲二区视频 | 亚洲av无码久久精品狠狠爱浪潮 | 久久精选 | 人妻大战黑人白浆狂泄 | 欧美一级淫片aaaaaa | 亚洲视频一区二区三区 | 欧美在线观看视频一区二区 | 国产99久久久国产精品成人免费 | 三上悠亚一区二区三区 | 欧美日韩a级片 | 51精品国产人成在线观看 | 成人免费网站视频 | 欧美日韩精品中文字幕 | 泽村玲子av | 午夜在线观看一区 | 国产极品尤物 | 中文字幕一区二区三三 | 秋霞av在线 | 在线不卡免费av | 福利网站在线观看 | 人妻互换一区二区激情偷拍 | 少妇久久久久 | 一级少妇精品久久久久久久 | 操操日日 | 91超碰在线 | 久久中文字幕人妻熟av女蜜柚m | 日韩av毛片在线观看 | 久久久黄色 | 少妇激情在线 | 色撸撸在线视频 | 色小妹av | 高清亚洲| 不卡影院 | 奇米影视中文字幕 | 一区二区国产精品精华液 | av卡一卡二 | 欧美在线一区二区三区四区 | 黄视频在线观看免费 | 好色av| 轮乱| 少妇人妻偷人精品视频蜜桃 | 无码毛片aaa在线 | 国产精品va在线观看无码 | 亚洲天堂男人av | 国产一级片自拍 | 91视频国产一区 | 97se在线视频 | 真实的国产乱xxxx在线 | 亚洲免费影视 | 疯狂做受xxxx国产 | 亚洲人人夜夜澡人人爽 | 国产成人一区二区三区小说 | 成人亚洲玉足脚交系列 |