https://www.luogu.org/problem/show?pid=2639 题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H <= 45,000)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N (1 <= N <= 500)捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更…
题目传送门 这也是个01背包,只是装的很... #include<bits/stdc++.h> #define MAXN 45010 using namespace std; int f[MAXN],w[MAXN],c[MAXN],n,v; int main(){ scanf("%d%d",&v,&n); ;i<=n;i++) scanf("%d",&w[i]); ;i<=n;i++) for(int j=v;j>…
[洛谷P2584][ZJOI2006]GameZ游戏排名系统题解 题目链接 题意: GameZ为他们最新推出的游戏开通了一个网站.世界各地的玩家都可以将自己的游戏得分上传到网站上.这样就可以看到自己在世界上的排名.得分越高,排名就越靠前.当两个玩家的名次相同时,先上传记录者优先.由于新游戏的火爆,网站服务器已经难堪重负.为此GameZ雇用了你来帮他们重新开发一套新的核心. 排名系统通常要应付三种请求:上传一条新的得分记录.查询某个玩家的当前排名以及返回某个区段内的排名记录.当某个玩家上传自己最新…
参考:https://phqghume.github.io/2018/05/19/%E8%87%AA%E9%80%82%E5%BA%94%E8%BE%9B%E6%99%AE%E6%A3%AE%E6%B3%95/ 以及洛谷不多的题解. 辛普森推导过程就看参考吧,当然你要想看懂推导需要: 1.会高中导数那点东西,至少知道原函数怎么求. 2.粗略了解定积分. 3.知道微积分第一.第二基本定理(从知乎上找的:https://www.zhihu.com/question/21439225). 然后推导就很…
洛谷1387 dp题目,刚开始写的时候使用了前缀和加搜索,复杂度大概在O(n ^ 3)级别,感觉这么写还是比较对得起普及/提高-的难度的..后来看了题解区各位大神的题解,开始一脸mb,之后备受启发. 设dp[i][j]表示以(i, j)为右下点的正方形的最大边长,则转移方程如下: dp[i][j] = min{dp[i-1][j], dp[i][j-1], dp[i-1][j-1]} + 1 (a[i][j] == 1) dp[i][j] = 0 (a[i][j] == 0) 转移非常简单,但是…
题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H <= 45,000)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N (1 <= N <= 500)捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更多的干草.很自然地,每捆干草只能被吃一次(即使在列表中相同的重量可能出现2次,但是这表示…
题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H <= 45,000)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N (1 <= N <= 500)捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更多的干草.很自然地,每捆干草只能被吃一次(即使在列表中相同的重量可能出现2次,但是这表示…
题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H <= 45,000)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N (1 <= N <= 500)捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更多的干草.很自然地,每捆干草只能被吃一次(即使在列表中相同的重量可能出现2次,但是这表示…
题目传送门 这题和01背包最大的区别在于它没有价值,所以我们可以人工给它赋一个价值,由于要求体积最大,把价值赋成体积即可.顺带一提,这题数据范围很大,二维会MLE,要压缩成一维才可以AC 下面给出参考程序: #include<iostream> using namespace std; ],v[],w[]; int main() { cin>>n>>m; ;i<=m;i++) { cin>>v[i]; w[i]=v[i]; } ;i<=m;i++…
P2376 [USACO09OCT]津贴Allowance 题目描述 作为创造产奶纪录的回报,\(Farmer\) \(John\)决定开始每个星期给\(Bessie\)一点零花钱. \(FJ\)有一些硬币,一共有\(N(1<=N<=20)\)种不同的面额.每一个面额都能整除所有比它大的面额. 他想用给定的硬币的集合,每个星期至少给\(Bessie\)某个零花钱的数目\(C(1<=C<=100000000)\).请帮他计算他最多能支付多少个星期的零花钱. 输入输出格式 输入格式:…
P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer's land. He raises delicious papaya fruit, which is a delicacy for cows. The papaya jungle is partitioned into a grid of squares with R rows and C col…
P2959 [USACO09OCT]悠闲漫步The Leisurely Stroll 题目描述 Bessie looks out the barn door at the beautiful spring day and thinks to herself, 'I'd really like to enjoy my walk out to the pastures for the tender spring grass.' She knows that once she leaves the b…
P2960 [USACO09OCT]Milkweed的入侵Invasion of the Milkweed 题目描述 Farmer John has always done his best to keep the pastures full of luscious, delicious healthy grass for the cows. He has lost the battle, though, as the evil milkweed has attained a foothold…
P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer's land. He raises delicious papaya fruit, which is a delicacy for cows. The papaya jungle is partitioned into a grid of squares with R rows and C col…
题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and returns. She is curious as to just how mu…
题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H ( <= H <= ,)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N ( <= N <= )捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更多的干草.很自然地,每捆干草只能被吃一次(即使在列表中相同的重量可能出现2次,但是这表示的是两捆干草,其中每…
P1339 [USACO09OCT]热浪Heat Wave 题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy delicious dairy products. Farmer John is leading the charge to delive…
https://www.luogu.org/problem/show?pid=2957 题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out a…
题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive integers I (1 <= I <= 10^60) for which Bessie must determine their parity (explained in second grade as 'Even... or odd?'). Bessie is overwhelmed by the…
题目传送门 这道题实际非常简单好奇是怎么变黄的... 其实也就是一个SPFA,本人非常懒,不想打邻接表,直接用矩阵就好啦... #include<bits/stdc++.h> using namespace std; ][],m,fr,to; void add(int x,int y,int z){a[x][y]=z;} ]; ]; queue<int> q; void SPFA(int from){ vis[; q.push(; while(!q.empty()){ ; q.po…
https://www.luogu.org/problemnew/show/P2376 看了题解做的,根本不会贪心.. #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back t…
题目链接:https://www.luogu.org/problemnew/show/P1339 解题思路: 一道简单的最短路水题,dijkstra解法模板思路:https://www.cnblogs.com/lipeiyi520/p/10340361.html AC代码: #include<bits/stdc++.h> using namespace std; const int ff=0x3f3f3f; ][],a,b,c; ]; ]; void dij(int s){ memset(vi…
题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy delicious dairy products. Farmer John is leading the charge to deliver plenty of ice cold nutritiou…
[题解] 最短路.那么直接写dijkstra就好了. #include<cstdio> #include<algorithm> #include<cstring> #define LL long long #define rg register #define N 200010 using namespace std; int n,m,s,t,tot,last[N],dis[N],pos[N]; struct edge{ int to,pre,dis; }e[N<…
思路:裸SPFA过一遍(建议使用邻接链表存储),无向图,无向图,无向图,重要的事情要说三遍!!!蜜汁RE是什么鬼????第九个点数组开到20K,第十个点数组开到30K才AC.或许我代码写的有bug?(逃 CODE: #include<iostream> #include<queue> using namespace std; queue<int>q; struct Edge{ int pre,to,w; }edge[]; ]; ]; ]; int T, C, Ts, T…
题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy delicious dairy products. Farmer John is leading the charge to deliver plenty of ice cold nutritiou…
题目链接 https://www.luogu.org/problemnew/show/P1339 最短路 解题思路 dijkstra直接过 注意: 双向边 memset ma数组要在读入之前 AC代码 #include<iostream> #include<cstring> using namespace std; int n,m,ts,te; ]; ]; ][]; int main(){ cin>>n>>m>>ts>>te; mem…
嗯... 题目链接:https://www.luogu.org/problem/P1339 这道题是水的不能在水的裸最短路问题...这里用的dijkstra 但是自己进了一个坑—— 因为有些城市之间可能还没有道路,自己只是将其初始化为0,而应该初始化为0x3f3f,从而表示两个城市之间没有道路... AC代码: #include<cstdio> #include<iostream> #include<algorithm> #include<cstring>…
AC代码 #include<bits/stdc++.h> using namespace std; const int MAXN=62000+10,INF=999999; struct Edge{ int u,v,w,next; }edge[MAXN]; int head[MAXN],n,m,s,t,dist[MAXN],cnt; bool vis[MAXN]; void addedge(int x,int y,int z){ edge[cnt].u=x; edge[cnt].v=y; edg…
https://www.lydsy.com/JudgeOnline/problem.php?id=4071 https://www.luogu.org/problemnew/show/P3644 http://uoj.ac/problem/112 一条东西走向的穆西河将巴邻旁市一分为二,分割成了区域 A 和区域 B. 每一块区域沿着河岸都建了恰好 1000000001 栋的建筑,每条岸边的建筑都从 0 编号到 1000000000.相邻的每对建筑相隔 1 个单位距离,河的宽度也是 1 个单位长度…