<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    emu in blogjava

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      171 隨筆 :: 103 文章 :: 1052 評論 :: 2 Trackbacks

    Problem Statement

        

    In the factorial number system the value of the first digit (from the right) is 1!, the value of the second digit is 2!, ..., and the value of the n-th digit is n!. This means that any decimal number d can be written in this system as: anan-1...a2a1, where

    d = an * n! + an-1 * (n-1)! + ... + a2 * 2! + a1 * 1! and 0 <= ai <= i for all i.

    Given an int num in decimal, return its representation in the factorial number system.

    Definition

        
    Class: FactorialSystem
    Method: convert
    Parameters: int
    Returns: int
    Method signature: int convert(int num)
    (be sure your method is public)
        

    Notes

    - n! = 1 * 2 * ... * n

    Constraints

    - num will be between 1 and 3628799 (10!-1), inclusive.

    Examples

    0)
        
    1
    Returns: 1
    1)
        
    24
    Returns: 1000
    24 = 4!
    2)
        
    153
    Returns: 11111
    153 = 1! + 2! + 3! + 4! + 5!.
    3)
        
    133
    Returns: 10201
    4)
        
    3628799
    Returns: 987654321
    Largest possible input.

    This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

    posted on 2005-12-23 10:26 emu 閱讀(1351) 評論(4)  編輯  收藏 所屬分類: google編程大賽模擬題及入圍賽真題

    評論

    # re: FactorialSystem (code jam china round2 300分真題) 2006-07-28 08:29 peng he
    #include<stdio.h>
    void main()
    {int i, a;
    scanf("%d",&a);
    for(i=2;a/i!=0;i++)
    {printf("%d",a%i);
    a=a/i;



    }


    }  回復  更多評論
      

    # re: FactorialSystem (code jam china round2 300分真題) 2007-06-09 15:39 匿名
    @peng he
    你這編的什么東西呀

    題目意思理解清楚沒有呀  回復  更多評論
      

    # re: FactorialSystem (code jam china round2 300分真題)[未登錄] 2007-09-08 22:44 a
    package factorial;
    import java.util.LinkedList;
    public class Factorial {

    public static void main(String[] args) {
    StringBuffer sb=new StringBuffer();
    LinkedList<Integer> al=new LinkedList<Integer>();
    int m=445;
    int z=1;
    int fZ=z;
    al.add(fZ);
    while(m/fZ>0)
    {
    z++;
    al.addLast(al.getLast()*z);
    fZ=al.getLast();

    }
    int n=z-1;
    for(int i=n;i>=1;i--)
    {

    int temp=m/al.get(i-1);
    m-=temp*al.get(i-1);
    sb.append(temp);
    }
    System.out.println(sb.toString());

    }

    }
      回復  更多評論
      

    # re: FactorialSystem (code jam china round2 300分真題) 2008-10-12 21:45 zgqchina
    #include<iostream>
    using namespace std;

    long factrial(int n) //求階乘,n>0
    {
    if(n==1) return 1;
    else
    return n*factrial(n-1);
    }

    int k=0,a[9]; //全局變量 K用來計數,數組用來存放數列

    void convert(double num) //轉換成數列
    {
    int n=9;
    while((num>0)&&(n>=1))
    {
    int m=factrial(n);
    if(num<m)
    a[k]=0;
    else
    {
    for(int p=n;p>=1;p--)
    if(num>=p*m)
    {
    a[k]=p;
    break;
    }
    num=num-p*m;
    }
    n--;
    k++;
    }
    }

    void main()
    {
    cout<<"please input a number(num will be between 1 and 3628799) :"<<endl;
    double temp;
    cin>>temp;
    cout<<"now the result is :"<<endl;
    convert(temp);
    int i=0;
    while(a[i]==0) i++;
    for(i;i<9;i++)
    cout<<a[i]<<" ";
    }  回復  更多評論
      

    主站蜘蛛池模板: 亚洲av日韩av无码黑人| 亚洲欧美成人综合久久久| 2021久久精品免费观看| 自拍偷自拍亚洲精品播放| 亚洲精品夜夜夜妓女网| 日本片免费观看一区二区| 美女扒开屁股让男人桶爽免费| 亚洲国产精品无码久久久不卡| 免费观看激色视频网站bd | 亚洲性无码av在线| 国产免费直播在线观看视频| 真人做人试看60分钟免费视频| 亚洲а∨精品天堂在线| 亚洲精品自产拍在线观看| 大地资源二在线观看免费高清| 人成免费在线视频| 亚洲中文无码a∨在线观看| 亚洲av成本人无码网站| 国产成A人亚洲精V品无码性色| 毛片免费观看的视频| 免费看成人AA片无码视频吃奶| 亚洲色成人网站WWW永久四虎 | 亚洲视频在线观看2018| 国产亚洲精品a在线观看| 日韩吃奶摸下AA片免费观看| 中文字幕在线免费视频| 国产精品亚洲综合| 亚洲狠狠爱综合影院婷婷| 日本zzzzwww大片免费| 中国精品一级毛片免费播放| 亚洲日韩国产二区无码| 激情内射亚洲一区二区三区| 久久精品免费全国观看国产| 99麻豆久久久国产精品免费| 黄网站色视频免费看无下截| 亚洲av无码片在线观看| 亚洲AV无码1区2区久久| 国产亚洲精品无码专区| 免费人成网站在线高清| 成人永久免费高清| 久久午夜免费视频|