CF816A Karen and Morning 题解】的更多相关文章

Content 给定一个时间 \(h:m\),求从现在这个时间开始到下一个离该时间最近的回文时间要多久? 数据范围:\(0\leqslant h\leqslant 23,0\leqslant m\leqslant 59\). Solution 其实 scanf 有个特别的技巧叫做按格式读入,比如说这里我们就可以用 scanf("%d:%d", ...); 来按照 \(h:m\) 的格式读入. 然后,正如我在 CF108A 的题解里面讲的那样,一共的回文时间只有 \(16\) 个(具体是…
题目链接 CF815C Karen and Supermarket 题解 只要在最大化数量的前提下,最小化花费就好了 这个数量枚举ok, dp[i][j][1/0]表示节点i的子树中买了j件商品 i 优惠了 / 没优惠 复杂度是n^2的 因为每次是新儿子节点的siz * 之前儿子几点的siz, 就相当于树上的节点两两匹配,这个匹配只会在lca处计算一次 代码 #include<cstdio> #include<cstring> #include<algorithm> #…
看到这道题,网上没有中文版的官方题解,于是就自己翻译了一遍. 不是机器翻译,是一个字一个字纯手翻译的,如果有错误欢迎指正. 比如我们有一张卡片,三个参数分别是 a1 = 4, b1 = 2, c1 = 3. 方便起见,我们令 p = q = r = 5. 考虑什么样的卡片能够击败这张. 我们可以固定一个参数c,来观察对于不同的c,有什么特殊的性质:   注意在第c个坐标系中,坐标为(a,b)的绿色方格代表一张卡片 (a, b, c) 可以击败我们这张卡片 (4, 2, 3). 因此,对于所有c个…
B. Karen and Coffee time limit per test 2.5 seconds memory limit per test 512 megabytes input standard input output standard output To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, wants to know the opti…
C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level,…
A. Karen and Morning time limit per test 2 seconds  memory limit per test 512 megabytes input standard input output standard output Karen is getting ready for a new school day! It is currently hh:mm, given in a 24-hour format. As you know, Karen love…
On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a lot of goods, but since she is a student her budget is still quite limited. In fact, she can only spend up to b dollars. The supermarket sells n goods…
C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level,…
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the u…
[CF815D]Karen and Cards 题意:一张卡片有三个属性a,b,c,其上限分别为A,B,C,现在有n张卡片,定义一张卡片能打败另一张卡片当且仅当它的至少两项属性要严格大于另一张的对应属性.问在所有可能的卡片中,有多少种能打败这全部n张卡. n,A,B,C<=500000 题解:我们反过来,统计哪些卡片不能打败全部的卡. 我们先确定一个属性c,那么对于某张卡片(ai,bi,ci),如果c<=ci,则要求!(a>ai&&b>bi):如果c>ci,则…
良心赛,虽然我迟了半小时233333. 比赛链接:#869. 呃,CF的比赛都是有背景的……上次是<哈利波特>,这次是<物语>…… [A]巧妙的替换 题意: Karen发现了石头剪刀布的决定性规律,看透了这个游戏的本质,使得石头剪刀布再无奥秘可言. 但是他的哥哥,Koyomi发明了一个新游戏: 他们先选定一个数\(n\),然后选出\(2n\)个互不相同的数,为\(x_{1},x_{2},\cdots,x_{n}\)和\(y_{1},y_{2},\cdots,y_{n}\). 接下来…
传送门 - > \(CF816E\) Karen and Supermarket 题意翻译 在回家的路上,凯伦决定到超市停下来买一些杂货. 她需要买很多东西,但因为她是学生,所以她的预算仍然很有限. 事实上,她只花了b美元. 超市出售N种商品.第i件商品可以以ci美元的价格购买.当然,每件商品只能买一次. 最近,超市一直在努力促销.凯伦作为一个忠实的客户,收到了n张优惠券. 如果凯伦购买i次商品,她可以用i次优惠券降低di美元. 当然,不买对应的商品,优惠券不能使用. 然而,对于优惠券有一个规则…
E. Karen and Supermarket time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a lot of goods, b…
C. Karen and Supermarket     On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a lot of goods, but since she is a student her budget is still quite limited. In fact, she can only spend up to b dollars.…
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我没看,看不懂. 基本思路:我不会. 参考代码:找Oyk老师和Czj老师去. B. The background of water problem 题目大意(大写加粗的水题):给定$N$个学生和他们$K$个科目的成绩$S_i$,再给出各科目$K_i$的权重顺序$Q_i$,求排名之后,拥有id为$X$的…
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <…
2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2561 Description 给定一个边带正权的连通无向图G=(V,E),其中N=|V|,M=|E|,N个点从1到N依次编号,给定三个正整数u,v,和L (u≠v),假设现在加入一条边权为L的边(u,v),那么需要删掉最少多少条…
Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring Painting standard input/output 1 s, 256 MB    x2519 C Money Transfers standard input/output 1 s, 256 MB    x724 D Tree Construction standard input/outp…
题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练. 题解: E666 这个题是让求有多少个子串只含有6.寻找连续的6,然后用n*(n+1)/2求出这一段的子串个数,然后把每一段连续的加起来. 做的时候wa了很多次,原来是在n*(n+1)的地方已经超过int型了,所以需要设置类型为long long. #include <cstdio> #inc…
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 57    Accepted Submission(s): 49 Problem Description Recently, paleoanthropologists have found historical remains on an…
http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minecraft方块地图上(由很多1*1*1的方块搭起来的地图,最高5000),其中两块分别有高0.5米的激光塔,有一个高0.5米的机器人要从其中一个激光塔走到另一个.要求只能走相邻4个方向,每次不能爬上超过1格或跳下超过3格(咦,好像真的很像minecraft),要求每走到一个格子,机器人站在在这个格子的…
学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或者SPFA跑出来s-t最短路,然后把最短路DAG上的每条边的容量设为1,跑最小割即可. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #define INF ((~(…
求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & \equiv & a_2 \pmod{p} \\ & \vdots & \\ \sum_{i=1}^n x_i^n & \equiv & a_n \pmod{p}\end{array} \] 的解,或输出"NO". 题解 构造多项式\(\prod_i…
题意请看absi大爷的blog http://absi2011.is-programmer.com/posts/200920.html http://absi2011.is-programmer.com/posts/200822.html DAY1 T1 最优比率树形DP? 跟最优比率生成树很像..二分Σp/Σs(暂定为f 判定过程:每个点得到一个新权值f*p[i]-s[i] 做树形dp,dp[i][j]表示以i为根的子树选j个点能得到的最大权值 dp[root][k]>0则为合法 T2 T3…
又恬不知耻的开始写题解了,暑假到了,QAQ然而想我这样的弱逼是没有暑假的sad,还是老老实实刷题吧. 题目大意:给一个小车的宽度和长度和两条道路的宽度,判断小车能否通过. 思路:可以先看下面的图,我们可以得到高度h的表达式和角度 要使汽车能转过此弯道,那么就是汽车的左边尽量贴着那个直角点,而汽车的右下后方的点尽量贴着最下面的边. 我们以O点为原点建立直角坐标系,我们可以根据角a给出P点横坐标的函数F(a)   那么很容易得到:   其中有条件:,可以很容易证明是一个单峰函数,也可以不用证明,自己…
h3 { font-family: Consolas; color: #339966 } .math { font-family: Consolas; color: gray } 题目描述 Description Z小镇是一个景色宜人的地方,吸引来自各地的观光客来此旅游观光.Z小镇附近共有N(1<N≤500)个景点(编号为1,2,3,-,N),这些景点被M(0<M≤5000)条道路连接着,所有道路都是双向的,两个景点之间可能有多条道路.也许是为了保护该地的旅游资源,Z小镇有个奇怪的规定,就是对…
[前言] 感觉稍微有些滑稽吧,毕竟每次练的题都是提高组难度的,结果最后的主要任务是普及组抱一个一等奖回来.至于我的分数嘛..还是在你看完题解后写在[后记]里面.废话不多说,开始题解. 第一题可以说的内容不是很多吧.直接暴力,计算每种铅笔需要花费的金额. 只不过计算的时候,需要注意如下问题 如果不是整数倍,除完后要加1 神奇的Linux系统,很多人的第三个点wa了,所以要养成良好的编写代码的习惯 Code(我的源程序) #include<iostream> #include<fstream…
机器翻译 题解:模拟 #include <cstdio> #include <cstring> ; ], ]; int main(){ memset(, sizeof(in)); scanf(; ; i<m; i++){ scanf("%d", &cj); if (~in[cj]) continue; Pri ++; <=n) now ++, in[cj] = i; else { MinV = 0x3f3f3f3f; ; j<=MAXN…
四.应用题 ( 本大题共5 小题,50 分 ) 1. 假设某系统中有五个进程,每个进程的执行时间(单位:ms)和优先数如下表所示(优先数越小,其优先级越高). 进程 执行时间 优先数 P1 P2 P3 P4 P5 10 1 2 1 5 3 1 5 4 2 如果在0时刻,各进程按P1.P2.P3.P4.P5的顺序同时到达,请回答以下问题:(12分) (1)当系统采用先来先服务调度算法时: 进程执行顺序是      p1 p2 p3 p4 p5      平均周转时间是  13.4ms (2)当系统…
啊啊啊啊啊啊今天已经星期三了吗 那么,来一波题解吧 本题地址http://www.luogu.org/problem/show?pid=1006 传纸条 题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸运的是,他们可以通过传纸条来进行交流.纸条要经由许多同学传到对方手里,小渊坐在矩阵的左上角,坐标(1,1),小轩坐在矩阵的右下角,坐标(m,n).从小渊…