http://115.28.138.223:81/view.page?opid=4

这道题写的我醉醉的,想建一棵指定深度的树最后统计满足条件的个数

居然没去考虑这样必然超时!!!代码写的也是醉了,把没完成的代码先贴出来,好好嘲讽下自己

(╬▔皿▔)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int floorer,num,lable;//0 none ; 1 1 ; 3 3 ; 4 1&3
bool shine1,shine0,shine3,shit,shit0;
int x[]={,,,};
int y[]={,,,};
int donser1=,donser2=,donser3=,donser4=,donser5=;
bool dong1=false,dong2=false,dong3=false,dong4=false,dong5=false;
void creatree(int lab,int flooor)
{ cout<<"-------->floor:"<<flooor<<"(12)"<<endl;
if((flooor==floorer+)&&shine0&&shine1&&shine3){cout<<"*********************************************";num++;}
if(flooor==floorer+){cout<<endl<<"&return "<<endl<<endl;return;}
if(shit&&shit0)
{
for(int i=;i<;i++)
{
cout<<"lab -1 : "<<y[i]<<"(19)"<<endl;
if(y[i]==){dong1=shine0;shine0=;donser1=;}
if(y[i]==){dong1=shine1;shine1=;lab=;donser1=;}
if(y[i]==){dong1=shine3;shine3=;lab=;donser1=;}
if(flooor==floorer+){cout<<"++++"<<"(23)"<<endl;return;}
int ii=flooor;
creatree(lab,++ii);
if(donser1==){shine0=dong1;donser1=;}
if(donser1==){shine1=dong1;donser1=;}
if(donser1==){shine3=dong1;donser1=;}
}
}
if(lab==)
{
for(int i=;i<;i++)
{
cout<<"lab 0 : "<<x[i]<<"(31)"<<endl;
if(y[i]==){dong2=shine0;shine0=;donser2=;}
if(y[i]==){dong2=shine1;shine1=;lab=;donser2=;}
if(y[i]==){dong2=shine3;shine3=;lab=;donser2=;}
if(flooor==floorer+){cout<<"????"<<"(35)"<<endl;return;}
int ii=flooor;
creatree(lab,++ii);
if(donser2==){shine0=dong2;donser2=;}
if(donser2==){shine1=dong2;donser2=;}
if(donser2==){shine3=dong2;donser2=;}
}
}
if(lab==)
{
for(int i=;i<;i++)
{
cout<<"lab 1 : "<<x[i]<<"(43)"<<endl;
if(x[i]==){dong3=shine3;shine3=;lab=;shit=false;donser3=;}
if(flooor==floorer+){cout<<"...."<<"(45)"<<endl;return;}
int ii=flooor;
creatree(lab,++ii);
if(donser3==){shine3=dong3;donser3=;}
}
}
if(lab==)
{
for(int i=;i<;i++)
{
cout<<"lab 3 : "<<y[i]<<"(43)"<<endl;
if(!y[i]==&&!shine1){shit=true;}
if(y[i]==) {shit=false;dong4=shine1;shine1=;lab=;donser4=;}
if(flooor==floorer+){cout<<"````"<<"(56)"<<endl;return;}
int ii=flooor;
creatree(lab,++ii);
if(donser4==){shine1=dong4;donser4=;}
}
}
if(lab==)
{
for(int i=;i<;i++)
{
cout<<"lab 4 : "<<y[i]<<"(64)"<<endl;
if(flooor==floorer+){cout<<"----"<<"(65)"<<endl;return;}
int ii=flooor;
creatree(lab,++ii);
}
}
}
int main()
{
int n,flooor;
while(cin>>n)
{
floorer=n;
shine1=shine0=shine3=shit=shit0=false;
num=lable=;
flooor=;
creatree(,flooor);
cout<<num<<endl;
cout<<endl<<endl;
cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++";
shine1=shine0=shine3=shit=false;
shit0=true;
creatree(,flooor);
cout<<num<<endl;
cout<<endl<<endl;
cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++";
shine1=shine0=shine3=shit=false;
shit0=true;
creatree(,flooor);
cout<<num<<endl;
}
return ;
}
#include<iostream>
using namespace std;
int main()
{
long long mod=;
long long n;
cin>>n;
long long**donser=new long long*[n+];
for(long long i=; i<n+; i++)
donser[i]=new long long[];
for(long long i=; i<; i++)
donser[][i]=;
/*6种状态
*0--剩013
*1--剩13
*2--剩01
*3--剩3
*4--剩1
*5--无
*/
for(long long i=; i<=n; i++)
{
long long j=i-;
donser[i][]=;
donser[i][]=(donser[j][]+donser[j][]*)%mod;
donser[i][]=(donser[j][]+donser[j][])%mod;
donser[i][]=(donser[j][]+donser[j][]*)%mod;
donser[i][]=(donser[j][]+donser[j][]+donser[j][]*)%mod;
donser[i][]=(donser[j][]+donser[j][]+donser[j][]*)%mod;
}
cout<<donser[n][]<<endl;
return ;
}

CCF 模拟D 动态规划的更多相关文章

  1. codeforces 792CDivide by Three(两种方法:模拟、动态规划

    传送门:https://codeforces.com/problemset/problem/792/C 题意:给你一个字符串,要求让你删除最少个数的元素,使得最终答案是没有前导0并且是3的倍数. 题解 ...

  2. CCF 模拟试题——出现次数最多的数 官方答案解析及自己写的正确答案

    前几天知道的CCF计算机职业资格认证考试,觉得好像比软考含金量高一些,就去了解了一下,做了模拟试题中的 “出现次数最多的数” 这道题,我的算法和官方答案算法不同,个人觉得觉得官方的好一点,没那么繁琐, ...

  3. 2018SCin tsyzDay2 模拟赛-动态规划(简单的)

    内心OS:简单?????还是我太弱了. 期望得分:100+100+0+0+0+0+随机暴力的点==200 实际得分:0+100+10+0+10+0==120 您知道我第一题为什么错了嘛??文件在混乱中 ...

  4. CCF模拟题 窗口

    窗口 时间限制: 1.0s 内存限制: 256.0MB   问题描述 在某图形操作系统中,有 N 个窗口,每个窗口都是一个两边与坐标轴分别平行的矩形区域.窗口的边界上的点也属于该窗口.窗口之间有层次的 ...

  5. CCF 模拟E DFS深搜

    http://115.28.138.223:81/view.page?opid=5 这道题问的很怪. 起点DFS,每一个点还要DFS一次,统计不能到终点的个数 数据量不大这样做也能AC #includ ...

  6. CCF 模拟C 找最大矩形+输入输出外挂

    http://115.28.138.223:81/view.page?opid=3 统计出连续的最长乘以当前高度,找最大即可 #include<iostream> #include< ...

  7. CCF 模拟B 无脑循环+输入输出外挂

    http://115.28.138.223:81/view.page?opid=2#code 代码一有WA点80分 #include<iostream> #include<cstdi ...

  8. CCF 模拟A 无脑大循环

    http://115.28.138.223:81/view.page?opid=1 第一题用一组STL函数查找即可 #include<iostream> #include<cstdi ...

  9. noip模拟赛 动态规划

    题目描述LYK在学习dp,有一天它看到了一道关于dp的题目.这个题目是这个样子的:一开始有n个数,一段区间的价值为这段区间相同的数的对数.我们想把这n个数切成恰好k段区间.之后这n个数的价值为这k段区 ...

随机推荐

  1. JavaScript的闭包原理

    什么是js(JavaScript)的闭包原理,有什么作用? 一.定义 官方解释:闭包是一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分. 个人的理解是 ...

  2. 10月16日上午MySQL数据库基础操作(创建、删除)

    以前用的是鼠标在界面上手动创建,这样创建会比较麻烦,而且还会经常出问题.在其它电脑上要用的话还需要重复操作.所以要使用程序代码操作,能通过代码的就不用手动操作. 在数据库界面选择要用的数据库,双击打开 ...

  3. 9月23日JavaScript作业----日期时间选择

    作业二:日期时间选择 <div style="width:600px; height:100px;"> <select id="year"&g ...

  4. Java数据结构——解析算术表达式

  5. JavaScript学习笔记——BOM_window对象

    javascript浏览器对象模型-windwo对象 BOM Browser Object Model window对象 是BOM中所有对象的核心. 一.属性 1.(位置类型-获得浏览器的位置) IE ...

  6. Robot Framework--11 RF结合Jenkins

    转自:http://blog.csdn.net/tulituqi/article/details/17846463 为什么我们要引入RF?其实最初我们引入RF是为了能够快速的开展自动化验收测试,为敏捷 ...

  7. python 占位符 %s Format

    1.百分号方式 %[(name)][flags][width].[precision]typecode (name)      可选,用于选择指定的key flags          可选,可供选择 ...

  8. JavaScript 五种(非构造方式)继承

    参考链接:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_inheritance_continued.html

  9. 命名不规范引发的DropDownListFor无法选中

    问题的引出: 项目中遇到和以下链接相同的问题,大概可以描述为:后台ViewData["KeyName"],前台Model属性里也有一个字段KeyName,那么DropDownLis ...

  10. linux下google chrome浏览器字体修改

    今天安装了最新的chrome,我是下载的.deb包直接安装的. 安装完后,用chrome浏览页面时,发现字体有的大,有的小,还不清楚. 于是在网上搜索了一下如何设置字体. 1.打开Chrome浏览器. ...