博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
阶乘之和
阅读量:2038 次
发布时间:2019-04-28

本文共 1314 字,大约阅读时间需要 4 分钟。

/**@Author:   STZG*@Language: C++*/#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#define DEBUG#define RI register intusing namespace std;typedef long long ll;typedef __int128 lll;const int N=100010;const int MOD=1e9+7;const double PI = acos(-1.0);const double EXP = 1E-8;const int INF = 0x3f3f3f3f;int t,n,m,k,q;int he[N],num[N],s[N];inline void add(){ memset(he,0,sizeof(he)); he[0]=max(s[0],num[0]); for(RI i=1;i<=he[0];++i) { he[i]+=s[i]+num[i]; he[i+1]=he[i]/10; he[i]%=10; } while(he[ he[0]+1 ]>0) { he[ he[0]+2 ]=he[ he[0]+1 ]/10; he[ he[0]+1 ]%=10; he[0]++; } s[0]=he[0]; for(RI i=1;i<=he[0];++i) s[i]=he[i];}int main(){#ifdef DEBUG freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout);#endif scanf("%d",&n); num[0]=1,num[1]=1; s[0]=1,s[0]=0; for(RI k=1;k<=n;++k) { memset(he,0,sizeof(he)); he[0]=num[0]; for(RI i=1;i<=num[0];++i) { he[i]+=num[i]*k; he[i+1]=he[i]/10; he[i]%=10; } while(he[ he[0]+1 ]>0) { he[ he[0]+2 ]=he[ he[0]+1 ]/10; he[ he[0]+1 ]%=10; he[0]++; } for(RI i=1;i<=he[0];++i) num[i]=he[i]; num[0]=he[0]; add(); } for(RI i=s[0];i>=1;--i) printf("%d",s[i]); puts(""); //cout << "Hello world!" << endl; return 0;}

 

转载地址:http://eyzof.baihongyu.com/

你可能感兴趣的文章
SOA架构师注意的问题
查看>>
最佳拍档:首席市场官与首席技术官
查看>>
CIO领导力必会的八大诀窍
查看>>
微软技术节(TechFest 2010)最前沿技术汇总
查看>>
SQL 操作结果集 -并集、差集、交集、结果集排序
查看>>
详解索引连接类型
查看>>
托管堆与垃圾收集
查看>>
MySQL初夜(乱码问题,命令行客户端使用)
查看>>
jQuery工具函数
查看>>
cookie
查看>>
javascript之window对象
查看>>
HttpCookie类
查看>>
(转载addone)完全使用Linux作为桌面系统 —— 使用Linux两年记 --软件列表
查看>>
wxzh001,进来看关于APACHE+PHP+MYSQL+SSL的LINUX下安装配置(转自奥索)
查看>>
google app api相关(商用)
查看>>
linux放音乐cd
查看>>
GridView+存储过程实现'真分页'
查看>>
flask_migrate
查看>>
flask_script
查看>>
threading.local
查看>>