码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces400A - Inna and Choose Options 暴力

时间:2014-07-24 10:16:23      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   

题意:给你12张只包含X 和O的牌,问你n*m = 12 中,每一列都是X的情况有几种: 谁把这题定为DP题信不信我砍死你。

解题思路:我愚蠢的暴力

解题代码:

bubuko.com,布布扣
  1 // File Name: 400a.cpp
  2 // Author: darkdream
  3 // Created Time: 2014年07月24日 星期四 08时48分04秒
  4 
  5 #include<vector>
  6 #include<list>
  7 #include<map>
  8 #include<set>
  9 #include<deque>
 10 #include<stack>
 11 #include<bitset>
 12 #include<algorithm>
 13 #include<functional>
 14 #include<numeric>
 15 #include<utility>
 16 #include<sstream>
 17 #include<iostream>
 18 #include<iomanip>
 19 #include<cstdio>
 20 #include<cmath>
 21 #include<cstdlib>
 22 #include<cstring>
 23 #include<ctime>
 24 
 25 using namespace std;
 26 char str[100];
 27 int is(int i , int j )
 28 {
 29    for(int k = i;k <= 12;k += j)
 30    {
 31       if(str[k] == O)
 32           return 0;
 33    }
 34    return 1 ; 
 35 }
 36 int main(){
 37     int n;
 38     scanf("%d",&n);
 39     for(int i =1;i<= n; i ++)
 40     {    
 41         scanf("%s",&str[1]);
 42         int sum = 0 ;
 43         int ok ; 
 44         ok = 0;
 45         int a[10] = {0};
 46         for(int i =1;i <= 1;i ++)
 47         {
 48            if(is(i,1))
 49                ok = 1 ; 
 50         }
 51         if(ok)
 52             a[1]++ ;
 53         sum += ok ;
 54         ok = 0;
 55         for(int i =1;i <= 2;i += 1)
 56         {
 57            if(is(i,2))
 58                ok = 1 ; 
 59         }
 60         if(ok)
 61             a[2]++ ;
 62         sum += ok ;
 63         ok = 0;
 64         for(int i =1;i <= 3;i +=1)
 65         {
 66            if(is(i,3))
 67                ok = 1 ; 
 68         }
 69         if(ok)
 70             a[3]++ ;
 71         sum += ok ;
 72         ok = 0;
 73         for(int i =1;i <= 4;i ++)
 74         {
 75            if(is(i,4))
 76                ok = 1 ; 
 77         }
 78         if(ok)
 79             a[4]++ ;
 80         sum += ok ;
 81         ok = 0;
 82         for(int i =1;i <= 6;i ++)
 83         {
 84            if(is(i,6))
 85                ok = 1 ; 
 86         }
 87         if(ok)
 88             a[5]++ ;
 89         sum += ok ;
 90         ok = 0;
 91         for(int i =1;i <= 12;i ++ )
 92         {
 93            if(is(i,12))
 94                ok = 1 ; 
 95         }
 96         if(ok)
 97             a[6]++ ;
 98         sum += ok ;
 99         printf("%d ",sum);
100         if(a[6])
101             printf("1x12 ");
102         if(a[5])
103             printf("2x6 ");
104         if(a[4])
105             printf("3x4 ");
106         if(a[3])
107             printf("4x3 ");
108         if(a[2])
109             printf("6x2 ");
110         if(a[1])
111             printf("12x1 ");
112         printf("\n");
113     }     
114 return 0;
115 }
View Code

codeforces400A - Inna and Choose Options 暴力,布布扣,bubuko.com

codeforces400A - Inna and Choose Options 暴力

标签:style   blog   http   color   os   io   

原文地址:http://www.cnblogs.com/zyue/p/3864788.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!