自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 美丽的数

直接打表1e9的数组会超内存,而且代码长度只有256KB,所以要分块打表。#include<bits/stdc++.h>typedef long long ll;typedef double db;#define all(x) (x).begin(),(x).end()#define mp make_pair#define pb push_back#define fi ...

2019-08-13 18:37:28 427

原创 P1417 烹调方案(dp)

题目背景由于你的帮助,火星只遭受了最小的损失。但gw懒得重建家园了,就造了一艘飞船飞向遥远的earth星。不过飞船飞到一半,gw发现了一个很严重的问题:肚子饿了~gw还是会做饭的,于是拿出了储藏的食物准备填饱肚子。gw希望能在T时间内做出最美味的食物,但是这些食物美味程度的计算方式比较奇葩,于是绝望的gw只好求助于你了。题目描述一共有n件食材,每件食材有三个属性,ai,bi和ci,如果在t...

2019-07-26 18:47:14 173

转载 P1052 过河(dp+路径压缩)

题目描述在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧。在桥上有一些石子,青蛙很讨厌踩在这些石子上。由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数轴上的一串整点:0,1,…,L0,1,…,L(其中LL是桥的长度)。坐标为00的点表示桥的起点,坐标为LL的点表示桥的终点。青蛙从桥的起点开始,不停的向终点方向跳跃。一次跳跃的距离是SS到TT之间的任...

2019-07-24 16:43:44 315

原创 P1316 丢瓶盖(于答案区间二分查找)

题目描述陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想从这些瓶盖里找出B个,使得距离最近的2个距离最大,他想知道,最大可以到多少呢?输入输出格式输入格式:第一行,两个整数,A,B。(B<=A<=100000)第二行,A个整数,分别为这A个瓶盖坐标。输出格式:仅一个整数,为所求答案。输入输出样例输入样例#1:5 ...

2019-07-21 17:21:56 317

原创 记忆化搜索

Michael喜欢滑雪。这并不奇怪,因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道在一个区域中最长的滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子:1 2 3 4 516 17 18 19 615 24 25 20 714 23 22...

2019-07-15 21:25:44 137

原创 广搜迷宫

一个迷宫由R行C列格子组成,有的格子里有障碍物,不能走;有的格子是空地,可以走。给定一个迷宫,求从左上角走到右下角最少需要走多少步(数据保证一定能走到)。只能在水平方向或垂直方向走,不能斜着走。输入第一行是两个整数,R和C,代表迷宫的长和宽。( 1<= R,C <= 40)接下来是R行,每行C个字符,代表整个迷宫。空地格子用’.’表示,有障碍物的格子用’#’表示。迷宫左上角...

2019-07-14 21:02:54 259

原创 八皇后

#include<bits/stdc++.h>const ll mod = 1e9+7;const int N = 1e5+20;#define dep(i,a,b) for(int i=(a);i>=(b);i--)#define rep(i,a,b) for(int i=(a);i<=(b);i++)#define mes(p) memset(p,0,size...

2019-07-13 15:37:25 140

原创 UVA 1595

The figure shown on the left is left-right symmetric as it is possible to fold the sheet of paper along avertical line, drawn as a dashed line, and to cut the figure into two identical halves. The fi...

2019-07-12 16:15:34 130

原创 UVA-10763 multimap的使用

Your non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordinates a very successful foreign student exchange program. Over the last few years, demand hassky-rocke...

2019-07-12 10:30:28 121

转载 C++ multimap

在multimap中,同一个键关联的元素必然相邻存放。基于这个事实,就可以将某个键对应的值一一输出。1、使用find和count函数。count函数求出某个键出现的次数,find函数返回一个迭代器,指向第一个拥有正在查找的键的实例。2、使用lower_bound(key)和upper_bound(key)lower_bound(key)返回一个迭代器,指向键不小于k的第一个...

2019-07-12 09:37:37 581

转载 截取字符串

用途:一种构造string的方法形式:s.substr(pos, n)解释:返回一个string,包含s中从pos开始的n个字符的拷贝(pos的默认值是0,n的默认值是s.size() - pos,即不加参数会默认拷贝整个s)补充:若pos的值超过了string的大小,则substr函数会抛出一个out_of_range异常;若pos+n的值超过了string的大小,则sub...

2019-07-11 19:22:34 136

原创 排序成绩,且成绩相同学号越小的拍前

88 5 1005 95 2390 95 1000 90 1001 88 3239 88 bool cmp(x a,x b){if(a.s==b.s)//成绩相同排学号return a.k<b.k;return a.s>b.s;//拍成绩}

2019-07-10 15:51:12 436

原创 截取字符串

标准库的string有一个substr函数用来截取子字符串。一般使用时传入两个参数,第一个是开始的坐标(第一个字符是0),第二个是截取的长度#include<bits/stdc++.h>using namespace std;int main(){string s=“123456”;string first(s.substr(2,3));cout<<first...

2019-07-09 20:59:42 108

转载 C++删除string最后一个字符的几种方法

#include<string>using namespace std;int main(){ string str; str = "123456"; cout << str << endl; //方法一:使用substr() str = str.substr(0, str.length() - 1);...

2019-07-09 20:29:06 9668 1

原创 Jun 15 training C. Hard problem(dp)

C. Hard problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy is fond of solving different tasks. Today he found one he wasn’t able t...

2019-06-25 20:25:28 209

原创 矩阵快速幂(无需乘法逆元)or 乘法逆元+快速幂 May 17trainging problem D

D. Iterated Linear Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a linear function f(x) = Ax + B. Let’s define g(0)(x) = x ...

2019-05-23 13:34:20 191

转载 快速幂以及矩阵快速幂

ll quickpow(ll x,ll n){ll ans=1,res=x;while(n){if(n&1) ans*=res;ans%=mod;res*=res;res%=mod;n=n>>1;}return ans;}

2019-05-23 10:19:19 146

原创 Codeforces Round #532 (Div. 2), problem: (B)

B. Build a Contesttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputArkady coordinates rounds on some not really famous competitive programming ...

2019-05-19 23:26:15 183

原创 枚举+二分查找(May 17 training problem D)

B. Powers of Twotime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a1, a2, …, an. Find the number of pairs of indexes i...

2019-05-19 18:25:03 406

原创 由最大公约数求最小公倍数

公式:(a,b)×[a,b]=a×b;【】为最小公倍数,()为最大公约数int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//求最大公约数;即最小公倍数为 【a,b】=(a*b)/gcd(a,b)...

2019-05-18 00:08:48 509

原创 最长区间

D. Longest k-Good Segmenttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe array a with n integers is given. Let’s call the sequence of one ...

2019-05-16 09:38:56 369

原创 求两个数的最大正整数公约数问题(gcd)

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}

2019-05-09 16:26:45 445

空空如也

空空如也

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

TA关注的人

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