• Lottery hdu1099


    Lottery

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 1108    Accepted Submission(s): 544


    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
     
    Author
    eddy
     
    Recommend
    JGShining
     
     
    题目没有看懂啊~~~~
    /*****************************************************************
    HDU 1099
    ****************************************************************
    */
    #include<iostream>
    using namespace std;
    long long gcd(long long a,long long b)
    {
    if(b==0)return a;
    else return gcd(b,a%b);
    }
    int main()
    {
    int i,n;
    long long number,n1,n2;
    long long integer;
    long long fenzi,fenmu;
    long long a[23];
    a[1]=1;
    for(i=2;i<=22;i++)a[i]=i*a[i-1]/gcd(i,a[i-1]);
    while(scanf("%d",&n)!=EOF)
    {
    fenzi=0;
    for(i=1;i<=n;i++) fenzi+=a[n]/i;
    fenzi*=n;
    number=gcd(fenzi,a[n]);
    fenzi=fenzi/number;
    fenmu=a[n]/number;
    integer=fenzi/fenmu;
    fenzi-=integer*fenmu;
    if(fenzi==0)
    {
    printf("%I64d\n",integer);continue;
    }
    int size1=0,size2=0;
    n1=integer;n2=fenmu;
    while(n1!=0){size1++;n1/=10;}
    while(n2!=0){size2++;n2/=10;}
    for(i=0;i<=size1;i++)printf("");
    printf("%I64d\n",fenzi);
    printf("%I64d ",integer);
    for(i=0;i<size2;i++)printf("-");
    printf("\n");
    for(i=0;i<=size1;i++)printf("");
    printf("%I64d\n",fenmu);
    }
    return 0;
    }
  • 相关阅读:
    更博更博233 总结一点点vue
    码几篇过两天要用的jq拦截器和导航插件
    整理两篇不错的关于rgba兼容和线性渐变
    1-新一期的技术难点
    决定把工作bug写到这好了 省的记到本本上还要带着(QAQ我啥时候变这么懒呢)。。。
    小知识点,jQuery把一个已知的值赋值给input
    bootstrap3踩过的坑~具体来说这是在制作一个接地气的功能块时碰到的各种小坑坑!
    自己写的一个banner动画
    自己做了一个左边侧边栏展开的效果
    模仿qq音乐播放字母效果
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2229004.html
Copyright © 2020-2023  润新知