CodeForces - 748E (枚举+脑洞)】的更多相关文章

E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school…
题意:给你一堆数,问其中lcm最小的一对数是什么? 思路:因为lcm(a, b) = a * b / gcd(a, b), 所以我们可以考虑暴力枚举gcd, 然后只找最小的a和b,去更新答案即可. 数据范围1e7? 不慌,bitset搞一下, 1e7log(1e7)可以500ms过. 代码: #include <bits/stdc++.h> using namespace std; const int maxn = 1000010; bitset<maxn * 10> v, v1;…
题意 有n(n<=3000)个人参与acm比赛,每个人都有一个解题数,现在要决定拿金牌的人数cnt1,拿银牌的人数cnt2,拿铜牌的人数cnt3,各自对应一个解题数区间[d1,c1],[d2,c2],[d3,c3] 现在要求: 1.d1-c2尽可能大 2.在1满足的前提下,d2-c3尽可能大 3.在1,2满足的前提下,d3-num尽可能大(num表示铁牌第一名的解题数) 4.对于任意的x,y(1<=x,y<=3),cntx<=2*cnty 你需要给出一种每个人的奖牌分配来满足以上要…
C. Vasily the Bear and Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasily the bear has got a sequence of positive integers a1, a2, ..., *a**n*. Vasily the Bear wants to write o…
两个二分 枚举位数 #include <bits/stdc++.h> #define MOD 1000000007 using namespace std; typedef long long ll; ll ten[]; ll check1(ll x) { ll ans = ; ll l, r; ; i <= ; i++) { l = ten[i], r = ten[i + ] - ; if (r < x) { ans += i * ( * x - l - r) * (r - l…
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school…
A /*#include<cstring>#include<algorithm>#include<queue>#include<vector>#include<cstdio>#include<cmath>#include<iostream>*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; ; int main() { in…
题意:将n个蛋糕分给k个人,要保证每个人都有蛋糕或蛋糕块,蛋糕可切, 1.若蛋糕值为偶数,那一次可切成对等的两块. 2.若蛋糕值为奇数,则切成的两块蛋糕其中一个比另一个蛋糕值多1. 3.若蛋糕值为1,则不可切. 问每个人拥有的蛋糕中最小蛋糕值可能的最大值是多少. 分析: 1.若每个蛋糕都分成蛋糕值为1,即n个蛋糕的蛋糕值总和<k,则输出-1. 2.验证mid是否成立,若某蛋糕值x大于mid,则可切,并将该蛋糕可切成的块数保存在vis[x]中. 3.若mid为5,而x为11,则有必要切蛋糕x,若x…
题目链接:http://codeforces.com/problemset/problem/144/D 思路:首先spfa求出中心点S到其余每个顶点的距离,统计各顶点到中心点的距离为L的点,然后就是要统计在边上的点了,可以枚举边(这里边的数量最多也就100000条),对于枚举的某条边,如果它的其中某个端点到S的距离记过这条边,也就是满足一下这个条件:d1 + w == d2 || d2 + w == d1,那么边上符合要求的点最多只有一个,否则,就要判断d1,d2的关系,对于求出的边上的某个符合…
C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a…