【数学规律】Vijos P1582 笨笨的L阵游戏

题目链接:

  https://vijos.org/p/1582

题目大意

  就是o(o<=50)个人在n*m(n,m<=2000)的格子上放L型的东西(有点像俄罗斯方块的L,可对称旋转),问第几个人覆盖全图或无解。

题目思路:

  【数学】

  n*m%8如果为0则(n*m/4-1)%o+1那个人胜利。

  否则无解。

  (当时手画了大概8以内的几种样例,就感觉好像有规律可循,慢慢推但是感觉可能有错,于是偷偷瞄了一眼别人的题解,果然是规律题。但是我并不会证明。)

 

 1 //
 2 //by coolxxx
 3 //
 4 #include<iostream>
 5 #include<algorithm>
 6 #include<string>
 7 #include<iomanip>
 8 #include<memory.h>
 9 #include<time.h>
10 #include<stdio.h>
11 #include<stdlib.h>
12 #include<string.h>
13 #include<stdbool.h>
14 #include<math.h>
15 #define min(a,b) ((a)<(b)?(a):(b))
16 #define max(a,b) ((a)>(b)?(a):(b))
17 #define abs(a) ((a)>0?(a):(-(a)))
18 #define lowbit(a) (a&(-a))
19 #define sqr(a) (a)*(a)
20 #define swap(a,b) (a)^=(b),(b)^=(a),(a)^=(b)
21 #define eps 1e-8
22 #define MAX 0x7f7f7f7f
23 #define INF 20000
24 #define PI 3.1415926535897
25 #define N 54
26 using namespace std;
27 int n,m,lll,ans,cas;
28 char c[N][N];
29 int main()
30 {
31     #ifndef ONLINE_JUDGE
32 //    freopen("1.txt","r",stdin);
33 //    freopen("2.txt","w",stdout);
34     #endif
35     int i,j;
36     while(~scanf("%d",&cas) && cas)
37     {
38         scanf("%d%d",&n,&m);
39         for(i=1;i<=cas;i++)
40             scanf("%s",c[i]);
41         if(n<2 || m<2 || n*m%8!=0)puts("Nobody can win!");
42         else printf("%s can win!\n",c[(m*n/4+cas-1)%cas+1]);
43     }
44     return 0;
45 }
46 
47 
48 /*
49 //
50 
51 //
52 */
View Code

 

posted @ 2016-03-30 00:57  Cool639zhu  阅读(288)  评论(0编辑  收藏  举报