poj 2756
来源:互联网 发布:java main启动项目 编辑:程序博客网 时间:2024/06/07 15:51
利用二叉树的性质:
lchild=2*parent;
rchild=2*parent+1;
就可以做出来。
#include<stdio.h>int d(int a,int c[]){ int i=0; while(a!=0) { c[i++]=a; a/=2; } return i;}int main(){ int x,y; int i,j,count=0; int a[10],b[10]; scanf("%d%d",&x,&y); x=d(x,a); y=d(y,b); for(i=x,j=y;i>=0&&i>=0;i--,j--) if(a[i]==b[j]) count=a[i]; printf("%d\n",count);}
0 0
- poj 2756
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- SpringMVC-03_SpringMVC基于注解开发
- sgu131:Hardwood floor
- Android 四大组件·五大布局
- Program work 5. 用链表实现矩阵及实现矩阵转置
- linux curl 命令详解,以及实例
- poj 2756
- 软件工程:(五)软件测试
- android一步一步实现视频客户端app(一)
- 移动机器人运动模型
- 十二周项目二 投机取巧的错误程序
- 从开源项目学习 C 语言基本的编码规则
- 感知甘特图
- iOS界面设计切图小结
- 学习笔记:第4章 多媒体基础知识