当前位置: 首页 > wzjs >正文

静安网站建设内容营销平台有哪些

静安网站建设,内容营销平台有哪些,网站电子地图怎么做,系统开发的主要方法有生命周期法博主主页:Yu仙笙 专栏地址:洛谷千题详解 目录 题目描述 输入格式 输出格式 输入输出样例 解析: C源码: Python源码: Java源码: Pascal源码: ------------------------------------------------…

博主主页:Yu·仙笙

专栏地址:洛谷千题详解

目录

题目描述

输入格式

输出格式

输入输出样例

解析: 

C++源码:

Python源码:

Java源码:

Pascal源码:


 -------------------------------------------------------------------------------------------------------------------------------

 -------------------------------------------------------------------------------------------------------------------------------

题目描述

用高精度计算出 S=1!+2!+3!+⋯+n!(n≤50)。

其中 ! 表示阶乘,定义为n!=n×(n−1)×(n−2)×⋯×1。例如,5!=5×4×3×2×1=120。

 -------------------------------------------------------------------------------------------------------------------------------

输入格式

一个正整数 n。

 -------------------------------------------------------------------------------------------------------------------------------

输出格式

一个正整数 S,表示计算结果。

 -------------------------------------------------------------------------------------------------------------------------------

输入输出样例

输入 #1

3

输出 #1

9

 -------------------------------------------------------------------------------------------------------------------------------

解析: 

 思路就是高精乘+高精加,就是把高精乘的模板套上去接着套高精加的模板,b=c=i的阶乘。

 -------------------------------------------------------------------------------------------------------------------------------

C++源码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
struct fantastic     //嗯,开始重载了
{int len,s[9999];fantastic(){memset(s,0,sizeof(s));len=1;}fantastic operator=(const char*num){len=strlen(num);for(int i=0;i<len;++i)s[i]=num[len-i-1]-'0';return *this;}fantastic operator=(const int num){char a[9999];sprintf(a,"%d",num);*this=a;return *this;}fantastic (const int num){*this=num;}fantastic (const char * num){*this=num;}fantastic operator+(const fantastic &a)   //这里在重载 “+” 的运算{fantastic c;c.len=max(len,a.len)+1;                //这里就是我们熟悉的竖式模拟了for(int i=0,x=0;i<c.len;++i){c.s[i]=s[i]+a.s[i]+x;x=c.s[i]/10;c.s[i]=c.s[i]%10;}if(c.s[c.len-1]==0)--c.len;return c;}fantastic operator * (const fantastic &x)           //然后再来波 “*” 的运算{fantastic c;c.len=len+x.len;                 //又是我们熟悉的竖式模拟for(int i=0;i<len;++i)for(int j=0;j<x.len;++j){c.s[i+j]+=s[i]*x.s[j];c.s[i+j+1]+=c.s[i+j]/10;c.s[i+j]%=10;}if(c.s[c.len-1]==0)--c.len;return c;}
};
ostream& operator<<(ostream &out,const fantastic& x)   //重载一下输出
{for(int i=x.len-1;i>=0;--i)cout<<x.s[i];return out;
}
istream& operator>>(istream &in,fantastic &x)       //重载一下输入
{char num[9999];in>>num;x=num;return in;
}
int main()         //然后就可以愉快的开始主程序啦
{int n;fantastic ans=0,num=1;cin>>n;for(int i=1;i<=n;i++){num=num*i;ans=ans+num;}cout<<ans<<endl;
}                                         //非常的简单明了

 -------------------------------------------------------------------------------------------------------------------------------

Python源码:

print(reduce(lambda x,y:x+y,[reduce(lambda x,y:x*y,range(1,i+1)) for i in range(1, int(raw_input())+1)]))

 -------------------------------------------------------------------------------------------------------------------------------

Java源码:

    private static final BigInteger[] INTEGERS = new BigInteger[51];static {INTEGERS[0] = new BigInteger("1");}public static void main(String[] args) {BigInteger result = new BigInteger("0");Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();for (int i = 1; i <= n; ++ i) {INTEGERS[i] = INTEGERS[i - 1].multiply(new BigInteger(String.valueOf(i)));result = result.add(INTEGERS[i]);}System.out.println(result);}

 -------------------------------------------------------------------------------------------------------------------------------

Pascal源码:

var a,b:array[1..1000] of int64;i,j,la,lb,n:longint;
procedure cheng(t:longint);//高精度乘单精度
var i:longint;
beginfor i:=1 to la doa[i]:=a[i]*t;for i:=1 to la dobegina[i+1]:=a[i+1]+a[i] div 10;a[i]:=a[i] mod 10;end;while a[la+1]>0 do inc(la);
end;
procedure jia;//高精度加法
var i:longint;
beginfor i:=1 to la dobeginb[i]:=b[i]+a[i];b[i+1]:=b[i+1]+b[i] div 10;b[i]:=b[i] mod 10;end;while b[lb+1]>0 do inc(lb);
end;
beginread(n);a[1]:=1;for i:=1 to n dobegincheng(i);jia;end;for i:= lb downto 1 dowrite(b[i]);
end.

 -------------------------------------------------------------------------------------------------------------------------------

http://www.dtcms.com/wzjs/65759.html

相关文章:

  • 手机版网站设计案例营销软文怎么写
  • 价目表海报app制作站群seo技巧
  • 杭州市滨江区建设局网站深企在线
  • 网站 黑白推广方案格式模板范文
  • 电子元器件网站怎么做营销软文500字范文
  • 移动端网站推广万网域名注册流程
  • 宣传片策划拍摄制作公司关键词查询优化
  • 常州专业网站建设公司咨询武汉seo优化代理
  • 框架布局技术制作一个网站网络网站
  • 营销型企业网站建设教案站长之家最新网站
  • 网站建设原创苏州整站优化
  • 百度糯米做网站多少钱个人网页在线制作
  • 网站开发与网站建设搜索 引擎优化
  • 网站商城建设需求表深圳龙岗区优化防控措施
  • 采集做网站中国软文网
  • 如何用服务器做网站百度提交网址多久才会收录
  • 建设银行信用卡中心网站首页seo文章
  • wordpress.appseo搜索引擎优化
  • 网站建设和优化排名seo岗位培训
  • 网站搭建的收录情况
  • 网站与网页的区别与联系科学新概念seo外链
  • 网站外链平台女孩短期技能培训班
  • 海南海口做网站国内十大4a广告公司
  • 做设计常用网站有哪些游戏优化软件
  • wordpress 原创模板电脑优化软件哪个好用
  • wordpress网站制作最有效的100个营销方法
  • 网站建设技术方案今日深圳新闻最新消息
  • bootstrap网站登录页面长沙网站优化方案
  • 医院网站建设 费用seo日常工作都做什么的
  • 长沙网站建设合肥seo外包平台