Ivan and Powers of Two time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan has got an array of n non-negative integers a1, a2, ..., an. Ivan knows that the array is sorted in the non-decre…
Ivan and Powers of Two Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 404C Description Valera had an undirected connected graph without self-loops and multiple edges consisting of n ver…
Points and Powers of Two time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output There are nn distinct points on a coordinate line, the coordinate of ii-th point equals to xixi. Choose a subset of…
题解: 将一个数的指数看着一个堆,问题变成这些堆的异或值 分析一个堆的情况,打SG表. #include<stdio.h> #include<string.h> ]; char getsg(int x) { ) return sg[x]; ]= {}; ; i<; i++) { <<i)) { ,tmp=x; ) { <<(t-))) tmp-=<<(t-); t+=i+; } hash[getsg(tmp)]=; } //printf(&…
A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A and B are preparing themselves for programming contests. An important part of preparing for a competition is shar…
传送门 题意: 给出一个整数 n ,问能否将 n 分解成 k 个数之和,且这 k 个数必须是2的幂. 如果可以,输出"YES",并打印出任意一组解,反之输出"NO": 题解: 预备知识补充: 如何求出 num 最少需要多少个2的幂之和? 例如 : num = 3 = 20+21至少需要两个 num = 4 = 22 至少需要一个 num = 17 = 24+20 至少需要两个 根据贪心的思想 : 令 2x ≤ num,求出最大的 x ,那么此时num可以表示为 nu…
实在太冷了今天 taxi :错误原因1 忽略了 1 1 1 1 和 1 2 1 这种情况,直接认为最多两组一车了 2 语句顺序错 double cola: 忘了减去n的序号1,即n-- B. Taxi time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output After the lessons n groups of schoolchi…
题目传送门 题目大意: 一个$n*m$的网格图,每个格子可以染黑色.白色,问每个格子最多有一个相邻格子颜色相同的涂色方案数$n,m<=1e5$ 分析: 首先,考虑到如果有两个相邻的格子颜色相同,那么这两行/列的格子状态就确定了.比如: 在中间两个爱心格子被确定的情况下,第二列和第三列的涂色情况就已经被确定了.实际上,第一列和第四列涂的颜色也确定了.(最后这句话我们留着待会儿分析) 同理,在中间两个星星确定的时候,第二行和第三行的涂色情况也唯一确定.实际上,第一行和第四列涂的颜色也确定了. 假如说…
LINK:Quantifier Question 题面过长 引起不适 读题花了好长时间 对于 和 存在符合不是很熟练 导致很懵逼的做完了. 好在还算很好想.不过wa到了一个坑点上面 自闭一大晌 还以为自己思路错了 看了某个强者的blog才知道自己有个地方没处理好. 题目中明确指出 这种关系运算符只能顺序的添加 也就是说 \(\forall x_2\exists x_1\) 这是不能被表达的 只能表达出\(\exists x_1\forall x_2\) 如果有题目中的f函数 那么后者将会被判定为…
题意: m个水果,n个价格.每种水果只有一个价格. 问如果给每种水果分配价格,使得买的m个水果总价格最小.最大. 输出最小值和最大值. 思路: 贪心. 代码: bool cmp(int a,int b){ return a>b; } string name; map<string,int> mp; int price[200],fruit[200]; int cn; int n,m; int main(){ cin>>n>>m; mp.clear(); cn=0;…
题意: 给一个数X. 起始点为坐标0.第1步跳1格,第2步跳2格,第3步跳3格,.....以此类推. 每次可以向左跳或向右跳. 问最少跳几步可以到坐标X. 思路: 假设X是正数. 最快逼近X的方法是不停向右走.如果越过了X,假设到了X1,则必有X1-X小于最后一步d. 如果X1-X是偶数,将之前的某个x变为-x.则可以到X. 如果X1-X是奇数,因为将之前的某个x变为-x,实际是后退2x格.所以必定要再向右走一步.直到X1-X是偶数.(其实只要走一步或两步) X是负数的情况和X是正数的情况一样.…
C. Ivan and Powers of Two time limit per test 0.5 seconds memory limit per test 256 megabytes input standard input output standard output Ivan has got an array of n non-negative integers a1, a2, ..., an. Ivan knows that the array is sorted in the non…
A. Strange Addition (目前的做法好像做烦了) 统计数的\(mask\),表示个.十.百位上是否是0,共8种数. 枚举8种数组成的所有情况\(2^8\),记录最大数量. B. Continued Fractions 大数.分数运算. C. Ivan and Powers of Two \(map\)模拟即可. D. Olya and Graph \(i\)和\(i+1\)必然连边. \(i\)要连第二条边的话,只能连向\(i+k+1\),并且对于\(j\ge i+k+1\)不能…
A positive integer xx is called a power of two if it can be represented as x=2y, where y is a non-negative integer. So, the powers of two are 1,2,4,8,16,… You are given two positive integers nn and k. Your task is to represent nn as the sumof exactly…
[链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include<cstring> #include<set> #include<qu…
[链接]:CF [题意]:从一堆数中选一个最大子集,使得任意两个数相减的绝对值都是2的幂. [分析]:首先很难的一点,需要想到子集最多只能有三个,四个及以上的子集一定不存在(可以证明).当有三个元素时,则必有其中两对元素之差相等. [代码]: #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2*1e5+5; const ll INF = 2147483647; typedef…
题目连接:http://codeforces.com/problemset/problem/1095/C 题目: C. Powers Of Two time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output A positive integer xx is called a power of two if it can be repres…
题目链接: 传送门 Devu and Partitioning of the Array time limit per test:3 second     memory limit per test:256 megabytes Description You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i.…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
DNA Alignment time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a…
Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r and center in point (x, y).…
Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp has n dice d1, d2, ..., dn. The i-th dice shows numbers from 1 to di. Polycarp rolled all the dice and the sum of n…
 Exam time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspect…
Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard input output standard output In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has n…
请看这个说明http://blog.csdn.net/u014800748/article/details/45914353 #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm> #include<set> #include<vector> #include<queue> #include<cstdlib> #include<cstdio&g…
题目链接:http://codeforces.com/problemset/problem/599/D 题意:定义F(n,m)为n行m列的矩阵中方阵的个数,比如3行5列的矩阵,3x3的方阵有3个.2x2的方阵有8个.1X1的方阵有15个,所以F(3,5)=3+8+15=26.现在告诉你F(a,b)=x中的x,要你求出所有满足要求的a,b,并按a递增的顺序输出. 思路:找出n行m列的矩阵中方阵数量的表达式即可,有些小细节需要注意... code: #include <iostream> #inc…
http://codeforces.com/contest/675/problem/C 题目大意: 给一个环,标号为1-n,然后能从n回到1.让这个环的值为0,最少需要的操作数是多少? 这道题目呀...应该说是自己的问题吧,规律并没有那么难找的,只要我将前缀全部都计算一遍就完全可以找出规律了的...然后竟然没有去那么做. 首先我们分析,最多的次数就是n-1.然后我们再看,因为是一个环,那么如果每次前缀和出现了0,就是说明这一段内可以得到0,那么所移动的次数就可以少1. 然后我们在反过来分析,我们…
In a far away galaxy there are n inhabited planets, numbered with numbers from 1 to n. They are located at large distances from each other, that's why the communication between them was very difficult until on the planet number 1 a hyperdrive was inv…
题意   Mishka想要去一个国家旅行,这个国家共有个城市,城市通过道路形成一个环,即第i个城市和第个城市之间有一条道路,此外城市和之间有一条道路.这个城市中有个首中心城市,中心城市与每个城市(除了自己)之间有一条道路.第城市个城市有一个魅力值,经过一条连接第个和第个城市的道路的费用是,求所有道路的费用之和是多少?   注意:任何两个城市之间最多只有一条路. 思路   先考虑所有中心城市:每条路只能算一遍,那么我们可以得到如下公式:   其中,代表所有城市的魅力值的和,代表已经计算过的中心城市…
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles: It turned out that the circles are equal. NN was very…