csuoj 1395: Timebomb
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1395
1395: Timebomb
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 139 Solved: 55
[Submit][Status][Web Board]
Description
Input
Output
Sample Input
*** * * * *** *** *** ***
* * * * * * * * *
* * * *** *** *** *** ***
* * * * * * * * *
*** * * *** *** *** ***
Sample Output
BEER!!
HINT
Source
分析:
直接写就ok啦,最后能整除6就“BEER” , 否则“BOOM”.
AC代码:
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<queue> 5 #include<iostream> 6 #include<stack> 7 #include<map> 8 #include<string> 9 using namespace std; 10 char ch[6][50]; 11 int main(){ 12 int n; 13 while(gets(ch[0])){ 14 for(int i = 1; i < 5; i++){ 15 gets(ch[i]); 16 } 17 int l = strlen(ch[0]); 18 int sum = 0; 19 for(int i = 0; i < l; i+=4){ 20 //printf("%s\n", ch[i]); 21 int num = 0; 22 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 23 &&ch[1][i]=='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 24 &&ch[2][i]=='*' && ch[2][i+1]!='*' && ch[2][i+2]=='*' 25 &&ch[3][i]=='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 26 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 27 ){ 28 num = 0; 29 } 30 if(ch[0][i]!='*' && ch[0][i+1]!='*' && ch[0][i+2]=='*' 31 &&ch[1][i]!='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 32 &&ch[2][i]!='*' && ch[2][i+1]!='*' && ch[2][i+2]=='*' 33 &&ch[3][i]!='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 34 &&ch[4][i]!='*' && ch[4][i+1]!='*' && ch[4][i+2]=='*' 35 ){ 36 num = 1; 37 } 38 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 39 &&ch[1][i]!='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 40 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 41 &&ch[3][i]=='*' && ch[3][i+1]!='*' && ch[3][i+2]!='*' 42 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 43 ){ 44 num = 2; 45 } 46 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 47 &&ch[1][i]!='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 48 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 49 &&ch[3][i]!='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 50 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 51 ){ 52 num = 3; 53 } 54 if(ch[0][i]=='*' && ch[0][i+1]!='*' && ch[0][i+2]=='*' 55 &&ch[1][i]=='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 56 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 57 &&ch[3][i]!='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 58 &&ch[4][i]!='*' && ch[4][i+1]!='*' && ch[4][i+2]=='*' 59 ){ 60 num = 4; 61 } 62 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 63 &&ch[1][i]=='*' && ch[1][i+1]!='*' && ch[1][i+2]!='*' 64 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 65 &&ch[3][i]!='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 66 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 67 ){ 68 num = 5; 69 } 70 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 71 &&ch[1][i]=='*' && ch[1][i+1]!='*' && ch[1][i+2]!='*' 72 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 73 &&ch[3][i]=='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 74 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 75 ){ 76 num = 6; 77 } 78 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 79 &&ch[1][i]!='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 80 &&ch[2][i]!='*' && ch[2][i+1]!='*' && ch[2][i+2]=='*' 81 &&ch[3][i]!='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 82 &&ch[4][i]!='*' && ch[4][i+1]!='*' && ch[4][i+2]=='*' 83 ){ 84 num = 7; 85 } 86 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 87 &&ch[1][i]=='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 88 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 89 &&ch[3][i]=='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 90 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 91 ){ 92 num = 8; 93 } 94 if(ch[0][i]=='*' && ch[0][i+1]=='*' && ch[0][i+2]=='*' 95 &&ch[1][i]=='*' && ch[1][i+1]!='*' && ch[1][i+2]=='*' 96 &&ch[2][i]=='*' && ch[2][i+1]=='*' && ch[2][i+2]=='*' 97 &&ch[3][i]!='*' && ch[3][i+1]!='*' && ch[3][i+2]=='*' 98 &&ch[4][i]=='*' && ch[4][i+1]=='*' && ch[4][i+2]=='*' 99 ){ 100 num = 9; 101 } 102 sum *= 10; 103 sum += num; 104 } 105 if(sum % 6 == 0){ 106 printf("BEER!!\n"); 107 } 108 else 109 printf("BOOM!!\n"); 110 } 111 112 return 0; 113 }
悠游天地间 all rights reserved. © 2013 -- 1 << 64