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

HDOJ 5031 Lines

編輯:C++入門知識

HDOJ 5031 Lines



枚舉角度DFS。。。。

Lines

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 479 Accepted Submission(s): 140


Problem Description You play a game with your friend. He draws several lines on the paper with n×m square grids (see the left figure). After that, he writes down the number of lines passing through every integer coordinate in a matrix (see the right figure).

\

The number of lines passing though coordinate (i,j) is written in cell (i,j) in the right figure.(i,j both start from 0).

You are given the matrix written by your friend. You need to figure out the possible minimal number of lines your friend drew on the paper.
Input The first line of the input contains an integer T indicating the number of test cases( 0 < T <= 10).

FZ喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vciBlYWNoIHRlc3QgY2FzZSwgdGhlIGZpcnN0IGxpbmUgY29udGFpbnMgdHdvIGludGVnZXJzIG4sIG0gKDEgodwgbiwgbSCh3CA1MCkgcmVwcmVzZW50aW5nIHRoZSBzaXplIG9mIHRoZSBncmlkcyBvbiB0aGUgcGFwZXIuIFRoZSBmb2xsb3dpbmcgKG4mIzQzOzEpIKHBIChtJiM0MzsxKSBudW1iZXJzIGlzIHdoYXQgeW91ciBmcmllbmQgd3JpdGVzLiBJdCBpcyBndWFyYW50ZWVkIHRoYXQgdGhlIG51bWJlciBvZiBsaW5lcyB5b3VyIGZyaWVuZCBkcmF3cyBkb2VzIG5vdAogZXhjZWVkIDE0LiBFYWNoIGxpbmUgcGFzc2VzIHRocm91Z2ggaW50ZWdlciBjb29yZGluYXRlcyBhdCBsZWFzdCB0aHJlZSB0aW1lcy4KCiAKPGJyPgoKT3V0cHV0CgpGb3IgZWFjaCB0ZXN0IGNhc2UsIHlvdSBuZWVkIHRvIG91dHB1dCB0aGUgbWluaW1hbCBudW1iZXIgb2YgbGluZXMgeW91ciBmcmllbmQgZHJldyBvbiB0aGUgcGFwZXIgaW4gYSBzaW5nbGUgbGluZS4KCiAKPGJyPgoKU2FtcGxlIElucHV0Cgo8cHJlIGNsYXNzPQ=="brush:java;">1 5 4 0 1 0 0 1 0 1 0 1 0 2 1 1 0 0 0 3 1 0 0 1 1 1 0 1 0 1 0 1 0
Sample Output
4

Source 2014 ACM/ICPC Asia Regional Guangzhou Online


#include 
#include 
#include 
#include 
#include 

using namespace std;

map DB;
int n,m,ans;
int mp[60][60];

inline bool is_in(int x,int y)
{
	if(x>=0&&x=0&y=ans) return ;
	if(remain==0)
	{
		ans=min(ans,deep);
		return ;
	}
	bool flag=false;
	for(int i=0;i



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