2015-2016 Northwestern European Regional Contest I.Identifying Map Tiles(超级技巧+脑洞)
来源:互联网 发布:合战 知乎 编辑:程序博客网 时间:2024/06/05 13:01
【题目链接】:http://codeforces.com/gym/101485/attachments
【分析】
给出一个0,1,2,3的矩阵,然后依次扩展,每次把一个位置分为四块,再依次标号,问最后标号为字符串s的位置的划分次数和位置。
比较坑,刚开始是模拟的,一直改不对,就想别的方法,观察了好久,发现了一种新的方式,那就是:对于一个字符串s,把它化成2进制,怎么化呢?很简单,s[i]是奇数,就把该位置为1,否则就置为0,这样最后二进制表示的数的值就是该处的x值,对于y值,就是把字符串s中s[i]大于等于2的位置置为1,其他位置置为0,这样最后的二进制数表示的值就是该处的y值,而放大次数很明显就是字符串的长度。
【AC代码】
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=31;int m,n;int main(){ char s[N]; int x,y; while(~scanf("%s",s)){ int len=strlen(s); x=0; y=0; int k=1; for(int i=len-1;i>=0;--i) { int a=s[i]-'0'; if(a&1) x+=k; if(a==2||a==3) y+=k; k*=2; //printf("%d %d\n",x,y); } printf("%d %d %d\n",len,x,y); } return 0;}
阅读全文
1 0
- 2015-2016 Northwestern European Regional Contest I.Identifying Map Tiles(超级技巧+脑洞)
- 2015-2016 Northwestern European Regional Contest (NWERC 2015) E
- 2015-2016 Northwestern European Regional Contest (NWERC 2015) 补题
- 2015-2016 Northwestern European Regional Contest (NWERC 2015)
- 2015-2016 Northwestern European Regional Contest (NWERC 2015) 7/11 待补
- 2015-2016 Northwestern European Regional Contest (NWERC 2015) E. Elementary Math
- 2015-2016 Northwestern European Regional Contest 训练总结 【5+2】【待补】
- C-Cleaning Pipes(判断两线段相交+二分图判定) 2015-2016 Northwestern European Regional Contest (NWERC 2015)
- 2014-2015 Northwestern European Regional Contest (NWERC 2014)【solved:7 / 11】
- 2013-2014 Northwestern European Regional Contest (NWERC 2013)
- 2012-2013 Northwestern European Regional Contest (NWERC 2012)【solved:6 / 11】
- 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)
- ACM ICPC 2017 Warmup Contest 4(ACM Northeastern European Regional Contest,Northern Subregion 2015)
- ACM ICPC 2017 Warmup Contest 2(ACM Northeastern European Regional Contest,Northern Subregion 2016)
- 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)题解
- 2014-2015 ACM-ICPC Northeastern European Regional Contest (NEERC 14)
- 2013-2014 ACM ICPC Central European Regional Contest (CERC 13) I题Crane
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)
- 虚拟机下CentOS安装JDK
- Linux中常用操作命令
- 大话设计模式之代理模式
- VS C# WinForm对于EXCEL表的操作
- 嵌入式编程常考的无符号数和有符号数的运算问题
- 2015-2016 Northwestern European Regional Contest I.Identifying Map Tiles(超级技巧+脑洞)
- 菜鸟手记(一)
- GCC编译c语言文件
- 462. Minimum Moves to Equal Array Elements II
- Android 手机卫士(5)从Apache Tomcat服务器获取数据并解析
- 每个架构师都应该研究下康威定律
- 数组
- log4J简单的使用步骤
- git笔记4——上传文件到码云