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卸载掉,然后就可以安装 ...
随机推荐
- 010-1 Socket地址族AddressFamily
AddressFamily地址组成员 成员名称 说明 AppleTalk AppleTalk 地址. Atm 本机 ATM 服务地址. Banyan Banyan 地址. Ccitt 对于 CCITT ...
- zipline框架--简介
Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zip ...
- JavaWeb处理GET、POST时的编码乱码问题
对于GET方法,只要设置了res.setContentType("text/html;charset=UTF-8"), req.getParameter()就不会产生乱码. 对于P ...
- idea编译错误提示编译版本不对,需要注意的配置
- python matplotlib 简单生成图
import numpy as np import pandas as pd from matplotlib import pyplot as plt data = pd.DataFrame([[1, ...
- 也写dateUtil.js
yl.dateUtil = { /** * y 年 * M 月 * d 日 * H 时 h 时(am/pm) * m 分 * s 秒 * S 毫秒 * a 上午/下午(am/pm) * setInte ...
- dotnet core使用开源组件FastHttpApi进行web应用开发(转)
FastHttpApi相对于asp.net mvc来说有着更轻量和性能上的优势,性能上面就不在这里介绍了(具体可查看 https://github.com/IKende/FastHttpApi). ...
- ubuntu server 16.04 安装过程中提示无法安装busybox-initramfs
这个问题在安装desktop版本时是不会出现的,只有server才有这个问题. 出现这个问题与硬件平台无关,不管是虚拟机还是物理机都会出现,解决的办法是在安装开始界面选择English,后面Langu ...
- .Net core----使用容联云短信推送
一直在忙于写接口,也没有时间去好好的整理的一片文档,写一篇经常的用到的短信推送案例 还是比较喜欢干货 作为有个程序员 有时候复制粘贴习惯了 实在的还是比较实在 比如能用复制解决的为什么不用复制 ...
- 收藏vue技术内幕
http://hcysun.me/vue-design/art/7vue-reactive.html#observer-%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0