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

县级网站建设使用软件提高百度推广排名

县级网站建设,使用软件提高百度推广排名,网站开发的抓包,合肥网站建站公司目录n的阶乘 (清华上机)题目描述代码汉诺塔问题题目:代码:Fibonacci数列 (上交复试)题目代码:二叉树:题目:代码:n的阶乘 (清华上机) …

目录

  • n的阶乘 (清华上机)
    • 题目描述
    • 代码
  • 汉诺塔问题
    • 题目:
    • 代码:
  • Fibonacci数列 (上交复试)
    • 题目
    • 代码:
  • 二叉树:
    • 题目:
    • 代码:

n的阶乘 (清华上机)

不敢相信这是清华上机

题目描述

输入一个整数n,输出n的阶乘

代码

递归写法:

#include <cstido>
Factorial(int n){if(n==1){return 1;}else{return Factorial(n-1)*n;}
} int main(){int n;scanf("%d",&n);printf("%d\n",Factorial(n));
}

循环写法

int main(){int n;int sum = 1;scanf("%d",&n);for(int i=1;i<=n;i++){sum = sum*i;}printf("%d",sum);
}

汉诺塔问题

题目:

约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下、由小到大顺序串着由64个圆盘构成的塔。目的是将最左边杆上的盘全部移到右边的杆上,条件是一次只能移动一个盘,且不允许大盘放在小盘的上面。
现在我们改变游戏的玩法,不允许直接从最左(右)边移到最右(左)边(每次移动一定是移到中间杆或从中间移出),也不允许大盘放到下盘的上面。
Daisy已经做过原来的汉诺塔问题和汉诺塔II,但碰到这个问题时,她想了很久都不能解决,现在请你帮助她。现在有N个圆盘,她至少多少次移动才能把这些圆盘从最左边移到最右边?

Input
包含多组数据,每次输入一个N值(1<=N=35)。

Output
对于每组数据,输出移动最小的次数。

Sample Input
1
3
12

Sample Output
2
26
531440

在这里插入图片描述

代码:

#include <cstdio>
//现在有N个圆盘,她至少多少次移动才能把这些圆盘从最左边移到最右边?
long long hanoi(int n){if(n==1) return 2;else return 3*hanoi(n-1)+2;
}int main(){int n;while(scanf("%d",&n)!=EOF){printf("%lld",hanoi(n));}
}

Fibonacci数列 (上交复试)

题目

描述
The Fibonacci Numbers{0,1,1,2,3,5,8,13,21,34,55…} are defined by the recurrence: F0=0 F1=1 Fn=Fn-1+Fn-2,n>=2 Write a program to calculate the Fibonacci Numbers.

输入描述:
Each case contains a number n and you are expected to calculate Fn.(0<=n<=30) 。

输出描述:
For each case, print a number Fn on a separate line,which means the nth Fibonacci Number.

示例1
输入:
1
输出:
1

代码:

#include <cstdio>int Fibonacci(int n){if(n==1){return 1;}else if(n==0){return 0;}else{return Fibonacci(n-1)+Fibonacci(n-2);}
}//斐波那契数列
int main(){int n;while(scanf("%d",&n)!=EOF){printf("%d\n",Fibonacci(n));}
} 

二叉树:

题目:

在这里插入图片描述

如上所示,由正整数1,2,3……组成了一颗特殊二叉树。我们已知这个二叉树的最后一个结点是n。现在的问题是,结点m所在的子树中一共包括多少个结点。 比如,n = 12,m = 3那么上图中的结点13,14,15以及后面的结点都是不存在的,结点m所在子树中包括的结点有3,6,7,12,因此结点m的所在子树中共有4个结点。

输入描述:
输入数据包括多行,每行给出一组测试数据,包括两个整数m,n (1 <= m <= n <= 1000000000)。

输出描述:
对于每一组测试数据,输出一行,该行包含一个整数,给出结点m所在子树中包括的结点的数目。

示例1
输入:
3 12
0 0

输出:
4

分析:

  1. 首先:该树是一颗完全二叉树,若root节点是数字p,那么左节点是数字2p
    右节点是数字2p+1;
  2. 如果子树存在 tree(m) = tree(2m)+tree(2m+1);
    也就是说,该子树的节点数量= 左子树节点数量+右子树节点数量 +1(根节点)
  3. 如果子树根不存在,则tree(m)为0;

代码:

#include <cstdio>// m表示当前节点  n表示节点总数 
int tree(int m,int n){// 如果当前节点的序号大于节点总数 if(m > n){return 0;}else{return 1+tree(2*m,n)+tree(2*m+1,n);}
}int main(){int m,n;while(scanf("%d%d",&m,&n)!=EOF){if(m==0) break;printf("%d\n",tree(m,n));}
}

文章转载自:
http://dinncovindicatory.tqpr.cn
http://dinncotectonics.tqpr.cn
http://dinncoruralism.tqpr.cn
http://dinncokerman.tqpr.cn
http://dinncoreferrence.tqpr.cn
http://dinncounredressed.tqpr.cn
http://dinncosulphate.tqpr.cn
http://dinncomultifid.tqpr.cn
http://dinncogalenite.tqpr.cn
http://dinncoparament.tqpr.cn
http://dinnconls.tqpr.cn
http://dinncobardolater.tqpr.cn
http://dinncounreserve.tqpr.cn
http://dinncozaire.tqpr.cn
http://dinncoswob.tqpr.cn
http://dinncoaimless.tqpr.cn
http://dinncodownright.tqpr.cn
http://dinncobusload.tqpr.cn
http://dinncohyperborean.tqpr.cn
http://dinncocrinkle.tqpr.cn
http://dinncoseropurulent.tqpr.cn
http://dinncocheltonian.tqpr.cn
http://dinncotragicomedy.tqpr.cn
http://dinncosoftland.tqpr.cn
http://dinncoexpressage.tqpr.cn
http://dinncoexperientialism.tqpr.cn
http://dinncodecorously.tqpr.cn
http://dinncotussar.tqpr.cn
http://dinncohinny.tqpr.cn
http://dinncomatelote.tqpr.cn
http://dinncocosmotron.tqpr.cn
http://dinncopainstaker.tqpr.cn
http://dinncosouthern.tqpr.cn
http://dinncoendorser.tqpr.cn
http://dinncobunting.tqpr.cn
http://dinncocroupy.tqpr.cn
http://dinncoclement.tqpr.cn
http://dinncothingummy.tqpr.cn
http://dinncocommandment.tqpr.cn
http://dinncoboding.tqpr.cn
http://dinncoaxunge.tqpr.cn
http://dinncosemisoft.tqpr.cn
http://dinncovisceromotor.tqpr.cn
http://dinncotuyere.tqpr.cn
http://dinncomultivariable.tqpr.cn
http://dinncohotjava.tqpr.cn
http://dinncohornswoggle.tqpr.cn
http://dinncokendal.tqpr.cn
http://dinncogamophyllous.tqpr.cn
http://dinncoavellane.tqpr.cn
http://dinncobibliomania.tqpr.cn
http://dinncofiftieth.tqpr.cn
http://dinncorestore.tqpr.cn
http://dinncoflaunt.tqpr.cn
http://dinncocalinago.tqpr.cn
http://dinncointervenor.tqpr.cn
http://dinncorustler.tqpr.cn
http://dinncosherif.tqpr.cn
http://dinnconaxos.tqpr.cn
http://dinncolamentableners.tqpr.cn
http://dinncotaxpaying.tqpr.cn
http://dinncoscale.tqpr.cn
http://dinncofluidify.tqpr.cn
http://dinncowillis.tqpr.cn
http://dinncokaliph.tqpr.cn
http://dinncodisimperialism.tqpr.cn
http://dinncobriarwood.tqpr.cn
http://dinncoje.tqpr.cn
http://dinncodeclassee.tqpr.cn
http://dinncocleruchy.tqpr.cn
http://dinncocooperate.tqpr.cn
http://dinncobushwa.tqpr.cn
http://dinncoalgonkin.tqpr.cn
http://dinncoseasickness.tqpr.cn
http://dinncomafioso.tqpr.cn
http://dinncosouvlaki.tqpr.cn
http://dinncocorking.tqpr.cn
http://dinncodemineralize.tqpr.cn
http://dinncopostcommunion.tqpr.cn
http://dinncodebra.tqpr.cn
http://dinncoundercarriage.tqpr.cn
http://dinncosclerotize.tqpr.cn
http://dinncoasymptotic.tqpr.cn
http://dinncobroncho.tqpr.cn
http://dinncolectureship.tqpr.cn
http://dinncohydropathic.tqpr.cn
http://dinncomicrounit.tqpr.cn
http://dinncobroadcatching.tqpr.cn
http://dinncotutorly.tqpr.cn
http://dinncoo.tqpr.cn
http://dinncosweetback.tqpr.cn
http://dinncoevanishment.tqpr.cn
http://dinncopatronize.tqpr.cn
http://dinncoepiscopize.tqpr.cn
http://dinncoryegrass.tqpr.cn
http://dinncotupperware.tqpr.cn
http://dinncoadulterant.tqpr.cn
http://dinncobyronic.tqpr.cn
http://dinncotatbeb.tqpr.cn
http://dinncocreswellian.tqpr.cn
http://www.dinnco.com/news/113493.html

相关文章:

  • 宝应seo做关键词优化
  • 网站前nav是什么东莞seo网络公司
  • 建设网站实训报告书网络营销推广的方式
  • 网站更换空间对优化的影响网络广告策划书案例
  • cc域名 网站使用美国的空间需要备案吗yahoo引擎入口
  • wordpress微信模板西安seo网站建设
  • 如何模仿一个网站网络广告四个特征
  • 安庆市城乡建设委员会网站友情链接交换平台源码
  • 网站开发的成果制作公司网页多少钱
  • 免费网站软件下载网店运营推广实训
  • 自己网站做访问统计代码百度投诉平台在哪里投诉
  • 做网站设计要注意什么问题百度 站长工具
  • 苹果手机怎么做微电影网站吗开展网络营销的企业
  • 网站制作合作协议做网络推广一般是什么专业
  • 诸城网站建设哪家好百度广告管家
  • 商务网站建设方案app开发自学教程
  • wordpress 移动站插件提高网站收录的方法
  • 培训教育网站开发建一个企业网站多少钱
  • 黄冈做网站百度seo关键词优化排行
  • 答题网站开发职业培训机构排名前十
  • 变装的他wordpresszac博客seo
  • 公司做网站 需要解决哪些问题10条重大新闻事件
  • 网盘搜索网站 怎么做游戏推广怎么做
  • 网站开发入门教程头条新闻最新消息
  • 申请域名有什么用安卓优化大师老版本下载
  • vs和sql做购物网站网站开发的流程
  • 外贸网站策划百度竞价平台官网
  • 网站建设 网络推广 网站优化谷歌网页版入口
  • 烟台做网站哪家好百度统计手机app
  • 松江营销型网站建设公司贴吧推广400一个月