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,…
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…
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…
                                                 C. Vasya and Petya's Game                                                                                                  time limit per test 1 second                                                  …
因为所有整数都能被唯一分解,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…
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN]; int main(void) //Codeforces Round #…
题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN][MAXN]; int main(void) //Codeforces Round #212 (Div. 2)…
题目传送门 /* 数学:这题一直WA在13组上,看了数据才知道是计算cost时超long long了 另外不足一个区间的直接计算个数就可以了 */ #include <cstdio> #include <cmath> #include <iostream> #include <algorithm> #include <cstring> using namespace std; typedef unsigned long long ull; int…
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <string> #include <queue> #incl…
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…
题意:猜数游戏变种.先选好猜的数,对方会告诉你他想的那个数(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,m,k,在你在(0,0)到(n,m)的矩形内,选3个格点(x,y都是整数),使得三角形面积为n*m/k,不能找到则输出-1 题解:由毕克定理知道,格点多边形的面积必为1/2的整数倍,所以首先n*m/k必须是1/2的整数倍,也就是2*n*m%k要等于0,不等于就输出-1 然后对于面积,我们知道底✖高*1/2=面积,a*b*1/2=n*m/k,我们很显然想到一种构造方法,(0,0),(0,a),(b,0); 有人就要问,会不会有一种,使得无法找到整数a,b,满足这种直角三角形点,…
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/problem/A Description One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks. Accordi…
B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wi…
题目链接:http://www.codeforces.com/problemset/problem/460/A题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子,请问第几天的时候Vasya会没有袜子穿?C++代码: #include <iostream> using namespace std; int n, m; int main() { cin >> n >> m; ; while (n) { d ++; if (n) n --…
C. Vasya and String 题目连接: http://www.codeforces.com/contest/676/problem/C Description High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as th…
题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put o…
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. T…
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each succe…
题目链接: http://codeforces.com/contest/676/problem/C 题解: 把连续的一段压缩成一个数,对新的数组求前缀和,用两个指针从左到右线性扫一遍. 一段值改变一部分的情况考虑的不够周到,wa了两次. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<vect…
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…
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…
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess. T…
C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each succe…
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and fo…
http://codeforces.com/contest/576/problem/C 题目大意: 给你一个曼哈顿距离的图,然后要求你找到一个链,链穿了所有的点 然后要求这链的长度<=25*10e8 思路: 分块分成1000块,每个块内y坐标最多走10e6长度,x坐标最多走n*10e3个,n表示一块内的点数 n是一个二次函数维护的东西……所以大概答案最后就是10e3(10e6+10e6) = 2*10e9 因为保证一定有解,所以基本上不会去卡你…
A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When…