zoukankan      html  css  js  c++  java
  • 1270: [蓝桥杯2015决赛]完美正方形

    如果一些边长互不相同的正方形,可以恰好拼出一个更大的正方形,则称其为完美正方形。
    历史上,人们花了很久才找到了若干完美正方形。
    比如:如下边长的22个正方形
    2 3 4 6 7 8 12 13 14 15 16 17 18 21 22 23 24 26 27 28 50 60
    如下图那样组合,就是一种解法。此时,
    紧贴上边沿的是:60 50
    紧贴下边沿的是:26 28 17 21 18

    22阶完美正方形一共有8种。下面的组合是另一种:
    2 5 9 11 16 17 19 21 22 24 26 30 31 33 35 36 41 46 47 50 52 61
    如果告诉你该方案紧贴着上边沿的是从左到右依次为:47 46 61
    你能计算出紧贴着下边沿的是哪几个正方形吗?

    输出

    请提交紧贴着下边沿的正方形的边长,从左到右,用空格分开。

    来源/分类

    #include <bits/stdc++.h>
    using namespace std;
    //const int EDGE = 154;
    //int num[19] = {2, 5, 9, 11, 16, 17, 19, 21, 22, 24, 26, 30, 31, 33, 35, 36, 41, 50, 52};
    //int vis[20];
    //int mp[EDGE][EDGE];
    //
    //void fillUp(int x, int y, int length, int fillNumber){
    //    for(int i = x; i < x + length; i++)
    //        for(int j = y; j < y + length; j++)
    //            mp[i][j] = fillNumber;
    //}
    //bool isFull(){
    //    for(int i = 0; i < EDGE; i++)
    //        for(int j = 0; j < EDGE; j++)
    //            if(!mp[i][j])
    //                return false;
    //    return true;
    //}
    //bool judge(int x, int y, int length){
    //    if(x + length > EDGE || y + length > EDGE)
    //        return false;
    //    for(int i = x; i < x + length; i++)
    //        for(int j = y; j < y + length; j++)
    //            if(mp[i][j])
    //                return false;
    //    return true;
    //}
    //bool dfs(int x, int y){
    //    if(isFull())
    //        return true;
    //    if(x > EDGE || y > EDGE)
    //        return false;
    //    bool flag = false;
    //    int newX, newY;
    //    for(int i = 0; i < EDGE; i++){
    //        for(int j = 0; j < EDGE; j++)
    //            if(!mp[i][j]){
    //                newX = i, newY = j;
    //                flag = true;
    //                break;
    //            }
    //        if(flag)
    //            break;
    //    }
    //    for(int i = 0; i < 19; i++){
    //        if(judge(newX, newY, num[i])){
    //            if(!vis[i]){
    //                fillUp(newX, newY, num[i], num[i]);
    //                vis[i] = true;
    //                if(dfs(newX, newY + num[i]))
    //                    return true;
    //                fillUp(newX, newY, num[i], 0);
    //                vis[i] = false;
    //            }
    //        }else
    //            break;
    //    }
    //    return false;
    //}
    int main(){
    //    fillUp(0, 0, 47, 47);
    //    fillUp(0, 47, 46, 46);
    //    fillUp(0, 93, 61, 61);
    //    dfs(0, 0);
    //    for(int j = 0; j < EDGE; j++)
    //      cout << mp[153][j] << " ";
    
        cout << 50 << " " << 33 << " " << 30 << " " << 41;
        return 0;
    }
    View Code
  • 相关阅读:
    openSUSE 13.1 Milestone 4 发布
    Neo4j 2.0 M4 发布
    iBoxDB for .NET v1.5发布, 移动NoSQL数据库
    GNU libc (Glibc) 2.18 发布
    Android 开源项目维护者宣布退出
    Jeasyframe 开源框架 稳定版 V1.5 发布
    Spring Mobile 1.1.0.RC1 和 1.0.2 发布
    Deis logo 开源PaaS系统 Deis
    EasyCriteria 3.0 发布
    TypeScript 0.9.1 发布,新增 typeof 关键字
  • 原文地址:https://www.cnblogs.com/xcfxcf/p/12436382.html
Copyright © 2011-2022 走看看