另一种阶乘问题
时间限制:3000 ms | 内存限制:65535 KB 难度:1- 描述
-
大家都知道阶乘这个概念,举个简单的例子:5!=1*2*3*4*5.现在我们引入一种新的阶乘概念,将原来的每个数相乘变为i不大于n的所有奇数相乘例如:5!!=1*3*5.现在明白现在这种阶乘的意思了吧!
现在你的任务是求出1!!+2!!......+n!!的正确值(n<=20)
- 输入
-
第一行输入一个a(a<=20),代表共有a组测试数据
接下来a行各行输入一个n.
- 输出
- 各行输出结果一个整数R表示1!!+2!!......+n!!的正确值
- 样例输入
-
2 3 5
- 样例输出
-
5 23
- 来源
-
[张洁烽]原创
#includeint a[22]; int main() { int i,j,n,test,sum; for(i=1;i<=20;i++) { a[i]=1; if(i&1) { for(j=1;j<=i;j+=2) a[i]*=j; } else { for(j=1;j
- <script type="text/java script">BAIDU_CLB_fillSlot("771048");
- 点击复制链接 与好友分享! 回本站首页 <script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)]; - 您对本文章有什么意见或着疑问吗?请到 论坛讨论您的关注和建议是我们前行的参考和动力??
- 相关文章
编程之美:不要被阶乘吓倒
- <script type="text/java script">BAIDU_CLB_fillSlot("182716");
- <script type="text/java script">BAIDU_CLB_fillSlot("517916");
- 图文推荐
<iframe src="http://www.2cto.com/uapi.php?tid=357923&catid=339&title=we3Su9bWvdezy87KzOKjqMTP0fRvajY1o6k=&forward=http://www.2cto.com/kf/201412/357923.html" width="100%" height="100%" id="comment_iframe" name="comment_iframe" frameborder="0" scrolling="no">
- <script type="text/java script">BAIDU_CLB_fillSlot("771057");



