关键词:
1 #include <cstdio> 2 #include <cstring> 3 4 using namespace std; 5 6 int btr[1<<20]; 7 8 9 int main() 10 { 11 int D,I; 12 13 while(scanf("%d%d",&D,&I)==2) 14 { 15 memset(btr,0,sizeof(btr)); 16 17 int k; 18 19 for(int i=1;i<=I;i++) 20 { 21 k=1; 22 23 for(int j=1;j<=D-1;j++) 24 { 25 if(btr[k]==0) 26 { 27 btr[k]=!btr[k]; 28 k=k*2; 29 } 30 else 31 { 32 btr[k]=!btr[k]; 33 k=k*2+1; 34 } 35 } 36 } 37 38 printf("%d ", k); 39 } 40 } 41 42 /* 43 int main() 44 { 45 int D,I; 46 47 while(scanf("%d%d",&D,&I)==2) 48 { 49 int k=1; 50 51 for(int i=1;i<=D-1;i++) 52 { 53 54 55 if(I%2) 56 { 57 k=k*2; 58 I=(I+1)/2; 59 } 60 else 61 { 62 k=k*2+1; 63 I/=2; 64 } 65 } 66 67 printf("%d ",k); 68 } 69 } 70 71 */ 72 73 /* 74 75 int main() 76 { 77 int D,I; 78 79 while(scanf("%d%d",&D,&I)==2) 80 { 81 int k=1; 82 83 for(int i=1;i<=D-1;i++) 84 { 85 86 87 if(I==1) //当题目是第一次左走其他时候又走时代码是这样 88 k=k*2; 89 else 90 { 91 k=k*2+1; 92 I=I-1; 93 } 94 95 } 96 97 printf("%d ",k); 98 } 99 } 100 101 */
第六章部分例题
1#include<iostream>2#include<cstdio>3#include<set>4#include<cstring>56usingnamespacestd;78constintmaxn=1000;9intUG[maxn][maxn];10intvis[maxn];11charstr[1024];12intin[maxn 查看详情
第六章部分例题
6-4自己先敲了一遍虽然可以完成书上的功能但是漏洞百出1#include<iostream>2#include<cstdio>3#include<cstring>45usingnamespacestd;67constintmaxn=100000+100;89chartxt[maxn];10intnext[maxn];1112intmain()13{1 查看详情
第六章部分例题
没看解答敲了一遍,发现自己题目的理解能力有点差 1#include<iostream>2#include<cstdio>34usingnamespacestd;56structNode7{8charvalue;9Node*ch1;10Node*ch2;11Node*ch3;12Node*ch4;1314Node():ch1(NULL),ch2(NULL 查看详情
第六章例题二叉树层次遍历
1.指针实现#include<iostream>#include<vector>#include<queue>#include<cstdio>#include<cstring>usingnamespacestd;#definemaxn100structNode{boolhave_value;intvalue;/*节点结构体*/ 查看详情
机试指南第六章-搜索-例题自解(代码片段)
枚举:枚举是最简单也是最直白的搜索方式,它依次尝试搜索空间中所有的解,测试其是否符合条件,若符合则输出答案,否则继续测试下一组解。例6.1百鸡问题#include<iostream>usingnamespacestd;intmain()intn;while(cin>>n)for(intx=0;x... 查看详情
算法入门经典第六章例题6-5移动盒子
例题6-5移动盒子(BoxesinaLine,UVa127675)问题给定一行盒子,从左到右编号依次为1,2,...,n.可以执行以下命令:1XY 把盒子X移动到Y的左边(如果已经在左边,忽略此命令)2XY 把盒子X移动到Y右边(如果X已经在Y的右边,忽... 查看详情
第六章部分例题双向bfs邻接表和邻接矩阵实现
Idealpath双向bfs输出颜色,邻接矩阵实现 1#include<iostream>2#include<cstdio>3#include<cstring>4#include<queue>5#include<map>6#include<algorithm>78usingnamespacestd;910consti 查看详情
算法入门经典第六章例题6-15给任务排序
假设有n个变量,还有m个二元组(u,v),分别表示变量u小于v。那么,所有变量从小到大排列起来应该是什么样子呢?例如,有4个变量a,b,c,d,若已知a<b,c<b,d<c,则这4个变量的排序可能是a<d<c<b。尽管还有其他可能... 查看详情
算法入门经典第六章例题6-14abbott的复仇(abbott'srevenge)bfs算法实现
SampleInput31N33 11WLNR* 12WLFNRER* 13NLER* 21SLWRNF* 22SLWFELF* 23SFREL* 0SampleOutput(3,1)(2,1)(1,1)(1,2)(2,2)(2,3)(1,3)(1,2)(1,1)(2,1) (2,2)(1,2)(1,3)( 查看详情
第六章
第六章编译预处理三种形式的命令:头文件,文件包含,条件编译命令宏定义:#define #undef emmm写不下去了,下周补回来 查看详情
第六章脑图
第六章项目进度管理
第六章树和二叉树
数学基础——概论第六章
第六章 图(a)概述
html第六章
第六章盒子模型1.什么是盒子模型: CSS中盒子模型的概念就是,CSS将网页中所有元素都看成一个个盒子。 2.盒子模型的边框、内边距和外边距属性:盒子模型的属性图示边框border 内边距Padding外边距margin高heig... 查看详情
第六章 图(b1)邻接矩阵
第六章数组
ArraySegmentSampleusingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceArraySegmentSample{classProgram{staticvoidMain(){int[]ar1={1,4,5,11,13,18};int[]ar2={3,4,5,18,2 查看详情