Codeforces Round #319 (Div. 2) D】的更多相关文章

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…
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…
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…
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 因为保证一定有解,所以基本上不会去卡你…
题目大意:在一个平面里有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…
题意:猜数游戏变种.先选好猜的数,对方会告诉你他想的那个数(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的高度差,另一个是本块最后一个和另一块第一个的高度差.这种做法下相邻两块这两个高度差的和是小…
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…
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,…
直接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…
因为所有整数都能被唯一分解,p1^a1*p2^a2*...*pi^ai,而一次询问的数可以分解为p1^a1k*p2^a2k*...*pi^aik,这次询问会把所有a1>=a1k && a2 >= a2k &&... a3 >= a3k的数从原来的集合中分开.ai表示pi的幂. 那么只有当这个数的素因子的最大幂都被询问过一次,这个数才能确定.因此答案是所有的不大于n的只有一个素因子的数. #include<bits/stdc++.h> using…
水 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…
                                                         B. Modulo Sum                                                                                                  time limit per test 2 seconds                                                    …
                                                 C. Vasya and Petya's Game                                                                                                  time limit per test 1 second                                                  …
                                                                          C. Points on Plane 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 bis said to be the follow…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…