Codeforces Round #460 (Div. 2) 前三题】的更多相关文章

Problem A:题目传送门 题目大意:给你N家店,每家店有不同的价格卖苹果,ai元bi斤,那么这家的苹果就是ai/bi元一斤,你要买M斤,问最少花多少元. 题解:贪心,找最小的ai/bi. #include <cstdio> using namespace std; double minn=2e9,x,y,M; int N; int read() { '); +c-'; return x; } inline double min(double x,double y){return x<…
这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你我以前的号是灰名),还是挺高兴的,而且t神这场比赛又成第一了. 比赛传送门:http://codeforces.com/contest/1075 A. The King's Race 题意:有一黑一白两个旗子,白的在(1, 1)上,黑的在(n, n)上.每次可以将旗子移动到周围一圈这八个位置,给你三…
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Equation 题目大意:有一个数字n,让你给出任意两个合数a,b满足a - b = n. 我们知道大于2的偶数都是合数,那么如果n为奇数,只要n加上一个奇数合数一定也为合数,如果n为偶数,那么n加上一个偶数合数也一定为合数. 因为只求任意一组,就直接选择4,9,若为奇数输出 +n 和9,偶数输出 +…
题目链接: huangjing hdu5054 Alice and Bob 思路: 就是(x,y)在两个參考系中的表示演全然一样.那么仅仅可能在这个矩形的中点.. 题目: Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 216    Accepted Submission(s): 166 Problem De…
A 题 Vasily the Bear and Triangle 题目大意 一个等腰直角三角形 ABC,角 ACB 是直角,AC=BC,点 C 在原点,让确定 A 和 B 的坐标,使得三角形包含一个矩形,这个矩形一个角在原点,另一个点在 (x, y) 处,并且三角形 ABC 的面积尽量小 将 A B 两点按照 x 坐标从小到大输出 做法分析 A B 两点必然在坐标轴上,且线段 AB 经过点 (x, y),那么简单分类讨论下就行了 交之前犹豫了一下,10分钟才提交... 参考代码 #include…
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
A题 题意:给你 n 个数 , 你需要改变这些数使得这 n 个数的值相等 , 并且要求改变后所有数的和需大于等于原来的所有数字的和 , 然后输出满足题意且改变后最小的数值. AC代码: #include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int _; cin>>_; while(_--){ int n; cin>>n; ]; ; ;i<=n;i++){…
A题 题意:给你 n 个数 , 你需要改变这些数使得这 n 个数的值相等 , 并且要求改变后所有数的和需大于等于原来的所有数字的和 , 然后输出满足题意且改变后最小的数值. AC代码: #include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int _; cin>>_; while(_--){ int n; cin>>n; ]; ; ;i<=n;i++){…
http://codeforces.com/problemset/problem/556/A 题意:给一个01字符串,把所有相邻的0和1去掉,问还剩下几个0和1. 题解:统计所有的0有多少个,1有多少个,最后答案就是两者不同的个数. #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algo…
A题和B题...   A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to opera…
原文链接http://www.cnblogs.com/zhouzhendong/p/8397685.html 2018-02-01 $A$ 题意概括 你要买$m$斤水果,现在有$n$个超市让你选择. 每个超市的水果价格是固定的.第$i$个超市的水果价格用两个整数$a_i和b_i$来表示.含义是$a_i$元可以买$b_i$斤. 问你买$m$斤水果最少花费多少钱. 题解 直接枚举超市,判断最少的花费就可以了. 代码 #include <cstring> #include <cstdio>…
A. Supermarket We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to…
A. Supermarket time limit per test2 seconds memory limit per test256 megabytes Problem Description We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked ho…
A - Elections 题意: 每一场城市选举的结果,第一关键字是票数(降序),第二关键字是序号(升序),第一位获得胜利. 最后的选举结果,第一关键字是获胜城市数(降序),第二关键字是序号(升序),第一位获得胜利. 求最后选举获胜者. 思路: 直接模拟就可以. 代码: /* * @author FreeWifi_novicer * language : C++/C */ #include<cstdio> #include<iostream> #include<cstrin…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果有环 ->直接输出-1 (拓扑排序如果存在某个点没有入过队列,说明有环->即入队的节点个数不等于n 否则. 说明可以做拓扑排序. ->是一个有向无环图. 那么定义f[x][y] 表示x节点前面的某条路径中,字母y出现的最多次数是多少次. 在拓扑排序的时候做DP就好. (可以百度:有向无环图 DP 应该有挺多类似的题的 从入度为0的点开始进行DP. 然后遇到分叉的时候也没关系 取两条路中对应字母的较大值就好. 所以最后…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用pre[i][j]表示第i行前j列的和. 然后枚举连续座位的最左上点. (有两种可能向右或向下k个. 则还需要处理出pre2[i][j]表示第j列前i行的和. (都可以O(N^2)求出 然后pre[i][j+k-1]-pre[i][j-1]就是第i行第j列往右k个格子的空(或被占据)的格子数目了. 看看是不是符合要求就好. 往下扩展同理. k==1的时候只要取向右一种就好.所以直接除个2 [代码] #include <bits…
题目链接: http://codeforces.com/problemset/problem/919/E 题意: 让你求满足 \(na^n\equiv b \pmod p\) 的 \(n\) 的个数. \(2 ≤ p ≤ 10^{6} + 3, 1 ≤ a, b < p, 1 ≤ x ≤ 10^{12}\). 题解: 因为: $n \mod p $的循环节是 \(p\) \(a^{n} \mod p\)的循环节是 \(p-1\).(费马小定理) 所以: \(na^n \mod p​\)的循环节为…
难题不会啊…… 我感觉写这个的原因就是因为……无聊要给大家翻译题面 A. Maximum Square 简单题意: 有$n$条长为$a_i$,宽为1的木板,现在你可以随便抽几个拼在一起,然后你要从这一大块木板中裁出一块最大的正方形. $1 \leq a_i \leq n \leq 1000$ 多测,$T \leq 10$ 给个官网的图: 直接排序然后扫就行了,这数据范围是不是让你想什么神奇东西了? #include <algorithm> #include <iostream> #…
---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recently. The referee has shown n yellow cards throughout the match. At the beginning of the match there were a_1 players in the first team and a_2 players…
E:https://codeforces.com/contest/1088/problem/E dp+贪心 题目大意:选择一个k并且选择k个连通块,要求sigma a[i]/k最大,k尽量大,对于给定的一颗树,输出最大的分数,不用约分的形式.题目意思需要进一步解析,假定有一个最大的连通块,那么根据贪心的思想,肯定是选择这个连通块,但又要求k大,所以把所有大小为这个连通块的dp值都计数一遍,因为我们知道两个最大的连通块不可能有交集,如果有,肯定是交集部分就是最大值部分,其余的部分都是零,那么我们从…
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at…
D. Substring time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's valu…
E. Congruence Equation time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy where a, b, p are all k…
D. Substring time limit per test3 seconds memory limit per test256 megabytes Problem Description You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the mos…
C. Seat Arrangements time limit per test1 second memory limit per test256 megabytes Problem Description Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that…
B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Description We consider a positive integer perfect, if and only if the sum of its digits is exactly 10. Given a positive integer k, your task is to find the k-t…
B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inv…
B. Mashmokh and Tokens time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of…
题意:一个有向图,每个结点 被赋予一个小写字母,一条路径的value等与这条路径上出现次数最多的字母的数目,求该图的最大value 比赛时,用dfs超时,看官方题解用的dp和拓扑排序,a--z用0-25表示,用dp[i][j]表示以第i个结点结尾的路径上第j个字母出现的次数 拓扑排序每排到一个点,就用该点的dp去更新与它相邻点的dp,最开始入度为0的点特殊处理了一下,dp过程中同步更新结果res 也复习了一下拓扑排序 #include<iostream> #include<cstdio&…
Supermarket 找最便宜的就行 Solution Perfect Number 暴力做 Solution Seat Arrangement 注意当k=1时,横着和竖着是同一种方案 Solution Substring dp[i][j]表示在节点i结束,字母j最多有多少个,按拓扑排序的顺序计算 Solution Congruence Equation Solution A Game With Numbers 跟SG游戏解决思路差不多 Solution…