【数据结构】[NOIP2004]FBI树
来源:互联网 发布:django 生鲜教程源码 编辑:程序博客网 时间:2024/05/18 09:31
题目
就是感觉很像线段树那样建树 然后统计01就行了
代码如下
#include<iostream>#include<cstdio>#include<cctype> using namespace std; #define in = read() typedef long long ll; typedef unsigned int ui; const ll size = 1000 + 100; int n; int num0 , num1 , mid , ans; char s[size];inline ll read(){ ll num = 0 , f = 1; char ch = getchar(); while(!isdigit(ch)){ if(ch == '-') f = -1; ch = getchar(); } while(isdigit(ch)){ num = num*10 + ch - '0'; ch = getchar(); } return num*f;}int pow(int a , int b){ ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b >>= 1; } return ans;}void build(int l , int r){ mid = ((l + r)>>1); if(l != r){ build(l , mid); build(mid + 1 , r); } for(register int i=l;i<=r;i++){ if(s[i] == '0') num0 ++; if(s[i] == '1') num1 ++; } if(num0 && num1) printf("F"); else if(!num1) printf("B"); else if(!num0) printf("I"); num0 = 0; num1 = 0;}int main(){// freopen("fbi.in" , "r" , stdin);// freopen("fbi.out" , "w" , stdout); n in; scanf("%s" , s + 1); build(1 , pow(2 , n)); return 0;}//COYG
阅读全文
0 0
- 【数据结构】[NOIP2004]FBI树
- 【CodeVS1094】【NOIP2004】FBI树
- noip2004 FBI树
- FBI树(fbi.cpp)NOIP2004
- |Tyvj|NOIP2004|二叉树|P1440 FBI树
- noip2004 FBI树 (树的后序遍历)
- 【递归】Vijos P1114 FBI树(NOIP2004普及组第三题)
- FBI树(fbi)
- FBI树
- FBI树
- FBI树
- FBI树
- FBI树
- fbi树
- FBI树
- FBI树
- FBI树
- FBI树
- 任重而道远
- RedHat6.5安装MySQL5.7
- 编写一个手机类(Mobile),包括手机品牌(brand)、手机型号(type),方法包括显示手机信息,并编写测试类进行对象的创建
- ACM学习总结之素数与串问题
- 通过rtsp获取H264裸流并保存到mp4文件
- 【数据结构】[NOIP2004]FBI树
- npm --save-dev 和--save区别
- HotSpot虚拟机在堆中对对象分配、布局和访问的全过程
- 白酒走势
- 继承中this关键字和super关键字的作用
- vi编辑器全选删除命令
- 说说JSON和JSONP,也许你会豁然开朗(含jQuery用例)
- Simple implementation of the BinaryTree preorder traversal, inorder traversal, post traversal
- Linux常用调试命令