codeforce div 377】的更多相关文章

#include <bits/stdc++.h> using namespace std; #define pb push_back #define lb lower_bound #define ull unsigned ll #define gcd(a,b) __gcd(a,b) #define pii pair<int,int> #define all(x) x.begin(),x.end() #define ll long long #define mp make_pair…
题目链接: http://codeforces.com/contest/1080/problem/C 思路:双向延长两个矩形方块的4边,会形成一个被分割为9块的更大立方体. 计算所有的9个方框.方框中心的点只有可能在黑框,白框或者在外面.中心点在黑框中则按照黑色渲染了棋盘计算,其余同理. 详细见代码. 注意点: 1.题目上方框的信息给出的是方块号的信息而非坐标信息.需要转换成坐标信息 2.求两者的中点得用double转换,如果用float转换精度会有偏差. 3.sort函数应该是sort(x+1…
Codeforces Round #377 (Div. 2) D. Exams    题意:给你n个考试科目编号1~n以及他们所需要的复习时间ai;(复习时间不一定要连续的,可以分开,只要复习够ai天就行了)   然后再给你m天,每天有一个值di; 其中,di==0代表这一天没有考试(所以是只能拿来复习的); 若di不为0,则di的值就代表第i天可以考编号为di的科目 ;(当然这一天也可以不考而拿来复习) .  问你最少能在第几天考完所有科目,无解则输出-1. 题解:首先,先想想最暴力的方法:从…
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { int k, r, i; scanf("%d %d", &k, &r); for(i = 1; i < 10000; ++i) { if((i*k)%10 == r) break; else if((i*k) % 10 == 0){ break;…
2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given n × m table. Each cell of the table is colored white or black. Find the numbe…
 传送门 Description Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. Empirically Polycarp learned that the dog needs at least k walks for any two consecutiv…
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…
题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i]为0,则表示当天不能参加任何科目的考试,只能预习或者休息: 数组b中有k个元素,b[i]表示科目i需要复习几天才能通过: 问最快需要几天能通过所有考试,如果不能完成所有科目考试,输出-1: 思路: 用二分方法直接找满足条件的最小的数,其中数是指当前天是第几天,条件是指当前天以前是否能考完所有科目(…
C time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set u…
C. Sanatorium time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! Every day th…
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…
A. Buy a Shovel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is so…
C. Duff in the Army Recently Duff has been a soldier in the army. Malek is her commander. Their country, Andarz Gu has n cities (numbered from 1 to n) and n - 1 bidirectional roads. Each road connects two different cities. There exist a unique path b…
cf 上的一道好题:  首先发现能生成所有数字-N 判断奇偶 就行了,但想不出来,如何生成所有数字,解题报告 说是  所有数字的中最大的那个数/所有数字的最小公倍数,好像有道理:纪念纪念: #include<iostream> #include<stdio.h> #include<algorithm> #include<cstring> #include<algorithm> #include<cmath> using namespa…
题目例如以下: B. Football Kit time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for aw…
A. Olympiad 给出n个数,让你找出有几个非零并且不重复的数 所以用stl的set //#define debug #include<stdio.h> #include<math.h> #include<cmath> #include<queue> #include<stack> #include<string> #include<cstring> #include<string.h> #include…
C. Phone Numbers time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output And where the are the phone numbers? You are given a string s consisting of lowercase English letters and an integer k. Find th…
B. Our Tanya is Crying Out Loud time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A an…
构造题 话说挺水的题..当时怎么就WA到自闭呢.. 先把每个位置按照最低要求填满,也就是相差1..然后从最后一位开始把剩下的数加上,直到不能加为止. #include <bits/stdc++.h> #define INF 0x3f3f3f3f #define full(a, b) memset(a, b, sizeof a) using namespace std; typedef long long ll; inline int lowbit(int x){ return x &…
数论 gcd 看到这个题其实知道应该是和(a+k)(b+k)/gcd(a+k,b+k)有关,但是之后推了半天,思路全无. 然而..有一个引理: gcd(a, b) = gcd(a, b - a) = gcd(b, b - a) (b > a) 证明一下: 令 gcd(a, b) = c, (b > a) 则有 a % c = 0, b % c = 0 那么 (a - b) % c = 0 令 gcd(a, b - a) = c', 假设c' != c 则有 a % c' = 0, (b - a…
D. Berland Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output XXI Berland Annual Fair is coming really soon! Traditionally fair consists of nn booths, arranged in a circle. The booths ar…
http://codeforces.com/contest/1072/problem/C C. Cram Time time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In a galaxy far, far away Lesha the student has just got to know that he has an exa…
http://codeforces.com/contest/1072/problem/B B. Curiosity Has No Limits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output When Masha came to math classes today, she saw two integer sequences…
dp 找规律 我好菜啊好菜啊,完全没有思路. 在合法的括号序列中,左括号数一定大于等于右括号数的,所以我们可以先定义平衡度为左括号数-右括号数. 然后可以发现一个惊人的规律..就是在trie同一深度上的点,如果平衡度相同,那么他的子树完全一样.. 官方的题解给出了几个栗子: ((()) , ()()( , (())( 然后我们对于他们的状态都可以用同一个表示方法表示. 对于树上的最大边独立,为们对每个点,可以看他的父亲节点有没有被选过,如果被选过了,那么该点与父亲的边就不能选,反之则选择数量加1…
题意(CodeForces 614D) 每个人有\(n(n\le 10^5)\)个技能,技能等级都在\([0,10^9]\)的范围,每个技能有一个当前等级,所有技能的最高等级都为A.一个人的力量被记做以下两项的和: 1. 顶级技能的个数 *cf 2. 最低等级的技能 *cm 每个单位的钱能够提升一级力量.我们希望花尽可能少的钱,使得力量尽可能高. 分析 我二分的功力还是不足,要多努力.这题其实是一个非常明显的暴力:我们枚举提高到A的等级的个数(到不能提升为止),枚举这种情况下,我们能够令把多少人…
题意 (CodeForces 617E) 已知一个长度为\(n\)的整数数列\(a[1],a[2],-,a[n]\),给定查询参数\(l,r\),问\([l,r]\)内,有多少连续子段满足异或和等于\(k\). 也就是说,对于所有的\(x,y (l\le x\le y\le r)\),能够满足\(a[x]\oplus a[x+1]\oplus ...\oplus a[y]=k\)的\((x,y)\)有多少组. 分析 对于这种离线区间的查询问题(不涉及对区间的更改),我们可以使用莫队算法解决.这类…
A. Buy a Shovel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is so…
前言:关于如何求双连通分量,我们可以在tarjan搜索时标记下所有桥的位置(双连通分量(可以认为是没有桥的无向图图)即可通过删去所有桥得到),那么怎么找桥呢,对于每一条搜索到的边u->x,如果low[u]>dfn[x]则说明u不能通过子图到达比x更早的节点,那么就说明该边是桥 题意:把一个无向图变成有向图,对于这个有向图来说,每个点的价值是它所有能到达的点的数量,要求使得所有点中最小的价值最大 题解:现学的边-双联通分量,先求一遍边-双联通分量,然后在每个双连通分量里dfs一边把双向边变成单向…
http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行. 如果不同,还有一个操作,就是在sockets中插东西,使得sockets的值变成val / 2 + (val & 1) 要求输出最多插多少个电脑和最小的代价. 开始的时候,就有一个暴力的思路了, 就是,用优先队列维护sockets,每次弹出插了最小adapters的一个sockets,然后就是电脑那里找,有得插…
http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来考试) 那么这个all值就是理想的最小值.然后去前all个数找,贪心地复习最小的科目,然后有的考试的话,就优先考试. 如果经过这all天,复习完了(这个是肯定得),但是只是因为时间分配不好,导致没得考试(数据导致没得考试) 那么就暴力枚举后面的[all + 1, n].有得考试就去考试,刚好考完就直…