自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

AresDLEX的博客

瘦尽灯花又一WA

  • 博客(28)
  • 收藏
  • 关注

原创 HDU 6318 Swaps and inversions

1、依旧是归并排序逆序对的模板,水题,因为交换次数就是逆序对,直接比较x和y大小就行。2、树状数组也可以做。一、mergeSort#include<cstdio>#include<iostream>#include<algorithm>using namespace std;const int MAXN=1e5;int num[MAXN...

2018-10-22 14:29:00 208

原创 HDU 6025 Coprime Sequence

1、gcd应用,前后缀和思想,水题。2、注意数据大小,暴力循环gcd时间复杂度O(N^2)肯定会爆掉的,前后缀和时间复杂度线性O(N)。#include<cstdio>#include<iostream>#include<algorithm>using namespace std;using LL=long long;const int M...

2018-10-22 14:24:49 225

原创 HDU 5698 瞬间移动

1、组合+逆元,水题。2、也可以找规律,发现杨辉三角(我用的数学推出来的)。3、dp打表后找规律(还没写)数学:#include<cstdio>#include<iostream>using namespace std;using LL=long long;const int mod=1e9+7;const int MAXN=2e5+1;in...

2018-10-22 14:19:42 222

原创 HDU 4911 Inversion

1、归并排序求逆序对,水题。2、最多只能k次操作,剩下逆序对即为mergeSort()-k(与0比较,有可能操作数大于原逆序对)。#include<cstdio>#include<iostream>#include<algorithm>using namespace std;const int MAXN=1e5;int num[MAXN+1...

2018-10-22 13:59:30 212

原创 HDU 2899 Strange Function

1、二分查找常规操作,水题。2、求导可知导函数在[0,100]内单增,[0,100]导函数有0点为函数先减后增,既导函数为0时,此处函数值最小。3、就其实我觉得可以了解一下stl的binarySearch函数。#include<cstdio>#include<iostream>#include<cstring>#include<cmat...

2018-10-22 13:55:29 416

原创 NYOJ 233 Sort it

1、数据不大,1000内,暴力循环写法时间复杂度O(N^2),水题2、归并排序的模板写法,归并排序求逆序对,水题一、暴力写法#include<cstdio>#include<iostream>#include<cstring>using namespace std;const int MAXN=1e3;int dp[MAXN+10];...

2018-10-22 13:34:25 177

原创 HDU 2504 又见GCD

1、GCD应用,水题2、gcd(a,c)==b,已知a和b,从1开始暴力找c(记得条件b!=c)#include<cstdio>#include<iostream>using namespace std;int gcd(int a,int b) { //gcd if(a%b==0) return b; return gcd(b,a%b); } ...

2018-10-22 13:30:07 164

原创 HDU 2199 Can you solve this equation

1、二分查找,水题。2、在0和100中二分找到0点(r-l范围在1e-6间视为0)#include<cstdio>#include<iostream>#include<cmath>using namespace std;double func(double x) { //数值 return 8*pow(x,4)+7*pow(x,3)+2...

2018-10-22 13:27:33 130

原创 HDU 1787 GCD again

1、欧拉函数的应用,水题。2、理解欧拉函数公式的原理,找到因数后记得筛掉倍数,剩下一项记得乘。#include<cstdio>#include<iostream>using namespace std;int euler(int n) { //欧拉函数 int res=n; for(int i=2;i*i<=n;i++) { if(n%i...

2018-10-22 13:23:59 145

原创 HDU 1061Rightmost Digit

1、快速幂取模,水题。2、记得数据范围大小,开long long。3、直接在函数里%10取最后一位,无需增加参变。#include<cstdio>#include<iostream>using namespace std;using LL=long long;LL quickpow(LL a,LL b) { //快速幂取模 LL ans=1; ...

2018-10-22 13:19:34 134

原创 手撸队列&&栈&&链表(暂时未完,需更新)

一、队列 1、普通的队列#include<stdio.h> const int MAXN=1e5+10; struct Queue { //建一个队列 int front,rear; int number[MAXN]; }; Queue Q; void initQueue(Queue &q) { //初始队列 q.front=0;...

2018-10-14 01:31:28 330

原创 HDU 1276 士兵队列

有关队列的应用,水题。可以创造两个队列,模拟报数。#include<cstdio>#include<iostream>#include<queue>#include<algorithm>using namespace std;queue<int> a,b;int main(){ int n,t; cin&gt...

2018-07-21 10:34:28 231

转载 POJ题目分类推荐(很好很有层次感)

OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期:一.基本算法    (1)枚举(poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法    (4)递推    (5)构造法(po...

2018-05-31 03:37:52 614

原创 POJ 4110 圣诞老人的礼物

贪心水题,性价比最高的方式是先选择单位价值最大的糖果,如果超量,就放一部分,不超量就继续放次单位价值大的糖果。#include<cstdio>#include<iostream>#include<algorithm>using namespace std;struct mem { int v,w; double density;};mem ...

2018-04-28 14:59:04 717

原创 HDU 2546 饭卡

1、01背包问题,可以参考HDU 2602 Bone Collector,类似其变形2、以5元为边界,小于5元的直接输出原卡上钱;恰好用到卡上剩余5元时,最后一道菜点最贵的,那么除去5元以外的钱可以相当于一个背包,除去最贵以外的菜可以当做装入背包的东西3、开在外面的数组默认为0,因为忘记循环之后数组值会变,缺少循环内置零语句,一直WA4、忘记自己开的二维数组(有i-1),循环从0开始,又一直WA#...

2018-04-26 03:39:48 169

原创 HDU 2602 Bone Collector

1、01背包问题,可参考博客http://www.cnblogs.com/William-xh/p/7305877.html2、其他背包问题可参考DD牛的“背包九讲”#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace st...

2018-04-26 02:17:31 137

原创 HDU 2022 海选女主角

1、二维数组水题,正常思路,for循环比较绝对值大小即可2、虽然我不知道为什么不卡数据(题目中有最大的负值-2147483648,但abs之后会上溢,超出范围),但OJ给过我就懒得添加这些细节了#include<iostream>#include<cmath>#include<cstring>using namespace std;int main(...

2018-04-21 16:06:27 430

原创 HDU 2021 发工资咯

贪心思想的水题,思路:从最大的面额开始计算能用几张,不足的用次小面额的开始补#include<iostream>using namespace std;int main(){ int n; while(cin>>n,n) { int a,sum=0; for(int i=1;i<=n;i++) { cin>>a; ...

2018-04-21 15:56:47 274

原创 UVA 253 Cube Painting (水题)

根据骰子的特性,三对对立面的涂色情况是不会变的,因而可根据这种特性来解题此题也可用枚举方法暴力,代码枚举类中已给出,但是相对于枚举,我觉得这种思考方法更好,代码相对简洁,也好理解#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namesp...

2018-04-21 15:42:20 235

原创 UVA 253 Cube Painting (枚举)

1、根据骰子自身六面的特质,可以模拟出所有面顺序的情况,因为情况总数小..暴力是没有关系。第一种方法是枚举(暴力)2、骰子的另一种情况是,即使再怎么旋转,对立面涂色的情况是不会变的,因而可以从这种方式检查(见水题分类,这里代码不做详解)枚举#include<cstdio>#include<iostream>#include<cstring>using n...

2018-04-21 15:35:58 193

原创 HDU 1008 Elevator

1、水题,思路非常直接,但题目读错了导致一直WA。上一层用时6s,下一层用时4s,每站停留5s。2、一定要注意电梯的起始楼层是0层。#include<cstdio>#include<iostream>using namespace std;int main(){ int n,i,sum,a[1001]; while(cin>>n &&am...

2018-04-21 15:20:19 177

原创 UVA 1587 Box

1、水题,模拟题。2、长方体盒子特征:每个面都与对立面长宽相同。此为题目判断条件已,另一个判断条件为,每一面与其他面的长宽是否能契合到一起。3、考察对sort自定义排序的运用。#include<cstdio>#include<iostream>#include<algorithm>using namespace std;const int N=6;...

2018-04-21 14:51:08 260

原创 UVA 401 Palindromes

1、常量数组用法的一道水题。2、字母和数字各开一组常量数组,储存字母和数字相对应的字符。情况分类讨论即可,可设置两个标记isp和ism。3、注意条件中给出的字符,因为粗心这道题WA了很多次。#include<cstdio>#include<iostream>#include<cctype>#include<cstring>using nam...

2018-04-21 04:49:59 142

原创 UVA 455 Periodic Strings

1、字符串类的水题。2、给出的字符串长度一定为重复字符串长度的倍数,只需要验证每组循环开头的第一个字符是否一样即可。设置flag标记,一路读到最后一组循环且flag=1,成立,flag=0则不成立。3、注意最后题目要求的格式输出。#include<cstdio>#include<iostream>#include<cstring>using namesp...

2018-04-21 04:37:46 109

原创 UVA 1585 Score

1、数组与字符串类的水题2、注意一下读入字符串的操作时,不能用gets(用法才被删去)#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main(){ int n; char line[80]; cin>>n; for(int i...

2018-04-21 04:22:42 96

原创 HDU 1089~1096 新手之八大输入输出

几种常见的输入输出,注意一下最后输出的格式即可。1、HDU 1089#include<cstdio>#include<iostream>using namespace std;int main(){ int a,b; while(cin>>a>>b) { cout<<a+b<<endl; } retur...

2018-04-21 04:01:08 238

原创 最长公共子序列长度

动态规划——最长公共子序列长度

2017-12-03 03:47:15 488

原创 一个咸鱼准备翻身——还是咸鱼

纪念一个咸鱼开通博客。也同时纪念咸鱼的我网吧第三次通宵学习,有点神奇,虽然网吧很吵。大学开始才接触编程这一块,算是有点晚吧。C才学完C++看了一个输入输出,不知道以后的进度会怎样,walk slowly but never walk backwards。最近阴差阳错地进了院里的ACM队,天天仰望大佬,深知差距。我需要做的,仅是比上一秒的自己更加坚定和进步。没什么其他想说的。...

2017-12-02 23:45:21 689

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除