
算法题解
文章平均质量分 54
FOWng_lp
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
快速排序算法
//快速排序 hoare版本(左右指针法)void QuickSort(int* arr, int begin, int end){//只有一个数或区间不存在if (begin >= end)return;int left = begin;int right = end;//选左边为keyint keyi = begin;while (begin < end){//右边选小 等号防止和key值相等 防止顺序begin和end越界while (arr[en.原创 2021-12-30 15:35:15 · 426 阅读 · 0 评论 -
最小生成树 —— 畅通工程hdu1863
畅通工程Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 53110 Accepted Submission(s): 23698Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若原创 2021-06-19 16:12:28 · 150 阅读 · 0 评论 -
并查集简单应用(红色警报)
https://pintia.cn/problem-sets/994805046380707840/problems/994805063963230208思路这个代码的意思是将图分块,能走通的节点合并为一个集合,记块的总数为num1。然后去掉一个节点后,再次分块,记块的总数为num2。如果num2-1(去掉了单独的一个节点)与num1相等或num2(去掉该节点之后,该节点所在的块仍互通)等于num1,则不影响连通性。#include<cstdio>#include<iostre..原创 2021-04-23 13:53:47 · 162 阅读 · 0 评论 -
7-4 到底是不是太胖了 (10 分)PTA
AC Code#include<cstdio>#include<iostream>using namespace std;typedef long long ll;int main(){ double ans,h,w; int n; cin >> n; while(n--){ cin >> h >> w; ans = (h-100)*0.9*2; if(w >= ans*11/10){ cout <.原创 2021-04-21 19:52:49 · 1175 阅读 · 0 评论 -
翻硬币(蓝桥杯)
AC code#include<cstdio>#include<iostream>#include<algorithm>using namespace std; string a,b; int l=-1,r,ans;int main(){ cin >> a >> b; for(int i = 0;i < a.size();i++){ if(a[i]!=b[i]){ if(l==-1)l = i; els...原创 2021-04-17 11:16:35 · 167 阅读 · 0 评论 -
有点意思的质数题HDU5750
A positive proper divisor is a positive divisor of a number n, excluding n itself. For example, 1, 2, and 3 are positive proper divisors of 6, but 6 itself is not.Peter has two positive integers n and d. He would like to know the number of integers below原创 2021-04-10 17:03:55 · 170 阅读 · 0 评论 -
不错的简单递归题,字符串递归训练
题目链接https://www.luogu.com.cn/problem/P1928点这里Code简单易懂的代码答案#include<cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<string>using namespace std;string dg(){ int cnt; string s="",ss; char c; wh.原创 2020-10-14 14:34:40 · 179 阅读 · 0 评论 -
C++相关基础知识复习
判断闰年#include<cstdio>#include<iostream>#include<algorithm>using namespace std;int main(){ int n,year=1777,month=4,day=29; int a[15]={0,31,28,31,30,31,30,31,31,30,31,30,31}; cin >> n; //for(int i = 1;i <= 12;i++)cout <原创 2020-09-27 16:57:32 · 290 阅读 · 0 评论 -
洛谷P1064 金明的预算方案 终于做出了一道01背包(不会告诉你我瞄了一眼题解)
linkhttps://www.luogu.org/problem/P1064题目描述金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间金明自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过NN元钱就行”。今天一早,金明就开始做预算了,他把想买的物品分为两类:主件与附件,附件是从属于某个主件的,下表就是一些主件与附件的例子...原创 2019-08-01 19:58:33 · 199 阅读 · 0 评论 -
01背包 洛谷P1060 开心的金明 why the for circle should be “n to 0“
题目描述金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过NN元钱就行”。今天一早金明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的NN元。于是,他把每件物品规定了一个重要度,分为55等:用整数1-51−5表示,第55等最重要。他还从因特网上查到了每件物品的价格(...原创 2019-07-26 12:12:04 · 241 阅读 · 1 评论 -
居然搞了好久的水题 完全背包 HDU - 2159
最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗?Inpu...原创 2019-07-19 17:17:22 · 182 阅读 · 0 评论 -
水题 Floyd 简单思维 poj3660
Cow ContestN (1 ≤ N ≤ 100) cows, conveniently numbered 1…N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rat...原创 2019-07-16 16:16:46 · 201 阅读 · 0 评论 -
Til the Cows Come Home 最短路dijkstra
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b...原创 2019-01-26 22:02:38 · 224 阅读 · 0 评论 -
Magic Powder CodeForces - 670 D2 二分法
The term of this problem is the same as the previous one, the only exception — increased restrictions.InputThe first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109) — the ...原创 2019-02-15 10:52:18 · 293 阅读 · 0 评论 -
RMQ——快速求区间内最值
For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things ...原创 2019-01-23 17:01:16 · 338 阅读 · 0 评论 -
字典树入门
想想明天要交10篇题解就有点兴(nan)奋(shou)啊但是今天依旧划水写篇博客休闲一下大佬博客(菜是原罪) 真是太真实了https://blog.youkuaiyun.com/qq_42815188/article/details/88677836题目A prefix of a string is a substring starting at the beginning of the give...原创 2019-07-13 19:55:29 · 164 阅读 · 0 评论 -
今日水题博客第一篇(共十篇) codeforces/problem/645/C
In an attempt to escape the Mischievous Mess Makers’ antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to sta...原创 2019-07-14 19:27:23 · 251 阅读 · 0 评论 -
今日水题博客第三篇(共十篇) CodeForces -689B
http://codeforces.com/problemset/problem/689/BB. Mike and Shortcutstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Mike was very b...原创 2019-07-14 21:06:16 · 167 阅读 · 0 评论 -
Dijkstra堆优化 codeforces/problem/20/C
http://codeforces.com/contest/20/problem/CC. Dijkstra?time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputYou are given a weighted undirected grap...原创 2019-07-15 16:14:50 · 321 阅读 · 0 评论 -
好久没写博客了,冒个泡 敲BFS失败
http://poj.org/problem?id=3669Meteor ShowerTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 30527 Accepted: 7859DescriptionBessie hears that an extraordinary meteor shower is coming; r...原创 2019-07-11 11:16:55 · 175 阅读 · 0 评论 -
poj3268 Silver Cow Party DIJ
One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1…N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roa...原创 2019-07-16 14:09:53 · 178 阅读 · 0 评论 -
一道并查集的水题
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with k vertices and k - 1 edges, where k is some integer. Note that one vertex is ...原创 2019-01-17 22:39:26 · 360 阅读 · 0 评论