题意:给定 n 个数,然后有 m 个询问,每个询问一个数,问你小于等于这个数的数有多少个. 析:其实很简单么,先排序,然后十分查找,so easy. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <…
https://codeforces.com/problemset/problem/706/B 因为没有看见 $x_i$ 的上限是 $10^5$ ,就用了二分去做,实际上这道题因为可乐的价格上限是 $10^6$ ,可以用复杂度为 $O(max(x_i))$ 的dp去做. 也就是说,当这道题的可乐数量上升,二分就容易超时,而可乐的价格上升则dp容易爆内存且超时.各有所长 #include<bits/stdc++.h> using namespace std; #define ll long lo…
Interesting drink Problem Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that th…
题目链接: http://codeforces.com/problemset/problem/706/B 题目大意: n (1 ≤ n ≤ 100 000)个商店卖一个东西,每个商店的价格Ai,你有m(1≤m≤100 000)天,每天有Cj的钱,问每天可以负的起的商店数. 题目思路: [二分] 排个序,二分. // //by coolxxx // #include<iostream> #include<algorithm> #include<string> #inclu…
排序,二分. 将$x$数组从小到大排序,每次询问的时候只要二分一下位置就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include&l…
题目链接: B. Interesting drink 题意: 给出第i个商店的价钱为x[i],现在询问mi能在多少个地方买酒; 思路: sort后再二分; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <bits/stdc++.…
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bough…
传送门: http://codeforces.com/problemset/problem/600/B Queries about less or equal elements time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given two arrays of integers a and b. For e…
题目传送门 /* 二分查找/暴力:先埃氏筛选预处理,然后暴力对于每一行每一列的不是素数的二分查找最近的素数,更新最小值 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; ; const int INF = 0x3f3f3f3f; int a[MAXN][MAXN]; int mn_r[MAXN]; int mn_c[MAXN]; bool is_prim…
题面: 传送门:http://codeforces.com/problemset/problem/475/D Given a sequence of integers a1, -, an and q queries x1, -, xq on it. For each query xi you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(al, al + 1, -, ar) = xi. 题目大意:…