I - Infinite Improbability Drive
I - Infinite Improbability Drive
http://codeforces.com/gym/241750/problem/I
不断构造,先填n-1个0,然后能放1就放1,最后这个序列的长度就是(1<<n)+n-1,也就是每添加1位就要匹配出来一个。
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
int n;
int a[];
bool vis[];
int ans,t,fin; void in(int &x){
int y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(int x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main(){
freopen("infinite.in","r",stdin);
freopen("infinite.out","w",stdout);
in(n);
fin=(<<n)+n-;
a[n]=;
vis[]=;
For(i,n+,fin){
a[i]=;
t=;
ans=;
for(int j=i;j>=i-n+;j--){
ans+=t*a[j];
t<<=;
}
if(vis[ans]){
vis[ans-]=;
a[i]=;
}
else
vis[ans]=;
}
For(i,,fin)
o(a[i]);
return ; }
I - Infinite Improbability Drive的更多相关文章
- AHCI: Failed to attach drive to Port1 (VERR_GENERAL_FAILURE).
在mac操作系统下,安装VirtualBoxVm虚拟机,虚拟机里面安装wind7操作系统.在启动虚拟机的时候报错:AHCI: Failed to attach drive to Port1 (VERR ...
- vmware安装win7提示No CD-ROM drive to use:GCDROM not loaded
今天安装win7 64位的操作系统到vmware虚拟机,以为一切事如此的简单,因为自己以前经常拿vmware来装系统,结果确出现下面莫名其妙的错误: 提示说没有CD-ROM,可是我明明在vmware的 ...
- Ignite 配置更新Oracle JDBC Drive
如果使用Oracle 12C 作为Ignite 的Repository的话,在Repository Createion Wizard的配置过程中,会出现ORA-28040:No matc ...
- 网盘的选择,百度网盘、google drive 还是 Dropbox
我是国内用户,需要越过Chinawall 我使用的是一枝红杏,用着还行 如果要买,结账时输入'laod80' 一枝红杏官网:官网地址 Dropbox: 稳定,速度快 Dropbox官网:链接 操作十分 ...
- UEFI Bootable USB Flash Drive - Create in Windows(WIN7 WIN8)
How to Create a Bootable UEFI USB Flash Drive for Installing Windows 7, Windows 8, or Windows 8.1 In ...
- Create a SQL Server Database on a network shared drive
(原文地址:http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-sh ...
- Infinite loop when using cookieless session ID on Azure
If you use cookieless session ID and deploy them on Azure, you might get infinite loop when you quer ...
- 【转】Expire Google Drive Files 让Google Docs云盘共享连接在指定时间后自动失效
最近在清理Google Docs中之前共享过的文件链接,发现Google Docs多人协作共享过的链接会一直存在,在实际操作中较不灵活.正好订阅的RSS推送了Pseric写的这篇文章 - Expire ...
- vs2010 A selected drive is no longer valid
visual studio 2010重新安装添加组件,报A selected drive is no longer valid错误. 这个是由于已经安装了sp1,此时需要将sp1卸载掉,然后就可以安装 ...
随机推荐
- mysql中整数类型后面的数字,比如int(11),11代表11个字节吗?
原先对mysql不太理解,但也没有报错.但理解的不够深入.这次补上. 原来以为int(11)是指11个字节,int(10)就是10个字节.我错了. http://zhidao.baidu.com/li ...
- js制作可拖拽可点击的悬浮球
兼容mouse事件和touch事件,支持IE9及其以上 效果展示:https://jsfiddle.net/shifeng/7xebf3u0/ // index.html <!DOCTYPE h ...
- PowerEdge R430 机架式服务器安装( Ubuntu server 14.04.1 、PHP5.5.9、PHP-redis2.8、Phalcon3.1)
未解决问题:换成静态路由的话,怎么就 apt-get udpate 出现错误信息! 解决办法:么有设置网关 一.Ubuntu 系统下载地址: https://certification.ubuntu. ...
- hive 时间函数
使用时发现:1.datediff可以传入timestamp类型参数 官网文档: Date Functions The following built-in date functions are ...
- Linux 定时运行设置
脚本设置位置: /etc/cron.d SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # 每个小时的01分钟执行这个脚本 ...
- Technocup 2019 - Elimination Round 2
http://codeforces.com/contest/1031 (如果感觉一道题对于自己是有难度的,不要后退,懂0%的时候敲一遍,边敲边想,懂30%的时候敲一遍,边敲边想,懂60%的时候敲一遍, ...
- O2O淘宝优惠券代码总结
一.数据集预处理 1.数据读入 import pandas as pd import numpy as np import datetime as date import datetime as dt ...
- Python+Selenium+Unittest框架使用——Selenium——定位元素(二)
1.定位元素(id.name.class.link.partial link) (1)find_element_by_id() 用百度定位测试,用firebug查看定位元素 ,输入框的id为“kw”, ...
- matplotlib 生成 eps 插入到 tex
matplotlib 生成 eps 插入到 tex matplotlib 生成 eps,就可以插入到 tex 中,而且是矢量图,放大不失真. 而且因为图中的元素都是嵌入到 pdf 中,所以图中的文字也 ...
- CVE-2018-19386:SolarWinds数据库性能分析器中反射的XSS
漏洞 在SolarWinds的11.1.457版中,"idcStateError.iwc"错误页面中存在Reflected Cross-Site Scripting漏洞,已经在版本 ...