zoukankan      html  css  js  c++  java
  • HDU5463 Clarke and minecraft

    解题思路:此题刚开始,觉得好繁琐,好混乱,理清思路后,发现很简单。

           具体见代码分析。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 using namespace std;
     5 const int maxn = 505;
     6 int hash1[maxn]; //标记对应类型总共出现了多少个。
     7 int main()
     8 {
     9     int t, n, a, b, sum, cnt;
    10     scanf("%d", &t);
    11     while(t--)
    12     {
    13         scanf("%d", &n);
    14         memset(hash1, 0, sizeof(hash1));
    15         while(n--)
    16         {
    17             scanf("%d %d", &a, &b);
    18             hash1[a] += b; //hash1标记对应类型共出现多少个
    19         }
    20         sum = cnt = 0;
    21         for(int i = 0; i <= 505; i++) //因为a和b的取值范围都为500
    22         {
    23             if(hash1[i]) //如果出现过
    24             {
    25                 sum += hash1[i]/64; //sum记录总共要装多少个格子
    26                 if(hash1[i]%64) sum ++; //如果不能整除,则要多放一个格子
    27                 cnt += sum/36, sum %= 36;//cnt记录总共要运多少次
    28             }
    29         }
    30         if(sum) cnt ++; //如果sum没有整除,则要多运一次
    31         printf("%d
    ", cnt);
    32     }
    33     return 0;
    34 }
    View Code
  • 相关阅读:
    tornado之获取参数
    tornado中命名路由及反向解析使用
    options模块介绍
    服务的启动
    redis操作
    python中使用redis模块, 设置过期时间
    LaTeX
    word 摘要
    常用命令
    机器学习的建议
  • 原文地址:https://www.cnblogs.com/loveprincess/p/4825209.html
Copyright © 2011-2022 走看看