Codefroces D2. Magic Powder - 2(二分)】的更多相关文章

http://codeforces.com/problemset/problem/670/D2 http://codeforces.com/problemset/problem/670/D1 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The term of this problem is the same as the p…
D2. Magic Powder - 2 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The term of this problem is the same as the previous one, the only exception — increased restrictions. Input The first l…
题目链接:http://codeforces.com/contest/670/problem/D2 This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find t…
D1. Magic Powder - 1 题目连接: http://www.codeforces.com/contest/670/problem/D1 Description This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single soluti…
题目链接: http://codeforces.com/contest/670/problem/D2 题解: 二分答案. #include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; + ; const int INF = 2e9; typedef __int64 LL; int n, k; int x[maxn], y[maxn]; bool…
题意:今天我们要来造房子.造这个房子需要n种原料,每造一个房子需要第i种原料ai个.现在你有第i种原料bi个.此外,你还有一种特殊的原料k个, 每个特殊原料可以当作任意一个其它原料使用.那么问题来了,你最多可以造多少个房子呢? 析:首先可以先把开始能造出的先处理出来,然后再进行二分,当然也可以直接进行二分. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #inc…
D2. Magic Powder - 2 The term of this problem is the same as the previous one, the only exception — increased restrictions. Input The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109) — the number of ingredients and the…
D2. Magic Powder - 2 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The term of this problem is the same as the previous one, the only exception — increased restrictions. Input The first l…
http://codeforces.com/problemset/problem/670/D2 The term of this problem is the same as the previous one, the only exception — increased restrictions. Input The first line contains two positive integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109) — the nu…
D1. Magic Powder - 1 time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output This problem is given in two versions that differ only by constraints. If you can solve this problem in large constr…
C. Magic Ship time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You a captain of a ship. Initially you are standing in a point (x1,y1)(x1,y1) (obviously, all positions in the sea can be desc…
二分. 二分一下答案,然后验证一下. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<…
题意:给定一个长度为n的01串,你的任务是依次执行如表所示的m条指令: 1 p c 在第p个字符后插入字符,p = 0表示在整个字符串之前插入2 p 删除第p个字符,后面的字符往前移3 p1 p2反转第p1到第p2个字符4 p1 p2输出从p1开始和p2开始的两个后缀的LCP. 析:对于前三个操作,splay 很容易就可以解决,但是对于最后一个操作,却不是那么容易,因为这是动态的,所以我们也要维护一个可以动态的,这就可以用Hash来解决,由于要翻转,所以要维护两个,一个正向的,一个反向的.在操作…
A. Holidays 题意:一个星球 五天工作,两天休息.给你一个1e6的数字n,问你最少和最多休息几天.思路:我居然写成模拟题QAQ. #include<bits/stdc++.h> using namespace std; //#define int long long signed main(){ int n; cin>>n; ==){ ;x*=; cout<<x<<" "<<x; ; } ; ; ; int temp…
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1   This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you fin…
A. Holidays time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings …
链接:https://codeforces.com/contest/670 A - Holidays - [水] AC代码: #include<bits/stdc++.h> using namespace std; int n; int main() { cin>>n; , r=n%; ; int a,b; ) a=b=; ) a=, b=; <=r && r<=) a=, b=; ) a=, b=; printf("%d %d\n"…
第一次就去拉了点思维很神奇的CF题目 2018省赛赛第一次训练 # Origin Title     A CodeForces 607A Chain Reaction     B CodeForces 385C Bear and Prime Numbers     C CodeForces 670D2 Magic Powder - 2     D CodeForces 360B Levko and Array     E CodeForces 68B Energy exchange     F…
D1. Magic Powder - 1 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraint…
NOIP 2015 提高组 合集 D1 T1 神奇的幻方 题目让你干啥你就干啥,让你咋走你就咋走就完事儿了 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define N 50 using namespace std; struct Node { int x,y; }a[N*N]; int ans[N][N]; int main() { int n…
[NOIP2015]运输计划 D2 T3 Description 公元2044年,人类进入了宇宙纪元. L国有n个星球,还有n-1条双向航道,每条航道建立在两个星球之间,这n-1条航道连通了L国的所有星球. 小P掌管一家物流公司,该公司有很多个运输计划,每个运输计划形如:有一艘物流飞船需要从ui号星球沿最快的宇航路径飞行到vi号星球去.显然,飞船驶过一条航道是需要时间的,对于航道j,任意飞船驶过它所花费的时间为tj,并且任意两艘飞船之间不会产生任何干扰. 为了鼓励科技创新,L国国王同意小P的物流…
五一期间和然然打的团队赛..那时候用然然的号打一场掉一场...七出四..D1是个数据规模较小的题 写了一个暴力过了 面对数据如此大的D2无可奈何 现在回来看 一下子就知道解法了 二分就可以 二分能做多少个 每次对mid求一下不够的差值 比较差值与m的大小进行l与r的变换 由于自己一向对二分比较迷茫 自己琢磨出来一套神奇的办法面对边界数据 当小于和大于的时候 抛弃mid值 当等于的时候 直接break 然后打一发while试试能否向更好的情况偏移 当然在这个题目中 如果是直接break的时候就不用…
<题目链接> 题目大意: 给定起点和终点,某艘船想从起点走到终点,但是海面上会周期性的刮风,船在任何时候都能够向四个方向走,或者选择不走,船的真正行走路线是船的行走和风的走向叠加的,求船从起点到终点的最小步数. 解题分析: 因为本题数据量十分大,并且船和风叠加的行走路线比较复杂,所以我们考虑用二分答案解题.因为从起点到终点的有效步数是一定的,所以我们可以将船走动的总步数与风的步数(风吹不动的船的步数)分别进行计算,因为风是周期性吹的,但是从起点走到终点不一定是整数个周期,所以我们需要记录每个周…
https://codeforces.com/contest/1117/problem/C 你是一个船长.最初你在点 (x1,y1) (显然,大海上的所有点都可以用平面直角坐标描述),你想去点 (x2,y2) . 你看了天气预报——一个长为 n 的字符串 s,只包含字母 U, D, L 和 R .这些字母表示风向.并且,这个天气预报是循环的.例如,第一天风向是 s1 ,第二天是 s2 ,第 n 天是 sn ,则第 n+1 天又是 s1 ,以此类推. 船的坐标按照如下方式改变: 如果风向是 U ,…
维护一个01序列,一共四种操作: 1.插入一个数 2.删除一个数 3.反转一个区间 4.查询两个后缀的LCP 用Splay或者Treap都可以做,维护哈希值,二分求LCP即可. 注意反转序列的时候序列的哈希值也会改变,因此需要维护正反两个哈希值,在交换左右儿子的时候顺便交换两个哈希值即可. 还有就是打标记的同时也要进行反转,不要等pushdown的时候再反转 #include<bits/stdc++.h> using namespace std; typedef unsigned long l…
题意: 船在一个坐标,目的地在一个坐标,每天会有一个风向将船刮一个单位,船也可以移动一个单位或不动,问最少几天可以到目的地 思路: 二分天数,对于第k天 可以分解成船先被吹了k天,到达坐标(x1+sumx[k%n]+k/n*sumx[n], y1+sumy[k%n]+k/n*sumy[n]) 然后船在无风的情况下自己走k天是不是能到目的地就行了 注意二分的上限,如果能走到的情况下船可能每轮风只能移动一个有效单位,所以上限应该是1e9*1e5 代码: #include<iostream> #in…
题意:有\(n\)个数,每次可以选\(k(1\le k\le n)\)个数,并且得到\(a_1+max(0,a_2-1)+max(0,a_3-2)+...+max(0,a_k-k+1)\)的贡献,问最少选多少次使得总贡献不小于\(m\). 题解:我们从大到小排序,然后二分答案,贪心,如果答案是\(k\)天,那么对于前\(k\)个数,我们一定单独选它们分配到不同的\(k\)个集合中,然后再重复这个过程,从\(k+1\)个数开始循环分配到不同j集合中,这样一定能得到最大的贡献. 代码: ll n,m…
D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. Ab…
D. Exams Problem Description: Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. About every day we know exam for which one of m subjects can be passed on that day. Perhap…