• 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);
            }
    }
    大多数想法要么平庸,要么更糟糕,这很大程度上因为绝妙的想法难得一见,而且他们还要在我们身边这个充斥了各种恶俗的所谓常识的环境中孕育生长。
  • 相关阅读:
    (4.5.4)Android測试TestCase单元(Unit test)測试和instrumentationCase单元測试
    JVM、垃圾回收、内存调优、常见參数
    相关系数图可视化
    Codeforces 558(C、D、E)总结
    [Windows 64] (搬运)价值¥ 6,499的软件Navicat Premium11.2.11 最新版及其注册机
    ORA-12737: Instant Client Light: unsupported server character set CHS16GBK/ZHS16GBK解决方案
    计蒜客练习
    站在巨著之上谈泛型(转载)
    java util包概述
    Calender的使用详解
  • 原文地址:https://www.cnblogs.com/linux0537/p/6141602.html
Copyright © 2020-2023  润新知