B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence…
B. Modulo Sum Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/B Description You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such…
                                                         B. Modulo Sum                                                                                                  time limit per test 2 seconds                                                    …
直接O(n*m)的dp也可以直接跑过. 因为上最多跑到m就终止了,因为前缀sum[i]取余数,i = 0,1,2,3...,m,有m+1个余数,m的余数只有m种必然有两个相同. #include<bits/stdc++.h> using namespace std; ; int cnt[maxn]; bool dp[maxn][maxn]; #define Y { puts("YES"); return 0; } int main() { //freopen("i…
Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Description Input Output Sample Input 51 2 1 2 1 Sample Output 1 1 1 2 2 题解:这个题有做慢了,这种题做慢了和没做出来区别不大... 读题的时候脑子里还意识到素数除了2都是奇数,读完之后就脑子里就只剩欧拉筛了,贪心地构造使得前缀和是连续的素数,那…
Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1<=x<=10^9 题解: 送分题…对于每一行,判断是否存在数x即可…也可以枚举x的因子判断是否出现在表内… 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <cstdio> #include <cstring> inline in…
水 A - Multiplication Table 不要想复杂,第一题就是纯暴力 代码: #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int main(void) { int n, x; scanf (&qu…
[题目链接]:http://codeforces.com/contest/577/problem/B [相似题目]:http://swjtuoj.cn/problem/2383/ [题意]:给出n个数,问是否能从中选出一些数,使得这些数的和是m的倍数. [题解]: 首先,先明白这样一个事实: 设:sum%dend=rem; (sum:一些数的和,dend:被除数,rem:余数) 则有:(rem+n)%dend=(sum+n)%dend; (n为一个新的数) 知道了上面的等式之后,题目就好做了:…
E. Product Sum 题目连接: http://www.codeforces.com/contest/631/problem/E Description Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. Thi…
 传送门 Description Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris. There are exactly s blocks in Chris's set, each block has a unique number from 1 to s. Chr…
D. On Sum of Fractions Let's assume that v(n) is the largest prime number, that does not exceed n; u(n) is the smallest prime number strictly greater than n. Find . Input The first line contains integer t (1 ≤ t ≤ 500) — the number of testscases. Eac…
题目链接: 题目 D. Toy Sum time limit per test:1 second memory limit per test:256 megabytes 问题描述 Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris. There are exactly…
B. Invariance of Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/576/problem/B Description A tree of size n is an undirected connected graph consisting of n vertices without cycles. Consider some tree with n vertices. W…
C. Points on Plane Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/576/problem/C Description On a plane are n points (xi, yi) with integer coordinates between 0 and 106. The distance between the two points with numbers a and…
C. Vasya and Petya's Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/C Description Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. P…
A. Multiplication Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/A Description Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column co…
http://codeforces.com/contest/576/problem/C 题目大意: 给你一个曼哈顿距离的图,然后要求你找到一个链,链穿了所有的点 然后要求这链的长度<=25*10e8 思路: 分块分成1000块,每个块内y坐标最多走10e6长度,x坐标最多走n*10e3个,n表示一块内的点数 n是一个二次函数维护的东西……所以大概答案最后就是10e3(10e6+10e6) = 2*10e9 因为保证一定有解,所以基本上不会去卡你…
D. Toy Sum   time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a t…
E. Product Sum   Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. This time the problem is really special. You are given an array a o…
B. Odd Sum Segments time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given an array a consisting of n integers a1,a2,-,an. You want to split it into exactly k non-empty non-intersecting…
传送门 B题题意: 给你n个数,让你把这n个数分成k个段(不能随意调动元素位置).你需要保证这k个段里面所有元素加起来的和是一个奇数.问可不可以这样划分成功.如果可以打印YES,之后打印出来是从哪里开始断开的. 否则打印出NO 题解: 加上奇数可以使和的性质改变,原来使偶数则变为奇数,奇数则变为偶数.加上一个偶数就不会有这样的变化.所以第一步就找出来有多少个奇数.因为要保证k个段的和都为奇数,所以每个段得先有一个奇数 剩下来的奇数数量如果是偶数那就不影响,这样就可以成功划分.如果是奇数那就划分不…
题目大意:在一个平面里有n个点,点坐标的值在1-1e6之间,让你给出一个遍历所有点的顺序,要求每个点走一次,且 曼哈顿距离之和小于25*1e8. 思路:想了一会就有了思路,我们可以把1e6的x,y坐标都分成2000份,每份500,然后这样整个平面就被分成 了2000*2000个区域,然后按区域输出点就行了. #include<bits/stdc++.h> using namespace std; int n; vector<][]; int main() { scanf("%d…
Invariance of Tree 题目大意:给你一个有1-n组成的序列p,让你构造一棵树,如果节点a和b之间有一条边,则p[a]和p[b]之间也有一条边. 思路:没啥思路,看了题解菜爆. 我们可以把1-n个数分到若干个集合里边,一个集合里边的元素要满足按顺序转移改变的性质,如果有其中一个集合的元素等于数量等于1 或者其中一个集合的元素数量等于二,并且没有集合有奇数个元素. 因为我们需要用一个集合当作树的基准来构造,将其他集合的元素 连到这个基准上,所以如果这个基准的元素大于三个他们之间必然成…
E A tree of size n is an undirected connected graph consisting of n vertices without cycles. Consider some tree with n vertices. We call a tree invariant relative to permutation p = p1p2... pn, if for any two vertices of the tree u andv the condition…
等比数列求和一定要分类讨论!!!!!!!!!!!! #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define pii pair<int,int> #define ull unsigned long long using namespace std; ; +; const int inf=0x3f3f3f3f; const L…
题意:猜数游戏变种.先选好猜的数,对方会告诉你他想的那个数(1-n)能不能整除你猜的数,问最少猜几个数能保证知道对方想的数是多少? 对一个质数p,如果p^x不猜,那么就无法区分p^(x-1)和p^x,因此所有p^x如果小于等于n都要猜. 乱码: #pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<string&…
题意:有n个点,找到一个顺序走遍这n个点,并且曼哈顿距离不超过25e8. 由于给的点坐标都在0-1e6之间.将x轴分成1000*1000,即1000长度为1块.将落在同一块的按y排序,编号为奇的块和偶的块一个升序,一个降序.有3个量值得关注.一是同一块中x的变化量,其实是不超过1000*n1,n1是第1块中点的数量.那么1000*n1+1000*n2......=1000*n<1e9.后两个量是同一块中y的高度差,另一个是本块最后一个和另一块第一个的高度差.这种做法下相邻两块这两个高度差的和是小…
C. Vasya and Petya's Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the…
Points on Plane Problem's Link Mean: 在二维坐标中给定n个点,求一条哈密顿通路. analyse: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路的模板,无限TLE. 简单的构造,首先对x坐标设一个阀值,分段输出,从下到上.再从上到下.在从下到上...直到所有点输出完为止. 当然也可横向扫描输出. Time complexity: O(N) Source code:  ;;;;)                  ;}…
Vasya and Petya's Game Problem's Link Mean: 给定一个n,系统随机选定了一个数x,(1<=x<=n). 你可以询问系统x是否能被y整除,系统会回答"Yes"or“No". 问:至少询问多少次可以唯一确定x,并输出询问序列.(special judge). analyse: 做法:求质数的整数次幂(不大于n). 思路:首先我们肯定是用质数来判断,因为质数排除的是最多的. 如果质数p[i]能够整除,那么x有可能是p[i]^2,…