zoukankan      html  css  js  c++  java
  • POJ1011(问题!!)

    《Sticks》

    Description
    
    George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long they were originally. Please help him and design a program which computes the smallest possible original length of those sticks. All lengths expressed in units are integers greater than zero. 
    
    Input
    
    The input contains blocks of 2 lines. The first line contains the number of sticks parts after cutting, there are at most 64 sticks. The second line contains the lengths of those parts separated by the space. The last line of the file contains zero.
    
    Output
    
    The output should contains the smallest possible length of original sticks, one per line. 
    
    Sample Input
    9
    5 2 1 5 2 1 5 2 1
    4
    1 2 3 4
    0
    
    
    Sample Output
    6
    5

    代码:(没写完)

    #include <stdio.h>
    #include <stdlib.h>
    #define size 20
    int num;//TEST数目
    int data[size]={};
    int sum;
    int min,max;
    int N;
    int length,length_smallest;
    bool findpath = false;
    
    void foo1(int count){
        for(int i=0;i<count;i++){
            sum+=data[i];
        }
        min = sum/count;//分组每一组的最小和
        max = sum;
    
    }
    void meiju(){
        for(int i=min;i<max;i++){
            if(sum%i==0){
                N= sum/i;//n组
              //dfs过程
                dfs(0);
            }
        }
    
    }
    void handle(){
        if() 
            findpath = true;
    }
    void dfs(int step){
    
        if(step ==N){
            handle();
            if(findpath==1){
           length = sum/N;
           if(length<length_smallest){
                length_smallest = length;
           }
            }
            return;
        }
    
    
        
    
    }
    int main(){
            int count=0;
            freopen("input.txt","r",stdin);
            scanf("%d ",&num);
            while(num!=0){
            for(int i=num;i>0;i--){
                scanf("%d ",&data[count]);
                count++;
            }
            //进行处理的位置here
    
            //下一个case
            for(int i=0;i<count;i++)
            {data[i]=0;}
            count = 0;
            scanf("%d ",&num);
            }
    }
    大多数想法要么平庸,要么更糟糕,这很大程度上因为绝妙的想法难得一见,而且他们还要在我们身边这个充斥了各种恶俗的所谓常识的环境中孕育生长。
  • 相关阅读:
    Asp.net web Api源码分析HttpServer的创建
    asp.net mvc源码分析DefaultModelBinder 集合绑定
    asp.net mvc RouteCollection的RouteExistingFiles属性理解
    Asp.net web Api源码分析HttpResponseMessage
    asp.net mvc源码分析RenderAction和RenderPartial
    AcWing 1022. 宠物小精灵之收服
    AcWing 423. 采药
    AcWing 272. 最长公共上升子序列
    算法浅谈之迭代加深
    AcWing 1023. 买书
  • 原文地址:https://www.cnblogs.com/linux0537/p/6141602.html
Copyright © 2011-2022 走看看