代码
卖女孩的小fo柴
菜鸡上路
展开
-
UVA 10020 Minimal coverage(最小覆盖问题)
Minimal coverage The ProblemGiven several segments of line (int the X axis) with coordinates [Li,Ri]. You are to choose the minimal amount of them, such they would completely cover the segment...原创 2019-02-24 10:35:19 · 159 阅读 · 0 评论 -
哈密顿绕行世界问题(DFS)
一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。Input前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出.Output输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条...原创 2019-02-23 17:25:33 · 104 阅读 · 0 评论 -
HDU 1754 I Hate It--线段树
Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<...原创 2019-02-17 14:52:45 · 85 阅读 · 0 评论 -
FOX and Snake
FOX and Snake time limit per test 2 seconds memory limit per test 256 megabytesFox Ciel starts to learn programmi...原创 2019-02-17 14:19:13 · 191 阅读 · 0 评论 -
poj 1797 Heavy Transportation Dijkstra&&Kruskal
BackgroundHugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cust...原创 2019-02-17 13:36:04 · 175 阅读 · 0 评论 -
CodeForces 432A Choosing Teams(水)
DescriptionThe Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world pro...原创 2019-02-17 11:19:24 · 102 阅读 · 0 评论 -
Constructing Roads--最小生成树
Constructing Roads Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 22124 Accepted: 9431DescriptionThere are N villages, which ...原创 2019-02-17 11:06:58 · 151 阅读 · 0 评论 -
Bus to Udayland
Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytesZS the Coder and Chris the Baboon are travelling to...原创 2019-02-17 11:03:02 · 145 阅读 · 0 评论 -
HDU 1213 How Many Tables--简单并查集
How Many Tableshttp://acm.hdu.edu.cn/showproblem.php?pid=1213Problem DescriptionToday is Ignatius’ birthday. He invites a lot of friends. Now it’s dinner time. Ignatius wants to know how many table...原创 2019-02-17 10:59:51 · 99 阅读 · 0 评论 -
Maximum in table
题目:An n × n table a is defined as follows:The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, …, n.Each of the remaining numbers in the table is equal to t...原创 2019-02-17 10:56:16 · 117 阅读 · 0 评论 -
畅通工程-HDU-1232-并查集
畅通工程Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 74449 Accepted Submission(s): 39627Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定原创 2019-02-10 16:06:44 · 123 阅读 · 0 评论 -
Coin Collector--贪心
#include&lt;iostream&gt;using namespace std;int c[1005];int main(){ int t, n, i, sum, count; scanf("%d", &amp;t); while (t--) { scanf("%d", &amp;n); for (i = 0; i &am原创 2019-01-30 00:01:21 · 128 阅读 · 0 评论 -
Find a way--双起点BFS
#include&lt;iostream&gt;#include&lt;cstring&gt;using namespace std;const int INF=1e7;short map1[205][205];int que[40005],las,fir;int ans[205][205];int ans1[205][205];int N,M;int couKFC,Si,Sj,...原创 2019-01-30 00:01:32 · 82 阅读 · 0 评论 -
贪心算法1
贪心理解题1.在N行M列的正整数矩阵中,要求从每行中选出1个数,使得选出的总共N个数的和最大。输入: 第一行两个正整数N和M,用空格隔开,表示行数和列数 第2行到第N+1行,每行M个用空格隔开的整数 ,表示矩阵输出 最大总和分析:求最大总和,可以分解成每一行取最大的数,这样N行下来总和一定是最大的代码#incl...原创 2019-02-28 20:27:32 · 2574 阅读 · 0 评论 -
HDU 1009 贪心算法之FatMouse
Problem DescriptionFatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.The warehouse has N rooms. The i-th room con...原创 2019-02-28 20:48:31 · 174 阅读 · 0 评论 -
机器学习算法之(一) -- k邻近算法 (kNN) 代码详解 (Python 实现)
kNN 算法:简单来说就是在已知类别的样本中计算与已知点的距离,选取距离最近的k 个样本,再将这k个样本中的多数类作为该已知点的类下面给出伪代码:对未知类比属性的数据集中的每个点依次执行以下操作:(1)计算已知类别数据集中的点与当前点之间的距离(2)按照距离进行升序排序(3)选取与当前点距离最小的k个点(4)确定前k个点所在类别的出现频率(5)返回前k个点出现...原创 2019-08-01 23:19:29 · 331 阅读 · 0 评论 -
两数之和
给定一个整数数组nums和一个目标值target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]题目分...原创 2019-04-03 00:17:31 · 130 阅读 · 0 评论 -
整数反转
给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。示例1:输入: 123输出: 321示例 2:输入: -123输出: -321示例 3:输入: 120输出: 21注意:假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围为[−231, 231− 1]。请根据这个假设,如果反转后整数溢出那么就返回 0。...原创 2019-04-04 00:31:02 · 308 阅读 · 0 评论 -
见证奇迹的时刻
打开方式:emmm.最好找一个电脑上有编译器的。#include<iostream>#include<cmath> using namespace std; int main(){ float x, y; for (y = 1.5f; y >-1.5f; y -= 0.1f) { for (x = -1.5...原创 2019-03-07 14:48:33 · 162 阅读 · 0 评论 -
求(2~1000)一个数的最大质因数
直接暴力枚举,凡是能被2整除的或者既能被2整除也能被3整除的直接输出2,能被3整除的输出3,其余的 按照求质数法则就可以了。#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<string>using namespa...原创 2019-03-04 15:25:33 · 533 阅读 · 0 评论 -
绝对值排序
#include <stdio.h>#include<math.h>#include<algorithm>//for sortusing namespace std;int a[10000];bool cmp(int x,int y)//比较函数,从小到大排序{ if(abs(x)==abs(y)) return x<y;return...原创 2019-03-03 10:26:18 · 174 阅读 · 0 评论 -
求最小公约数和最小公倍数
#include<iostream>#include<cstdio>using namespace std;//数据没那么大就直接int 就行,刚好做题需求 long long gcd(long long a,long long b)//辗转相除法(欧几里德算法)求最大公约数 { return b ? gcd(b,a%b) : a; }lon...原创 2019-03-03 09:30:02 · 392 阅读 · 0 评论 -
大数相加
简单加法Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others)Problem Description本题很简单,计算a+b的和。Input多组输入数据。每组包括两个非负整数a,b(0<=a,b<10^50)【10^50就是10的50次方的意思】,占...原创 2019-03-02 22:08:00 · 141 阅读 · 0 评论 -
Prediction Contest URAL - 1868
Problem DecriptionAt the ICPC World Finals, four sets of gold medals, four sets of silver medals, and four sets of bronze medals are awarded; thus, top twelve teams win medals.There were few days ...原创 2019-02-25 22:45:27 · 105 阅读 · 0 评论 -
Tempter of the Bone--深搜+剪枝
#include&lt;iostream&gt;using namespace std;int flag,sx,sy,ex,ey,num;int n,m,t,vis[10][10];int dx[]={-1,0,1,0};int dy[]={0,-1,0,1};char map[10][10];int abs(int p){ return p&gt;=0?p:-p;}v...原创 2019-01-30 00:01:43 · 67 阅读 · 0 评论 -
Safecracker-DFS
#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;ctime&gt;#include &lt;set&gt;#include &lt;map&gt;#include &lt;cmath&gt;using names原创 2019-01-30 00:01:53 · 121 阅读 · 0 评论 -
.Pots-BFS
#include <iostream>#include <vector>#include <queue>#include <cstring>using namespace std;const int maxn=500;int a,b,c;int vis[maxn][maxn];struct node{ int x; int y...原创 2019-01-28 23:47:48 · 67 阅读 · 0 评论 -
Escape-BFS
#include <stdio.h>#include <string.h>#include <queue>#include <algorithm>using namespace std;#define ads(x) (x<0?-x:x)int n,m,k,life;int to[5][2] = {0,1,1,0,0,-1,-1,...原创 2019-01-28 23:46:29 · 88 阅读 · 0 评论 -
The Suspects--并查集
#include<iostream>using namespace std;#define maxn 33000int per[maxn],num[maxn],n,m;int a[maxn];void init(){ for(int i=0;i<n;i++) { per[i]=i; num[i]=1; } return;}int find (in...原创 2019-01-28 23:23:01 · 72 阅读 · 0 评论 -
PrimePath---BFS
#include &lt;iostream&gt;#include &lt;cstring&gt;#include &lt;algorithm&gt;#include &lt;queue&gt;#include &lt;cstdio&gt;#define MAXN 10using namespace std;int vis原创 2019-01-28 23:21:48 · 78 阅读 · 0 评论 -
Building a Space Station--最小生成树
Building a Space StationTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 13412 Accepted: 6026DescriptionYou are a member of the space station engineering team, and are assigned a task i...原创 2019-02-01 22:29:37 · 109 阅读 · 0 评论 -
Pearls--dp动态规划
题目:PearlsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3515 Accepted Submission(s): 1753Problem DescriptionIn Pearlania everybody is fo...原创 2019-02-01 21:54:12 · 156 阅读 · 0 评论 -
覆盖的面积
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8245 Accepted Submission(s): 4136Problem Description给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积.Input...原创 2019-01-31 22:08:02 · 530 阅读 · 0 评论 -
HDU 1264 Counting Squares----线段树求面积的并集
Counting SquaresTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1885 Accepted Submission(s): 946Problem DescriptionYour input is a series...原创 2019-01-31 21:02:26 · 127 阅读 · 0 评论 -
A+B problem too
#include<iostream>using namespace std;int main(){ int a,b; while(cin>>a>>b) { int sum=a+b; if (sum%86==0) cout<<"yes"<<endl; else cout<<"no原创 2018-12-07 00:49:09 · 92 阅读 · 0 评论 -
Calculate A +B
**#include<iostream>using namespace std;int main(){ int a,b; while(cin>>a>>b) cout<<a+b<<endl; }**原创 2018-12-06 20:18:26 · 1767 阅读 · 0 评论 -
George and Accommodation
#includeusing namespace std;int main(){int n; //房间数目int p,q; //每间宿舍当前居住人数以及宿舍所能容纳的人数cin>>n;int sum=0; //符合住宿标准的计数器for(int i=1;i<=n;i++){ cin>>p>>q;if((q-p)>...原创 2018-12-05 21:30:36 · 92 阅读 · 0 评论 -
string task
#include&amp;lt;iostream&amp;gt;#include&amp;lt;cstring&amp;gt;using namespace std;int main(){int lens,i,j,sum=0; char*s=new char[100]; cin&amp;gt;&amp;gt;s; lens=strlen(s); for(i=0;i&原创 2018-12-05 18:00:12 · 114 阅读 · 0 评论 -
ASCII码排序 HDU - 2000
**#include<iostream>#define N 3using namespace std;int main(){ int i,j; char str[N]; char temp; while(cin>>str) { for(i=0;i<N;i++) for(j=0;j<N-1;j++) if...原创 2018-12-07 18:24:23 · 91 阅读 · 0 评论 -
计算球体积 HDU - 2002
**#include<iostream>#include<iomanip>using namespace std;#define PI 3.1415927int main(){ double r,volume; //定义半径和体积 while(cin>>r) { cout<<fixed<<setprecision...原创 2018-12-07 17:50:55 · 101 阅读 · 0 评论