codevs1094FBI树80
来源:互联网 发布:知远战略与防务论坛 编辑:程序博客网 时间:2024/05/16 06:42
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>struct Node{char *p_data;int m_len;Node *p_left;Node *p_right;};void PrintNode(Node *pNode){int len = pNode->m_len;int sum = 0;while (len){sum += pNode->p_data[len - 1] - 48;--len;}if (sum == pNode->m_len)printf ("I");else if (sum == 0)printf ("B");elseprintf ("F");}Node* BuildTree(char* str, int len){Node *pNode = (Node*)malloc(sizeof(Node));pNode->m_len = len;pNode->p_data = str;if (len >= 2){pNode->p_left = BuildTree(str, len / 2);pNode->p_right = BuildTree(str + len / 2, len / 2);}PrintNode(pNode);return pNode;}int main (){int n;scanf("%d", &n);scanf("%*[^\n]");scanf("%*c");char buf[100];scanf ("%s", buf);if (pow(2, n) == (unsigned int)strlen(buf)){BuildTree(buf, strlen(buf));printf("\n");}return 0;}
0 0
- codevs1094FBI树80
- qduoj 80 树结构重逢(树形DP)
- 80
- 80
- 80
- 80
- 80
- 80
- 80
- 一周消息树:80%开发者背井离乡,70%经常加班
- [CodeForces #80 Div 1 D] 分块+树状数组/线段树
- BestCoder Round #80 E Road (hdu5669) 【线段树+分层图最短路】
- 80自语
- 80后
- 80后
- 《80后传》
- 80后
- After 80
- linq to sql 时间类型的查询
- codevs1074食物链
- Linux开发平台的搭建之SecureCRT
- ListView原理简单介绍(着重介绍getView被调用的一系列过程)
- quick-cocos2d-x里的MVC
- codevs1094FBI树80
- 程序员表白程序
- B\S备忘录01——此吧神兽“焰正马 ”
- 网易游戏2015雷火事业部实习招聘会笔记
- 阅读深入理解计算机系统(三)--------------- 虚拟存储器
- scipy入门
- java 装饰设计模式
- 插入法排序
- codevs1163访问艺术馆