C. Alternative Thinking Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/C Description Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary…
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/A Description Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maxi…
题意与分析 (CodeForces - 603A) 这题真的做的我头疼的不得了,各种构造样例去分析性质... 题意是这样的:给出01字符串.可以在这个字符串中选择一个起点和一个终点使得这个连续区间内所有的位取反.求经过处理后最多会得到多少次01变换(可以不连续). 首先求原串的最长01长度,这个太简单了,然后才是重头戏:精彩的构造样例分类讨论环节--如何增加01的最长串? 我们考虑一下反转串的几种情况:1.反转单个连续0/1串的内部:2.反转两个部分连续0/1串与中间的内容(内部无连续串)3.反…
水 A - Uncowed Forces #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; int main(void) { int s[5] = {50, 100, 150, 200, 250}; int m[5], w[5], hs, hu; for (int i=0; i<5; ++i) { sc…
D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/D Description As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State Uni…
B. More Cowbell Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/B Description Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of co…
题意与分析(CodeForces 604B) 题意是这样的:\(n\)个数字,\(k\)个盒子,把\(n\)个数放入\(k\)个盒子中,每个盒子最多只能放两个数字,问盒子容量的最小值是多少(水题) 不要看到这种题目什么都不想,看见最大容量最小值就是起手一个二分,这题运用贪心的思想会更简单. 想一想紫书上有一题是类似的,两个人坐船过河的,也是同样的思路. 我们一定要注意到这样一个结论:如果第一个数没法和某一个数放在一起,那么大于等于它的数一定都只能一个单独的盒子了.设这个数是第\(p\)个,那么就…
Lieges of Legendre 题意:有n堆牛,每堆有ai头牛.两个人玩一个游戏,游戏规则为: <1>从任意一个非空的堆中移走一头牛: <2>将偶数堆2*x变成k堆,每堆x头牛(可以增加牛的个数) 移走最后一头牛的人获胜: 数据:n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109).a1, a2, ... an (1 ≤ ai ≤ 109) 分析:这显然是SG函数与SG定理的应用: SG函数与SG定理:SG[x] = mex(S);其中S是所有x的后继…
B - Moodular Arithmetic 题目大意:题意:告诉你p和k,其中(0<=k<=p-1),x属于{0,1,2,3,....,p-1},f函数要满足f(k*x%p)=k*f(x)%p,f(x)的范围必须在[0.p-1]内,问这样的f函数有多少个. 思路:数学题不会写啊啊啊啊.. 一般这种题和费马小定理有关系,寻找循环节. 我们可以发现当k = 0 是答案为 p ^ (p - 1) k = 1 时答案为p ^ p 否则 首先我们知道f(0) = 0; 我们到最小的 r 使得 k ^…
D. Fish Weight 题目连接: http://www.codeforces.com/contest/298/problem/D Description It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number.…
A. Snow Footprints 题目连接: http://www.codeforces.com/contest/298/problem/A Description There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th blo…
A. Bits Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/484/problem/A Description Let's denote as the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries…
B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers. Unfortunately, the size of a is to…
题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange…
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova's house is an array consisting of nn elements (yeah, this is the first probl…
题目链接:http://codeforces.com/contest/719/problem/B B. Anatoly and Cockroaches time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anatoly lives in the university dorm as many other students do. A…
链接: https://codeforces.com/contest/1272/problem/A 题意: outputstandard output Three friends are going to meet each other. Initially, the first friend stays at the position x=a, the second friend stays at the position x=b and the third friend stays at t…
题目链接:https://codeforces.com/contest/1417/problem/A 题意 给出一个大小为 $n$ 的数组 $a$,每次操作可以选择两个数,然后将一个数加到另一个数上,要求操作后的数不能大于 $k$,问最多可以操作多少次. 题解 除一个最小值外,给每个数一直加最小值. 证明 操作的本质是留下哪一个数,明显留下较小的数更优. 代码 #include <bits/stdc++.h> using namespace std; int main() { ios::syn…
题目链接:https://codeforces.com/contest/1369/problem/E 题意 Lee 有 $n$ 种不同种类的食物和 $m$ 个朋友,每种食物有 $w_i$ 个,每个朋友喜欢吃两种食物 $x_i, y_i$,如果一个朋友被叫去厨房时一个喜欢吃的食物也没有,他就会吃掉 Lee,否则对还有的他喜欢吃的食物一种吃掉一个,问是否存在一个叫朋友去厨房的顺序保证 Lee 不会被吃掉. 题解 设 $s_i$ 为第 $i$ 种食物共需要多少个,若 $w_i \ge s_i$,则喜欢…
题目链接:https://codeforces.com/contest/1369/problem/C 题意 将 $n$ 个数分给 $k$ 个人,每个人分 $w_i$ 个数($\sum_{i = 1}^{k}w_i = n$),每个人的快乐值为分到数的最小值和最大值之和,计算所有人快乐值之和的最大值. 题解 将 $n$ 个数从小到大排序后从两边加起,利用较大的 $w_i$ 跳过尽可能多的较小值. 代码 #include <bits/stdc++.h> using ll = long long;…
C. Recycling Bottles   It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin. We can think Central Perk as coordinate plane. There are n bott…
D. Lazy Student   Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to…
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; +; int n, m; int main() { while( ~scanf("%d %d", &n, &m ) ) { ) { printf("1\n"); continue; } ) printf( ); else…
题目链接 给你一个n∗m的矩阵res,让你输出一个n∗m的矩阵a,这个矩阵满足:给你一个n*m的矩阵res,让你输出一个n*m的矩阵a,这个矩阵满足:给你一个n∗m的矩阵res,让你输出一个n∗m的矩阵a,这个矩阵满足: ai,j代表第i行第j列的元素,通过减小res之后,使得第i行,第j列的所有元素的最大值a_{i,j}代表第i行第j列的元素,通过减小res之后,使得第i行,第j列的所有元素的最大值ai,j​代表第i行第j列的元素,通过减小res之后,使得第i行,第j列的所有元素的最大值 最小…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
E. Distributing Parts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed…
#include<bits/stdc++.h>using namespace std;int order[300007];long long t[300007],ans[300007];int main(){    int n;    long long m; scanf("%d%lld",&n,&m); for(int i=1;i<=n;i++)  scanf("%lld",&t[i]); t[n+1]=2e18; for…
Description Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day…
D. Minimization time limit per test  2 seconds memory limit per test  256 megabytes input  standard input  output  standard output You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You…
贪心,如果m分成的两个区间长度不相等,那么选长的那个区间最接近m的位置,否则选m-1位置,特判一下n等于1的情况 #include<bits/stdc++.h> using namespace std; int main() { int n,m; scanf("%d%d",&n,&m); ){ printf(; } , d2 = n-m; if(d1<d2){ printf(); }else { printf(); } ; }…