[USACO09MAR]Moon Mooing】的更多相关文章

嘟嘟嘟 某谷的翻译挺迷的,简单来说就是给一个初值c,然后有两个函数f1 = a1 * x / d1 + b1, f2 = a2 * x / d2 + b2.把c分别带进去,所得的结果也递归带进去,这样的到一串数,输出第n小的. 这道题如果都带进去,然后在排序肯定行不通,因为这一串数不是递增的,不能确定后面多少有比当前数小的. 那或许会想到,可以用一个优先队列维护最小值,这样就避免排序啦.然而数据是4e6,O(nlogn)够强能过啊. 其实没那么难,完全可以用一个普通队列实现这个功能.首先我们建两…
链接:https://ac.nowcoder.com/acm/contest/1086/F来源:牛客网 题目描述 A full moon casts some sort of spell on the cows and, like their cousins the wolves and coyotes, they bay at the moon -- mooing instead of howling, of course. Each 'moo' lasts a certain amount…
1583: [Usaco2009 Mar]Moon Mooing 哞哞叫 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 244  Solved: 126[Submit][Status][Discuss] Description Input 第一行两个数,C和N 第二行3个数,a1,b1,c1 第三行3个数,a2,b2,c2 Output 一个整数代表最长的那一次嚎叫 Sample Input 3 10 4 3 3 17 8 2 Sample Out…
传送门 思想有点像蚯蚓那个题 #include <cstdio> #define N 4000001 #define LL long long #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) LL q1[N], q2[N]; LL a1, b1, d1, a2, b2, d2; int n, h1 = 1, t1 = 1, h2 = 1, t2; int main…
给n<=4000000,c,a1,b1,c1,a2,b2,c2,以c为初始得到的数,每次可以把得到的某个数x进行操作f1(x)=a1*x/c1+b1,f2(x)=a2*x/c2+b2,求最后能得到的数的第n个,保证c1<a1,c2<a2. 由于两个函数都单调递增,而且得到的数也是单调递增的,所以就在答案数组里开两个指针,用两种函数扩展就好啦~ 一开始还以为是分开算的QAQ #include<stdio.h> #include<string.h> #include&…
续.....TAT这回不到50题编辑器就崩了.. 这里塞40道吧= = bzoj 1585: [Usaco2009 Mar]Earthquake Damage 2 地震伤害 比较经典的最小割?..然而一开始还是不会QAQ 和地震伤害1的区别在于这题求的是最少的损坏牧场数目.把牧场拆点,因为要让1和被报告的点不联通,把1归到S集,被报告的点归到T集,就变成求最小割了. 具体建图: 假设点拆成x和x’,x和x‘间连边(就是等下要割的).被报告的点和1点:容量无穷大(不能割):其他点容量为1. 原图中…
接下来要滚去bzoj刷usaco的题目辣=v=在博客记录一下刷题情况,以及存一存代码咯.加油! 1.[bzoj1597][Usaco2008 Mar]土地购买 #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ; int n,cnt,q[N]; long long x[N],y[N],f[N]; struct node{long long x,y;}a[N]; bool…
听说KPM初二暑假就补完了啊%%% 先刷Gold再刷Silver(因为目测没那么多时间刷Silver,方便以后TJ2333(雾 按AC数降序刷 ------------------------------------------------------------------------------------------------------- bzoj1597: [Usaco2008 Mar]土地购买  斜率优化DP h升序,w降序. f[i]=min(f[j]+h[i]*w[j+1])…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
bzoj 1606: [Usaco2008 Dec]Hay For Sale 购买干草——背包 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int read(){ ,f=,c=getchar(); ; c=getchar();} +(c-'); c=getchar();} return ans*f; } ],k; int main() { h=read(); n=…