POJ 1105 S-Trees (模拟)
来源:互联网 发布:mysql 32位 64位 编辑:程序博客网 时间:2024/05/29 10:31
题意:一颗满二叉树,每个非叶子层用一个变量xi表示。有m条从根结点开始的路线,0表示向左孩子走,1表示向右孩子走,问m条路的最终结点的值。(模拟)
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <queue>#include <cmath>#include <stack>#include <map>#include <string>#define LL long long#define DB double#define SF scanf#define PF printf#define N 1009#define bug cout<<"bug"<<endl;using namespace std;char pth[10];int n,m;char lef[N];char ans[N];int main(){ #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int T = 1; while(~SF("%d",&n)&&n) { char ch[19]; for(int i=1;i<=n;i++) { SF("%s",ch); sscanf(ch+1,"%d",&pth[i]); } SF("%s",lef); SF("%d",&m); int tmp = 0; while(m--) { SF("%s",ch+1); int p = 0; for(int i=1;i<=n;i++) { if(ch[pth[i]]=='0') p*=2; else p = p*2+1; } ans[tmp++] = lef[p]; } ans[tmp] = '\0'; PF("S-Tree #%d:\n%s\n\n",T++,ans); } return 0;}
- POJ 1105 S-Trees (模拟)
- poj 1105 S-Trees 数组模拟建树
- poj S-Trees 1105 (二叉树模拟)
- 【POJ 1105 S-Trees】
- POJ 题目1105 S-Trees(二叉树模拟)
- UVa 712/POJ 1105/ZOJ 1150 S-Trees(用数组模拟二叉树)
- 1105 S-Trees
- 百练 1105: S-Trees
- zoj S-Trees 1150 (二叉树模拟)
- S-Trees
- POJ 2081 Recaman's Sequence(模拟/暴力)
- POJ 1107 W's Cipher(模拟)
- POJ 2528 - Mayor's posters(模拟)
- 【模拟+思维】hdu5200 Trees
- UVa 712 S-Trees
- poj1105 S-Trees
- 712 - S-Trees***
- UVa 712 - S-Trees
- android dev ------ Android开发之广播机制
- Win7(32位)下安装vs2010安装失败Error code -939523550
- PHP网站安全,PHP程序安全的几个措施
- 简单有效-禁止其他人到你电脑上用QQ
- 初学opencv小记-对像素的操作
- POJ 1105 S-Trees (模拟)
- java遍历Properties并排序输出
- 表达式语言内置对象
- PHP使用Yii框架写一个不间断执行的脚本
- 你应该知道的CSS文字大小单位PX、EM、PT
- 隐藏在JPG图片EXIF头部中的恶意软件
- mysql存储过程的参数名不要跟字段名一样
- GNU Makefile学习专题(二) | 第二个实例
- shell script 中#!的作用和读法