zoukankan      html  css  js  c++  java
  • HDU 5228

     1 #include<stdio.h>
     2 #include<string.h>
     3 int hash[4*13];
     4 int main(){
     5     int t;
     6     scanf("%d",&t);
     7     while(t--){
     8         char ch;
     9         int num;
    10         memset(hash,0,sizeof(hash));
    11         for(int i = 0;i<5;i++){
    12             scanf(" %c",&ch);
    13             scanf("%d",&num);
    14             num--;//下标要从0开始 
    15             hash[4*num+ch-'A']++;//hash,0-->1A,1-->1B,2-->1C......
    16         }
    17         int ans = 5;
    18         for(int i = 0;i<10;i++){//下标到9就好了,因为k会枚举后面4个的 
    19             for(int j = 0;j<4;j++){
    20                 int temp = 5;
    21                 for(int k = 0;k<5;k++){
    22                     int index = (i+k)*4+j;
    23                     if(hash[index%(13*4)])//这里取余是当枚举到13A、13B的时候,取余回到1A、1B... 
    24                         temp--;
    25                 }
    26                 ans = ans<temp?ans:temp;
    27             }
    28         }
    29         printf("%d
    ",ans);
    30     }
    31     return 0;
    32 } 
  • 相关阅读:
    9.8
    9.6
    9.5
    树状数组
    逆序对
    tab标签切换(无炫效果,简单的显示隐藏)
    JQuery 的选择器
    简单的JQuery top返回顶部
    Hello Word!
    java Data 计算自己活了多少天
  • 原文地址:https://www.cnblogs.com/zqy123/p/4947594.html
Copyright © 2011-2022 走看看