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