
二分查找
zzuli-dk
这个作者很懒,什么都没留下…
展开
-
poj 2456 最大化最小值
#include #include #include #define N 100005using namespace std;int a[N], n, c;bool judge(int x)//检查是否满足条件{ int cnt = 1,tmp = a[0]; for(int i = 1; i { if(a[i] -原创 2016-12-01 21:06:07 · 362 阅读 · 0 评论 -
hdu 6103 Kirinriki dp+二分 或 尺取法
题目连接:hdu 6103 题意:找出整个字符串中两个相同长度,但不重叠的连续字串,求满足他们的距离小于等于m的最长长度。 二分+dp应该也是能写的,但是我错了,应该是dp没写好, 队友写的dp过了。#include<bits/stdc++.h>using namespace std;const int MAXN = 5005;char str[20005];short int dp[M原创 2017-08-12 08:58:59 · 217 阅读 · 0 评论 -
UVA-10391 二分
You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. Input St原创 2017-08-14 15:00:37 · 191 阅读 · 0 评论 -
hdu 6216 规律+二分
思路: 一个素数是否是立方的差, 只要判断是否是两个连续立方数的差。 在线规律查找](http://oeis.org/)#include <stdio.h>#include <string.h>#include <iostream>#include <vector>using namespace std;const int MAXN = 100005;typedef long原创 2017-09-19 19:54:59 · 424 阅读 · 0 评论 -
1125 咸鱼商店(二分+01背包) “玲珑杯”线上赛
题意:求出满足在背包容量内,背包价值大于k的所有情况中,找到最小价值是最大的那一种情况。#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <string>#include <cmath>#include <map>#include <原创 2017-06-06 16:15:18 · 262 阅读 · 0 评论 -
Wannafly挑战赛1 B Xorto 前缀和
题目链接 思路:求出前缀异或和, 枚举所有以i结尾的区间值,对后面以i+1开头的区间值数量求和。#include <cstdio>#include <iostream>#include <cmath>#include <cstring>using namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;const i原创 2017-10-16 11:13:06 · 257 阅读 · 0 评论 -
Wannafly模拟赛5 A split 二分
思路:开始以为是对以分割数一半的平方求和是最佳的,后来才知道平分才是最佳的。只想着5*5>4*6没想5*10+5*5>7*8+4*4 每次平分应该只能过%40的数据。#include <bits/stdc++.h>using namespace std;typedef long long LL;const int mod = 1000000007;const int MAXN = 5000原创 2017-11-04 14:53:38 · 238 阅读 · 0 评论 -
atcoder AGC 020 B - Ice Rink Game
题意:有f(x,p)=x-x%p;求f(f(f(x,a[1]),a[2]),a[3])....a[n])=2;满足条件的x的最大值。二分是一个比较容易想到的思路,由于每次取余最多减掉a[i]-1,所以有较好的单调性, 所以答案会是一个区间,但是区间左右都是false,所以不能单纯判断最后是否为2,应该和2比较大小。解法1:二分#include #include #include #inclu原创 2018-01-16 13:50:33 · 360 阅读 · 0 评论