CCF 模拟D 动态规划
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 动态规划的更多相关文章
- codeforces 792CDivide by Three(两种方法:模拟、动态规划
传送门:https://codeforces.com/problemset/problem/792/C 题意:给你一个字符串,要求让你删除最少个数的元素,使得最终答案是没有前导0并且是3的倍数. 题解 ...
- CCF 模拟试题——出现次数最多的数 官方答案解析及自己写的正确答案
前几天知道的CCF计算机职业资格认证考试,觉得好像比软考含金量高一些,就去了解了一下,做了模拟试题中的 “出现次数最多的数” 这道题,我的算法和官方答案算法不同,个人觉得觉得官方的好一点,没那么繁琐, ...
- 2018SCin tsyzDay2 模拟赛-动态规划(简单的)
内心OS:简单?????还是我太弱了. 期望得分:100+100+0+0+0+0+随机暴力的点==200 实际得分:0+100+10+0+10+0==120 您知道我第一题为什么错了嘛??文件在混乱中 ...
- CCF模拟题 窗口
窗口 时间限制: 1.0s 内存限制: 256.0MB 问题描述 在某图形操作系统中,有 N 个窗口,每个窗口都是一个两边与坐标轴分别平行的矩形区域.窗口的边界上的点也属于该窗口.窗口之间有层次的 ...
- CCF 模拟E DFS深搜
http://115.28.138.223:81/view.page?opid=5 这道题问的很怪. 起点DFS,每一个点还要DFS一次,统计不能到终点的个数 数据量不大这样做也能AC #includ ...
- CCF 模拟C 找最大矩形+输入输出外挂
http://115.28.138.223:81/view.page?opid=3 统计出连续的最长乘以当前高度,找最大即可 #include<iostream> #include< ...
- CCF 模拟B 无脑循环+输入输出外挂
http://115.28.138.223:81/view.page?opid=2#code 代码一有WA点80分 #include<iostream> #include<cstdi ...
- CCF 模拟A 无脑大循环
http://115.28.138.223:81/view.page?opid=1 第一题用一组STL函数查找即可 #include<iostream> #include<cstdi ...
- noip模拟赛 动态规划
题目描述LYK在学习dp,有一天它看到了一道关于dp的题目.这个题目是这个样子的:一开始有n个数,一段区间的价值为这段区间相同的数的对数.我们想把这n个数切成恰好k段区间.之后这n个数的价值为这k段区 ...
随机推荐
- Construct Bounding Sphere
点集的包围球 http://en.wikipedia.org/wiki/Bounding_sphere http://blogs.agi.com/insight3d/index.php/2008/02 ...
- LeetCode —— Invert Binary Tree
struct TreeNode* invertTree(struct TreeNode* root) { if ( NULL == root ) { return NULL; } if ( NULL ...
- Robot Framework--11 RF结合Jenkins
转自:http://blog.csdn.net/tulituqi/article/details/17846463 为什么我们要引入RF?其实最初我们引入RF是为了能够快速的开展自动化验收测试,为敏捷 ...
- Ansible简介及常用模块
一.基础介绍 1.简介 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统配置. ...
- linux 下 zip unzip压缩与解压
注:*压缩成限.zip格式文件 常用解压缩: [root@mysql test]# unzip -o test.zip -d tmp/ 将压缩文件test.zip在指定目录tmp下解压缩,如果已有相同 ...
- MYSQL权限回收
给予最小权限 grant '; FLUSH PRIVILEGES 查看全部用户:select * from mysql. user \G. 查看权限. mysql> show grants fo ...
- Media Wiki
https://www.mediawiki.org/wiki/Help:Images/zh https://www.mediawiki.org/wiki/Manual_talk:Image_admin ...
- JQuery Easy Ui 可装载组合框 - ComboBox
可装载组合框 - ComboBox 继承自$.fn.combo.defaults,通过$.fn.combobox.defaults覆盖默认值 combobox显示的是一个可以编辑的文本框和一个下拉列表 ...
- 为IIS Express添加MIME映射
VS2013自带IIS Express,无法发布JSON文件,需添加MIME映射. 没有图形界面,只能命令行. 进入C:\Program Files(x86)\IIS Express文件夹,输入:ap ...
- 真正理解linux的inode?
linux 在整个架构上可以看作是三层: 1.底层代码, (引导层strip) 跟硬件沟通的那一层的代码(可能是汇编+c), 驱动底层的; strain: n./v. 拉紧, 张力, 气质, 风格, ...