自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 HDU - 1542 Atlantis(线段树扫描线基础)

#include <bits/stdc++.h>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn =5000;double sum[maxn<<2],key[maxn<<2];int lazy[maxn<<2];struct line{ double l,r,y

2016-11-29 10:06:29 313

原创 codeforces - 735D -Taxes(数学)

LINK:http://codeforces.com/contest/735/problem/D题意: 某人要交税,交的税钱是收入n的最大因子(!=n,若该数是质数则是1),但是这人作弊,把钱拆成几份,使交税最少,输出税钱。 解法: 如果n为质数不拆, 如果n是偶数可以拆成两个质数的和。 如果n可以拆成2+一个质数输出2 剩下的只能成3份#include<bits/stdc++.h>u

2016-11-28 23:07:23 706

原创 codeforces - 735C -

LINK:http://codeforces.com/contest/735/problem/C题意: 有n个人比赛,比赛规则是淘汰制,而且一个人只能和和他比赛次数相差1以内的人比,问赢的人最多比了几场。 解法: xjb搞#include <bits/stdc++.h>using namespace std;#define ll long longint main() { ll

2016-11-28 23:00:43 604

原创 codeforces - 735B - Urbanization(贪心)

LINK:http://codeforces.com/contest/735/problem/B 题意:两座容量分别为n1、n2的城市,有n个外来务工人员。这些人身上有一定的钱。 让两座城市的人均资产和最大,输出。解法:贪心。最有钱的一定在需要人最少的城市,然后排第二个城市。其他舍弃。#include <bits/stdc++.h>using namespace std;int cmp(in

2016-11-28 22:57:20 523

原创 codeforces - 735A-Ostap and Grasshopper

link:http://codeforces.com/contest/735/problem/A 题意: 蚱蜢在一个1*n的盒子里,蚱蜢能一步跳k格,不能跳到“#”上但是可以跨过#。蚱蜢要到T点问可不可行。解法:看看 T在不在可达范围内,然后排除路径上有#的情况 直接找#include <bits/stdc++.h>using namespace std;int main() {

2016-11-28 22:53:27 429

原创 HDU - 4578 -Transformation(线段树)

有地方写残了一直wa#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#defin

2016-11-25 22:36:59 449

原创 POJ -2892 Tunnel Warfare - 线段树区间合并

LINK:http://poj.org/problem?id=2892//#include<bits/stdc++.h>#include<iostream>#include<cstdio>#include<stack>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=500

2016-11-24 15:12:24 257

转载 poj 2528 - 线段树 - 离散化的小技巧

转自:http://www.notonlysuccess.com/index.php/segment-tree-complete/题意:在墙上贴海报,海报可以互相覆盖,问最后可以看见几张海报 思路:这题数据范围很大,直接搞超时+超内存,需要离散化: 离散化简单的来说就是只取我们需要的值来用,比如说区间[1000,2000],[1990,2012] 我们用不到[-∞,999][1001,1989]

2016-11-22 12:23:19 220

原创 codeforces - 707C - Pythagorean Triples (构造)

link:http://codeforces.com/contest/707/problem/C题意:给出直角三角形的其中一条边,输出另外两条边(任意方案,边都是整数)解法: 构造完全平方不等式。 若k为偶数输出(k/2)^2-1和(k/2)^2+1 若为奇数 输出2*(n^2)+2*n和2*(n^2)+2*n+1#include<bits/stdc++.h>using namespace

2016-11-21 22:02:02 215

原创 codeforces - 707B - Bakery(图的遍历)

LINK:http://codeforces.com/contest/707/problem/B 题意: n个城市,m条边,k个城市里有进货点。Masha要选一个没有进货点的城市开店,要选一个最近的有商店的城市进货,输出她进货时所用的最小路程。解法: 必须是进货点和商店相邻最优然后对每个进货点扫一次就行。#include<bits/stdc++.h>using namespace std;

2016-11-21 21:57:37 326

原创 codeforces - 707A - Brain's Photos(水)

LINK:http://codeforces.com/contest/707/problem/A 题意:给出n*m矩阵,判断彩色还是黑白。若出现一个彩色点就是个彩色图#include <bits/stdc++.h>using namespace std;#define max(a,b) a>b?a:bint main(){ int n,m; cin>>n>>m; cha

2016-11-21 21:49:22 242

原创 stl学习————离散化

离散化指 数据和数字值无关而和它们大小有关的时候,且空间浪费严重的时候,我们可以保留它们的大小关系,压缩到一定范围内节省空间的做法。 比如1 2 3 5 8这个序列可压缩成1 2 3 4 5。 假定待离散化的序列为a[n],sub_a[n]是a[n]的一个副本 sort(sub_a,sub_a+n); int size=unique(sub_a,sub_a+n)-sub_a;//size为

2016-11-21 13:48:30 478

原创 codeforces - 738A - Interview with Oleg(字符串处理)

codeforces - 738A - Interview with Oleg(字符串处理)题意:给一个长为n的串,找出所有ogogogo交替的,o开头o结尾的串,替换为三个*。 解法:瞎搞。找被两个o夹着的g,标记。 因为如果两个g在同一个替换串内,两个g下标差为2且两个g都在上一步标记过,然后xjbg输出【】#include<bits/stdc++.h>using namespace st

2016-11-20 21:09:53 426

原创 codeforces - 738B - Spotlights (瞎搞)

codeforces - 738B - Spotlights (瞎搞)题意: 给出n*m的矩阵。其中1代表该点有演员。0代表该点可放置追光灯。 找出放置追光灯的方法数(追光灯向上下左右算4种)。 解法: col,row记录在读到当前点之前该行/列有无演员。 最后全tm加一块就行。#include<bits/stdc++.h>using namespace std;int maze[1

2016-11-20 21:04:46 396

原创 codeforces - 703C - Chris and Road(几何)

LINK:http://codeforces.com/contest/703/problem/C 题意:有一个长成多边形的车,和一个在(0,0)点可视作点的人。 人以u的速度朝y轴正方向走。 车以v的速度朝x轴负方向走。 车不能撞到人(就是人的点在任意时刻不能出现在车的n边形内)。 求人到达y=w这条线的最小时间。解法: 对于车来说人相当于向上和向右走。 如图,长箭头表示以车为参照系人

2016-11-20 00:16:54 318

原创 codeforces - 703B - Mishka and trip(数学)

LINK:http://codeforces.com/contest/703/problem/B 题意:一个国家有n个城市,其中里面有k个省会,每个城市有点权。每个城市都和它前一个城市和后一个城市有边,第n个城市还有一条到第一个城市的边,省会到每个城市都有边。对每条边u-v边权都是c[u]*c[v]。求全部边圈和。 解法:n*n会t,给给。sum是首府的权值和。对每个不是首府的点,它到所有首府的

2016-11-20 00:03:41 368

原创 codeforces - 703A - Mishka and Game(水)

LINK:http://codeforces.com/contest/703/problem/A 两人掷骰子,看谁赢得次数多#include<bits/stdc++.h>using namespace std;#define LL long longint main(){ int n,a,b,cnt1=0,cnt2=0; cin>>n; for(int i=0;i<

2016-11-19 23:50:54 251

原创 codeforces - 596A&B - A - Wilbur and Swimming Pool/Arraay (水)

A题 link http://codeforces.com/contest/596/problem/A#include<bits/stdc++.h>using namespace std;int v[5][5];int fab(int a) { return a > 0 ? a : -a;}int fin(int n) { int ans = -1; for(int

2016-11-19 10:26:22 389

原创 codeforces - 734E - Anton and Tree(图论 树)

codeforces - 734E - Anton and Tree(图论 树)LINK:http://codeforces.com/contest/734/problem/E题意: 给一棵树,点被染成了黑白二色,每次操作可以翻转相邻的同色点的颜色,问最少多少次操作能把整棵树染成一个颜色。解法: 当天没去看..被剧透了,帮人把结论证明了一遍:把相邻同色的点缩点之后树的直径的一半就是答案。 对每

2016-11-17 21:38:38 733

原创 codeforces - 734C - Anton and Making Potions(二分)

codeforces - 734C - Anton and Making Potions(二分)LINK:http://codeforces.com/contest/734/problem/C题意: 要做n瓶药水。 有两种方法加速,第一种方法是把每剂药剂的生成时间变为ai,费用为bi,第二种方法是立刻生成ci个药剂,费用为di。 求最快的,在花费在s以内的方法。(题目保证c递增,d递增)解法:

2016-11-17 20:15:01 356

原创 codeforces - 734A&B - Anton and Danik/Digit(水)

#include<bits/stdc++.h>using namespace std;int main(){ char s[100010]; int n; int cnt=0; cin>>n>>s; for(int i=0;i<n;i++) { if(s[i]=='A')cnt++; } if(2*cnt>n)co

2016-11-16 21:28:10 382

转载 codeforces - 508D - Tanya and Password(欧拉通路)

codeforces - 508D - Tanya and Password(欧拉通路)LINK:http://codeforces.com/contest/508/problem/D codeforces 508D Tanya and Password 题意:给n个长为3的串,求一长度为n+2的串,包含全部子串。解法: 对于abc这个子串,ab视作一个节点bc视作一个节点,建边。 跑欧

2016-11-16 11:21:41 452

原创 codeforces - 508C - Anya and Ghosts(贪心)

codeforces - 508C - Anya and Ghosts(贪心)LINK:http://codeforces.com/contest/508/problem/C题意:Anya和鬼玩耍,有m只鬼,第i只会在Wi的时候出现,Anya手上有些蜡烛,她要保证在每只鬼来的时候都有r个蜡烛在亮着,其中每根蜡烛能燃烧长度为t的时间,Anya每次个单位时间只能点亮一根蜡烛。若不能做到,输出-1。解法:

2016-11-14 21:34:01 323

原创 codeforces - 508B - Anton and currency you all know(贪心)

codeforces - 508B - Anton and currency you all know(贪心)Link:http://codeforces.com/contest/508/problem/B 题意: 给出一个长度小于105的奇数,交换其中两位,使其变成一个偶数,若有多种做法输出最大的。若不能构造出一个偶数,输出-1。解法: 贪心。一开始以为只需交换最高位偶数即可,秒送wa。 正

2016-11-14 20:45:12 468

原创 codeforces - 508A - Pasha and Pixels(暴力模拟)

codeforces - 508A - Pasha and Pixels(暴力模拟)LINK:http://codeforces.com/contest/508/problem/A菜鸡如我开了个博客 先日刷cf_(:з」∠)_题意: 在n*m的矩阵中玩涂色游戏,给出每次涂色的格子的坐标,输出涂出一个2*2的方形为止所需步数。 解法: 暴力对每次输入遍历其左上左下右上右下四个2*2方块#incl

2016-11-14 20:37:13 422

空空如也

空空如也

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

TA关注的人

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