| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 761 人关注过本帖
标题:[求助]大家帮忙看下这个题!
只看楼主 加入收藏
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
 问题点数:0 回复次数:9 
[求助]大家帮忙看下这个题!

http://acm.hdu.edu.cn/showproblem.php?pid=1099
Lottery
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 19 Accepted Submission(s) : 12

Problem Description


Eddy's company publishes a kind of lottery.This set of lottery which are numbered 1 to n, and a set of one of each is required for a prize .With one number per lottery, how many lottery on average are required to make a complete set of n coupons?

Input


Input consists of a sequence of lines each containing a single positive integer n, 1<=n<=22, giving the size of the set of coupons.


Output


For each input line, output the average number of lottery required to collect the complete set of n coupons. If the answer is an integer number, output the number. If the answer is not integer, then output the integer part of the answer followed by a space and then by the proper fraction in the format shown below. The fractional part should be irreducible. There should be no trailing spaces in any line of ouput.


Sample Input


2
5
17

Sample Output


3
5
11 --
12
340463
58 ------
720720

我看不懂它的输出到底是什么规律呢?题意也看得很不明白!

搜索更多相关主题的帖子: required blank company Memory number 
2007-01-11 17:39
davidloves
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-1-6
收藏
得分:0 

帮你顶上去吧


2007-01-11 19:01
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
呵呵!自己也顶顶!

该学习了。。。
2007-01-11 19:32
ffaannggqq
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-12-23
收藏
得分:0 

啥东西啊


2007-01-12 15:40
神秘失恋
Rank: 1
等 级:新手上路
帖 子:663
专家分:0
注 册:2007-1-6
收藏
得分:0 

上帝之手.........
2007-01-12 15:45
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
呵呵!是acm的一道题:

该学习了。。。
2007-01-12 17:14
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 


If the answer is an integer number, output the number. If the answer is not integer, then output the integer part of the answer(输出整数) followed by a space(空格) and then by the proper fraction in the format shown below.(输出小数部分,要是真分数) The fractional part should be irreducible. (分数不能约分)There should be no trailing spaces in any line of ouput. (每一行的最后不能有多余的空格)


倚天照海花无数,流水高山心自知。
2007-01-12 19:13
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
我的理解是最少需要多少张的彩票才能将这n张彩票收集齐全,但是明显和答案不符,呵呵,想请问一下问什么会得到这个结果?

该学习了。。。
2007-01-12 20:28
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
提示一下算法是怎样的?

该学习了。。。
2007-01-13 19:51
Leelouder
Rank: 1
等 级:新手上路
帖 子:4
专家分:1
注 册:2010-7-19
收藏
得分:0 
据说算法是:sum=n/1+n/2+……+n/n  
其实我也没懂  网上搜了搜

给你一段c++的代码自己领悟吧:
#include<iostream>
using namespace std;
void tongfen(int &x,int &y)
{
    int m=x,n=y,r=m%n;
    while(r)
    {
        m=n;
        n=r;
        r=m%n;
    }
    x=x/n;
    y=y/n;
}
int main()
{
    int n,i,sumfz,sumfm,fz,fm,zheng,weif,weiz;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==1){printf("1\n");continue;}
        sumfz=n;sumfm=1;zheng=0;
        for(i=2;i<=n;i++)
        {
            fz=n;fm=i;
            sumfz=sumfz*fm+fz*sumfm;
            sumfm=sumfm*fm;
            zheng=sumfz/sumfm+zheng;
            sumfz=sumfz%sumfm;
            if(sumfz!=0)tongfen(sumfm,sumfz);
        }
        if(sumfz==0)printf("%d\n",zheng);
        else
        {
            weif=0;
            weiz=0;
            i=sumfm;
            while(i)
            {
                i=i/10;
                weif++;
            }
            i=zheng;
            while(i)
            {
                i=i/10;
                weiz++;
            }
            for(i=0;i<=weiz;i++)
                printf(" ");
            printf("%d\n",sumfz);
            printf("%d ",zheng);
            for(i=0;i<weif;i++)
                printf("-");
            printf("\n");
            for(i=0;i<=weiz;i++)
                printf(" ");
            printf("%d\n",sumfm);
        }
    }
    return 0;
}
 
2010-07-19 13:07
快速回复:[求助]大家帮忙看下这个题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017409 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved