[题目]B. Recover the String [题意]找到一个串s,满足其中子序列{0,0}{0,1}{1,0}{1,1}的数量分别满足给定的数a1~a4,或判断不存在.数字<=10^9,答案<=10^6. [算法]数学构造 [题解]首先由a1和a4易得0的数量x0和1的数量x1. 容易发现01和10关系密切,令1的位置为b1...bx1,则: {0,1} (b1-1)+(b2-2)+(b3-3)+...+(bx1-x1)=a2 {1,0} (x0-b1+1)+(x0-b2+1)+...…
题目链接: D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where …
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出一个符合要求的序列; [题解] 这里 00和11可以确定出序列中0和1的个数; 但有边缘数据 00如果为0代表什么? ->没有0或者是有1个0 11如果为0代表什么? ->没有1或者是有1个1 对这两种情况需要特判一下(两种情况的特判需要用到01和10的数量) 看代码吧. 然后这两种情况排除之后;…
A. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) an…
题目链接:http://codeforces.com/problemset/problem/509/D 题意:题目给出公式w[i][j]= (a[i] + b[j])% k; 给出w,要求是否存在这样的数列,若存在则求出a,b 和k 题解:如果有符合条件的点的话那么a[i],b[j]可以任意转换比如说a[i],b[j]可以转化为a[i]-p,b[i]+p.所以只要存在 符合条件的解的a[i]可以为任意值.也就是说a[i]可以先赋值为0然后其他就都可以推出来了,当然开始推出后会发现 有负的,没事,…
B. Recover the String 题目连接: http://www.codeforces.com/contest/708/problem/B Description For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where axy is the number of subsequences of length 2 of…
Recover the String 题目链接:http://codeforces.com/contest/709/problem/D 构造 这题乍一看很难构造,但是如果知道了整个字符串中'0'和'1'的个数n0和n1,就很好构造了: 1.将整个字符串填满'1',在所有的1右边填x个'0',那么'10'就有x*n1个了,一直填到还需要'10'的个数t1小于n1个: 2.再从右边数n1-t1个'1'并在它前面添加一个'0': 3.删去多余的'1'. 如此看来,构造并不困难,难的是判断何时Impos…
D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where axy is…
题意 Split a unique array into two almost unique arrays. unique arrays指数组各个数均不相同,almost unique arrays指可以删掉数后再判断. 思路 略神的数学构造题... 官方题解: An equivalent definition for almost unique, is arrays with at least ⌊ 2n / 3⌋ different elements. The idea is to split…
1.浮点数运算结果不精确 先看如下代码 System.out.println(1.0 - 0.8); System.out.println(0.2 + 0.1); System.out.println(1.0 - 0.8 == 0.2); //false System.out.println(0.2 + 0.1 == 0.3); //false 输出结果为: 0.199999999999999960.30000000000000004falsefalse 发现不是我们想要的正确结果,出现了1.0…