E. Cannon time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland…
time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After t…
D. Persistent Bookcase 题目连接: http://www.codeforces.com/contest/707/problem/D Description Recently in school Alina has learned what are the persistent data structures: they are data structures that always preserves the previous version of itself and a…
题意: 求(x div k) * (x mod k) = n的最小解x,保证有解 1<=n<=1e6, k<=1000,1s 思路: 注意到k的范围是1e3, 1<=x mod k<1e3,这并不能看到x的上限 而x div k要达到1e6,所以x最大可能达到1e9 所以不能枚举x 因为两个因子相乘正好为n,所以我们可以枚举x mod k x mod k<=n且x mod k < k 所以我们只需枚举[1,k)就可以了 此时x mod k = i ,且n%i==0…
题目链接:http://codeforces.com/problemset/problem/724/B 题目大意: 给出N*M矩阵,对于该矩阵有两种操作: (保证,每行输入的数是 1-m 之间的数且不重复) 1.交换两列,对于整个矩阵只能操作一次 2.每行交换两个数. 交换后是否可以使每行都是1-m 数字递增. 解题思路: 1.得到矩阵后先判断,是否每行可以交换两个数可以得到递增的矩阵,如果可以则输出"YES". 2.暴力交换两列,交换两列后,判断每行是否可以交换两个数得到递增的矩阵,…
codeforces 897A Scarborough Fair 题目链接: http://codeforces.com/problemset/problem/897/A 思路: 暴力大法好 代码: #include <iostream> #include <stdio.h> #include <string.h> using namespace std; typedef long long ll; int n,m; string s; int main() { ios…
A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
http://codeforces.com/problemset/problem/348/B 注意到如果顶点的数值确定了,那么它分下去的个数也就确定了,那么可以暴力枚举顶点的数值. 顶点的数值是和LCM相隔的,LCM就是,比如1有三个子节点,那么1的数值起码都是3的倍数,不然不能整除. 同理,1有三个儿子2.3.4.,如果3有三个儿子,那么1就要起码是9的倍数了,因为需要分给3的时候至少是3. 所以算出整颗树的LCM,叶子节点LCM是1,其他的LCM = lcm(所有子节点) * son[cur…
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following proble…
题目描述: Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of n songs. The -th song is characterized by two numbers *t**i* - its length and beauty respec…