zoukankan      html  css  js  c++  java
  • N!

    前言

    第一次打压位高精,也不是很难嘛

    以前用字符串做高精太蠢了

    题目

    HDU

    Vjudge

    正题

    暴力就完事了

    由于压位,我们第一位不需要补(0),直接输出就好了,剩下的要补了(0)再输出

    怎么补(0)呢?

    对于剩下的每一位,用(\%0*lld)输出,后面传两个参数(x,y)

    表示输出(y),如果不足(x)位,用(0)补足

    代码

    //12252024832524
    #include <cstdio>
    #include <algorithm>
    using namespace std; 
    
    typedef long long LL;
    const LL MAXN = 4000005;
    const LL LEN = 1000000000;
    int n;
    LL a[MAXN];
    
    int Read()
    {
    	int x = 0,f = 1;char c = getchar();
    	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
    	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
    	return x * f;
    }
    void Put1(LL x)
    {
    	if(x > 9) Put1(x/10);
    	putchar(x%10^48);
    }
    void Put(LL x)
    {
    	if(x < 0) putchar('-'),x = -x;
    	Put1(x);
    }
    template <typename T>T Max(T x,T y){return x > y ? x : y;}
    template <typename T>T Min(T x,T y){return x < y ? x : y;}
    template <typename T>T Abs(T x){return x < 0 ? -x : x;}
    
    void jc(int x)
    {
    	int len = 0;
    	a[0] = 1;
    	for(int i = 2;i <= x;++ i)
    	{
    		LL jw = 0;
    		for(LL j = 0;j <= len;++ j)
    		{
    			a[j] = a[j] * i + jw;
    			jw = a[j] / LEN;
    			a[j] %= LEN;
    //			printf("%d
    ",jw);
    		}
    		while(jw)
    		{
    			a[len+1] = jw % LEN;
    			jw /= LEN;
    			len++;
    		}
    	}
    	printf("%lld",a[len]); a[len] = 0;
    	for(int i = len-1;i >= 0;-- i)
    	{
    		printf("%0*lld",9,a[i]);
    		a[i] = 0;
    	}
    	putchar('
    ');
    }
    
    int main()
    {
    //	freopen(".in","r",stdin);
    //	freopen(".out","w",stdout);
    	while(~scanf("%d",&n))jc(n);
    	return 0;
    }
    
  • 相关阅读:
    M1卡的工作原理【转】
    磁卡ID卡IC卡的区别【转】
    磁卡结构【转】
    M1卡破解(自从学校升级系统之后,还准备在研究下)【转】
    RunJS演示代码
    Linux中inet_aton的问题(IP转整数)
    使用Hive UDF和GeoIP库为Hive加入IP识别功能
    hive下UDF函数的使用
    linux下smb
    使用Spring MVC表单标(转)
  • 原文地址:https://www.cnblogs.com/PPLPPL/p/13395308.html
Copyright © 2011-2022 走看看