题意:你在一家公司工作\(t\)天,负责给饮水机灌水,饮水机最初有\(k\)升水,水的范围必须要在\([l,r]\)内,同事每天白天都会喝\(x\)升水,你在每天大清早可以给饮水机灌\(y\)升水,问你在公司工作的这几天内,饮水机会不会发生故障. 题解:假如\(x>=y\),那么,我们贪心的思路一定是每天让水减的尽可能少,所以每天都要加水,这里要注意第一天的情况,如果第一天加水后大于\(r\)话,那么第一天大清早是不能加水的,这里我们要特判一下,接下来用if判断就行了. 假如\(x < y\)…
D. Wizards and Roads 题目连接: http://www.codeforces.com/contest/167/problem/D Description In some country live wizards. They love to build cities and roads. The country used to have k cities, the j-th city (1 ≤ j ≤ k) was located at a point (xj, yj). It…
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放学我呆到十点然后还要跑回家耽误时间....要不然$D$题就写完了 周末一些成绩好的同学单独在艺术楼上课然后晚上下第一节晚自习和他们在回廊里玩开灯之后再关上一片漆黑真好玩 A.Andryusha and Socks 日常煞笔提.....我竟然$WA$了一次忘了$n<<1$ #include <…
Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<node>::iterator #define sqr(x) (…
Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++.h> using namespace std; int n,m,k; ; int main() { cin>>n>>m>>k; ;i<=k-;++i) { sum+=(n+(m-))*-(i)*; } cout<<sum<<endl;…
A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream> #include<cstdio> #include<cstring> #define def 110 using namespace std; long a[def]; int main() { long _,ans0,ans1,ans2,n,i; for(scanf(&quo…
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \(a=b\) 和 \(a=b-1\) 的时候有解,再加上一个从 \(9\) 越到 \(10\) 的就可以了.被样例的 \(199,200\) 误导了. #include<bits/stdc++.h> using namespace std; typedef long long ll; int mai…
A. Technogoblet of Fire 题意:n个人分别属于m个不同的学校 每个学校的最强者能够选中 黑客要使 k个他选中的可以稳被选 所以就为这k个人伪造学校 问最小需要伪造多少个 思路:记录每个学校都有哪些人 每次看黑客选中的人是不是在学校是最强者(这里要处理能力一样的情况,如果有能力一样的为了保证稳进也要伪造一个学校) 然后就是模拟了 #include<bits/stdc++.h> #define FOR(i,f_start,f_end) for(int i=f_start;i&…
A. Right-Left Cipher time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves ciphers. He has invented his own cipher called Right-Left. Right-Left cipher is used for strings. To encr…
C. Did you mean... time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search…
B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how…
A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros i…
http://codeforces.com/contest/1072/problem/D bfs 走1步的最佳状态 -> 走2步的最佳状态 -> …… #include <bits/stdc++.h> using namespace std; #define ll long long #define minv 1e-6 #define inf 1e9 #define pi 3.1415926536 #define nl 2.7182818284 ; ; struct node {…
https://codeforces.com/contest/1072/problem/D 题意 给你一个n*n充满小写字母的矩阵,你可以更改任意k个格子的字符,然后输出字典序最小的从[1,1]到[n,n]的路径(1<=n<=2000) 思路 我的 定义dp[i][j]为从[1,1]到[i,j]字符串最小的字符串,然后枚举所有i-1+j-1+1<=k的点,然后字符串连接比较,代表更改前面i,j个字符 这种思路有两个问题,如何处理出从[i,j]到[n,n]的最小字典序字符串,第二假如i+j…
A. Search for Pretty Integers 题目链接:http://codeforces.com/contest/872/problem/A 题目意思:题目很简单,找到一个数,组成这个数的数字即在A数组中出现过,也在B数组中出现过,问这个数最小是多少. 题目思路:首先要么一个数两个数组都出现过直接输出来,要么分别取两个数组中最小的数组合一下输出. 代码: //Author: xiaowuga #include <bits/stdc++.h> using namespace st…
A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足条件的a和b,输出a/b最大的a和b. 题目思路:首先a+b=n,那么暴力枚举i和n-i,且gcd(i,n-i)==1,由于i越大是n-i越小,则a/b的值越大. 代码: //Author: xiaowuga #include <bits/stdc++.h> using namespace std…
地址:http://codeforces.com/contest/872/problem/D 题目: D. Something with XOR Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Jury has hidden a permutati…
http://codeforces.com/contest/851/problem/D 分区间操作 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <time.h> #include <string> #include <set> #include <map> #include <list&…
A. k-rounding 题目意思:给两个数n和m,现在让你输出一个数ans,ans是n倍数且末尾要有m个0; 题目思路:我们知道一个数末尾0的个数和其质因数中2的数量和5的数量的最小值有关系,所以我们可以把n中的2和5的因子数量分别算出来,然后看一下是否都大于等于m,否则我们就把他们补成m个.然后再乘回去就结束了. 题目链接:http://codeforces.com/contest/861/problem/A 代码: /* *********************************…
http://codeforces.com/contest/782/problem/E 题目大意: 有n个节点,m条边,k个人,k个人中每个人都可以从任意起点开始走(2*n)/k步,且这个步数是向上取整的.要求:着k个人要走完所有的节点,且每个人至少走1步. 思路:= =dfs找一棵树,一棵树是n-1条边,所以从树根开始走完所有的,也就只有n*2-2步,所以不会达到上限.md这么简单都没有想到,233 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #incl…
http://codeforces.com/contest/782/problem/D 题意: 每个队有两种队名,问有没有满足以下两个条件的命名方法: ①任意两个队的名字不相同. ②若某个队 A 选用了第二种队名,那么如果队 B 的第一种队名和队 A 的相同,那么同样不能选择.当然,队B的第二个队名无所谓 思路: 学习了2-sat发现这题这么简单= =. 如果那天A了这题就前200了 //看看会不会爆int!数组会不会少了一维! //取物问题一定要小心先手胜利的条件 #include <bits…
地址:http://codeforces.com/contest/782/problem/E 题目: E. Underground Lab time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The evil Bumbershoot corporation produces clones for gruesome experimen…
地址:http://codeforces.com/contest/782/problem/D 题目: D. Innokenty and a Football League time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Innokenty is a president of a new football league in B…
地址:http://codeforces.com/contest/782/problem/C 题目: C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha goes through a park each day. The squares and…
地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Bytecity is a straight line from…
地址:http://codeforces.com/contest/782/problem/A 题目: A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha is an orderly boy and likes to keep things in their plac…
传送门:http://codeforces.com/contest/1087/problem/C C. Connect Three time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The Squareland national forest is divided into equal 1×11×1 square plots al…
任意门:http://codeforces.com/contest/1058/problem/C C. Vasya and Golden Ticket time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Vasya found a golden ticket — a sequence which consists…
The last stage of Football World Cup is played using the play-off system. There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the…
A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最长我们肯定是取最小x和最大的y连起来就完事. 但是要求长度最小又得覆盖,那么可以这样想,我们需要把最小的x不断右移到这条线段的y, 最大的左移到x,所以就是最大x-最小y完事 #include <bits/stdc++.h> using namespace std; #define ll long…