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);
            }
    }
    大多数想法要么平庸,要么更糟糕,这很大程度上因为绝妙的想法难得一见,而且他们还要在我们身边这个充斥了各种恶俗的所谓常识的环境中孕育生长。
  • 相关阅读:
    springboot~使用docker构建gradle项目
    CH BR8(小学生在上课-逆元和互质数一一对应关系)
    UNIX环境高级编程第二版代码笔记
    【Linux学习笔记】用nc实现两台主机间的文件传输(不需要输密码)
    hdu 1159
    轻量级的原型设计工具-Axure RP
    在Ubuntu 12.10 上安装部署Openstack
    [Android 中级]Voip之CSipSimple类库的编绎
    OpenStack云计算快速入门之一:OpenStack及其构成简介
    OpenStack云计算快速入门之二:OpenStack安装与配置
  • 原文地址:https://www.cnblogs.com/linux0537/p/6141602.html
Copyright © 2011-2022 走看看