• [topcoder]SRM 633 DIV 2


    第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076

    模拟就可以了。

    #include <vector>
    #include <algorithm>
    
    using namespace std;
    
    class Target {
    public:
      vector <string> draw(int n) {
        vector<string> result(n, string(n, ' '));
        int x = 0;
        int y = 0;
        while (n >= 1) {
          for (int i = 0; i < n; i++) {
            result[x + i][y] = '#';
            result[x][y + i] = '#';
            result[x + n - 1][y + i] = '#';
            result[x + i][y + n - 1] = '#';
          }
          x += 2;
          y += 2;
          n -= 4;
        }
        return result;
      }
    };
    

    第二题,想了很久。最后发现用三角形的A+B>=C,一个一个推,可以推出N条边所组成的多边形(开口)的距离范围。http://apps.topcoder.com/wiki/display/tc/SRM+633#Jumping

    有详细的图示。

    #include <vector>
    #include <algorithm>
    #include <string>
    #include <algorithm>
    using namespace std;
    
    class Jumping {
    public:
      string ableToGet(int x, int y, vector <int> jumpLengths) {
        double d = sqrt(1.0 * x * x + 1.0 * y * y);
        sort(jumpLengths.begin(), jumpLengths.end());
        double low = jumpLengths[0];
        double high = jumpLengths[0];
        for (int i = 1; i < jumpLengths.size(); i++) {
          low = max(0.0, jumpLengths[i] - high);
          high = high + jumpLengths[i];
        }
        if (d >= low && d <= high) {
          return "Able";
        } else {
          return "not able";
        }
    
      }
    
    };
    

    第三题,没做。后来看题解,就是用LCD和GCD的限制,得到x*y,然后穷举搜索。用DFS。

  • 相关阅读:
    K8s(2)-部署应用
    Docker-常用命令(7)
    Docker-堆栈stack(6)
    Docker-集群swarm(5)
    Docker-服务(4)
    Docker的概念术语(2)
    k8s(1)-使用kubeadm安装Kubernetes
    Celery-分布式任务队列
    使用Python管理压缩包
    jQuery基础
  • 原文地址:https://www.cnblogs.com/lautsie/p/4246557.html
Copyright © 2020-2023  润新知