UVA - 11806
Cheerleaders Time Limit: 2000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit Status
Description
C
Cheerleaders
In most professional sporting events, cheerleaders play a major role in entertaining the spectators. Their roles are substantial during breaks and prior to start of play. The world cup soccer is no exception. Usually the cheerleaders form a group and perform at the centre of the field. In addition to this group, some of them are placed outside the side line so they are closer to the spectators. The organizers would like to ensure that at least one cheerleader is located on each of the four sides. For this problem, we will model the playing ground as an M*N rectangular grid. The constraints for placing cheerleaders are described below:
§ There should be at least one cheerleader on each of the four sides. Note that, placing a cheerleader on a corner cell would cover two sides simultaneously.
§ There can be at most one cheerleader in a cell.
§ All the cheerleaders available must be assigned to a cell. That is, none of them can be left out.
The organizers would like to know, how many ways they can place the cheerleaders while maintaining the above constraints. Two placements are different, if there is at least one cell which contains a cheerleader in one of the placement but not in the other. <喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+IDwvcD4KPHA+IDwvcD4KPHA+PHN0cm9uZz4gPC9zdHJvbmc+PC9wPgo8cD48c3Ryb25nPklucHV0PC9zdHJvbmc+PC9wPgo8cD48c3Ryb25nPiA8L3N0cm9uZz48L3A+CjxwPlRoZSBmaXJzdCBsaW5lIG9mIGlucHV0IGNvbnRhaW5zIGEgcG9zaXRpdmUgaW50ZWdlciA8c3Ryb25nPlQ8PTUwPC9zdHJvbmc+LCB3aGljaCBkZW5vdGVzIHRoZSBudW1iZXIgb2YgdGVzdCBjYXNlcy4gPHN0cm9uZz5UPC9zdHJvbmc+IGxpbmVzIHRoZW4gZm9sbG93IGVhY2ggZGVzY3JpYmluZyBvbmUgdGVzdCBjYXNlLiBFYWNoIGNhc2UgY29uc2lzdHMgb2YgdGhyZWUgbm9ubmVnYXRpdmUgaW50ZWdlcnMsIDxzdHJvbmc+Mjw9TSwgTjw9MjA8L3N0cm9uZz4gYW5kIDxzdHJvbmc+Szw9NTAwPC9zdHJvbmc+LgogSGVyZSA8c3Ryb25nPk08L3N0cm9uZz4gaXMgdGhlIG51bWJlciBvZiByb3dzIGFuZCA8c3Ryb25nPk48L3N0cm9uZz4gaXMgdGhlIG51bWJlciBvZiBjb2x1bW5zIGluIHRoZSBncmlkLiA8c3Ryb25nPks8L3N0cm9uZz5kZW5vdGVzIHRoZSBudW1iZXIgb2YgY2hlZXJsZWFkZXJzIHRoYXQgbXVzdCBiZSBhc3NpZ25lZCB0byB0aGUgY2VsbHMgaW4gdGhlIGdyaWQuPC9wPgo8cD48c3Ryb25nPiA8L3N0cm9uZz48L3A+CjxwPjxzdHJvbmc+IDwvc3Ryb25nPjwvcD4KPHA+PHN0cm9uZz5PdXRwdXQ8L3N0cm9uZz48L3A+CjxwPiA8L3A+CjxwPkZvciBlYWNoIGNhc2Ugb2YgaW5wdXQsIHRoZXJlIHdpbGwgYmUgb25lIGxpbmUgb2Ygb3V0cHV0LiBJdCB3aWxsIGZpcnN0IGNvbnRhaW4gdGhlIGNhc2UgbnVtYmVyIGZvbGxvd2VkIGJ5IHRoZSBudW1iZXIgb2Ygd2F5cyB0byBwbGFjZSB0aGUgY2hlZXJsZWFkZXJzIGFzIGRlc2NyaWJlZCBlYXJsaWVyLiBMb29rIGF0IHRoZSBzYW1wbGUgb3V0cHV0IGZvciBleGFjdCBmb3JtYXR0aW5nLiBOb3RlIHRoYXQsIHRoZSBudW1iZXJzIGNhbiBiZSBhcmJpdHJhcmlseQogbGFyZ2UuIFRoZXJlZm9yZSB5b3UgbXVzdCBvdXRwdXQgdGhlIGFuc3dlcnMgbW9kdWxvIDxzdHJvbmc+MTAwMDAwNzwvc3Ryb25nPi48L3A+CjxwPiA8L3A+Cjx0YWJsZSBib3JkZXI9"1" cellspacing="0" cellpadding="0">
Sample Input
Sample Output
2
2 2 1
2 3 2
Case 1: 0
Case 2: 2
Source
AC代碼:
#include#include #include using namespace std; const int MOD = 1000007; const int MAXK = 500; int C[MAXK+10][MAXK+10]; int main() { memset(C, 0, sizeof(C)); C[0][0] = 1; for(int i=0; i <= MAXK; i++) { C[i][0] = C[i][i] = 1; for(int j=1; j