CodeForces 483B Friends and Presents】的更多相关文章

 Friends and Presents Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 483B Description You have two friends. You want to present each of them several positive integers. You want to prese…
483B - Friends and Presents 思路:这个博客写的不错:http://www.cnblogs.com/windysai/p/4058235.html 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset((a),(b),sizeof(a)) const ll INF=1e18; ll c1,c2,…
题目链接:http://codeforces.com/problemset/problem/483/B 题目意思:有两个 friends,需要将 cnt1 个不能整除 x 的数分给第一个friend,cnt2 个不能整除 y 的数分给第二个friend.x 和 y 都是素数来的.要求求出最小的 v,v 表示可以从1,2,...,v 中取数. 开始我做这条题的时候是用很常规的方法做的,结果可想而知,WA,MLE,TLE.只能看题解啦,不会嘛---题解真是非常清晰.明白.易懂. 等我用中文来解释下吧…
[链接] 我是链接,点我呀:) [题意] [题解] 我们可以二分n的值,设为mid 那么对于n=mid 我们可以算出来以下3个东西 temp1 = n/x; temp2 = n/y; temp3 = n/lcm(x,y);//lc(x,y)表示x和y的最小公倍数 temp1是第一个人在1..n中不喜欢的数的个数 temp2是第二个人在1..n中不喜欢的数的个数 temp3是两个人在1..n中都不喜欢的数的个数. 那么我们把1..n中temp1-temp3个第一个人不喜欢的数字全给第二个人 然后把…
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to…
题目: B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have two friends. You want to present each of them several positive integers. You want to present cnt1 number…
题意:从1....v这些数中找到c1个数不能被x整除,c2个数不能被y整除! 并且这c1个数和这c2个数没有相同的!给定c1, c2, x, y, 求最小的v的值! 思路: 二分+容斥,二分找到v的值,那么s1 = v/x是能被x整除的个数 s2 = v/y是能被y整除数的个数,s3 = v/lcm(x, y)是能被x,y的最小公倍数 整除的个数! 那么 v-s1>=c1 && v-s2>=c2 && v-s3>=c1+c2就是二分的条件! #includ…
题意:给你n个数,将他们分成连续的三个部分使得每个部分的和相同,求出分法的种数. 思路:用一个数组a[i]记下从第一个点到当前i点的总和.最后一个点是总和为sum的点,只需求出总和为1/3sum的点和总和为2/3sum的点搭配的所有情况.遍历一遍总和为2/3sum的点前总和为1/3sum的点的个数. #include<stdio.h> #include<string.h> #include<iostream> using namespace std; ; typedef…
Friends and Presents CodeForces - 483B You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. Moreover, you want all presented numb…
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the prese…
最近一直在做 codeforces ,总觉得已经刷不动 BZOJ 了? ——真是弱喵 你看连 Div.2 的 B 题都要谢谢题解,不是闲就是傻 显然我没那么闲 ╮(╯_╰)╭ 我觉得这题的想法挺妙的~ 大意是你需要分别给 a 和 b cnt1 和 cnt2 个数字 但是 a 不要被 x 整除的数 ,as well as,b 不要被 y 整除的数 然后求需要给的最大数的最小值—— 最值的最值?那不是典型的二分吗? 但是——坑爹的英文题导致我完全没有意识到这一点…… 二分答案 v ,因为 a 不要被…
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to…
题目链接: A. Little Artem and Presents time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Mash…
8493833                 2014-10-31 08:41:26     njczy2010     B - Friends and Presents             GNU C++     Accepted 31 ms 4 KB B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output st…
[题目链接]:http://codeforces.com/contest/793/problem/D [题意] 给你n个点, 这n个点 从左到右1..n依序排; 然后给你m条有向边; 然后让你从中选出k个点. 这k个点形成的一条路径; 且在路径中,一个被访问过的点不会经过两次或以上; 比如从1->3(1和3被访问过) 然后再从3->4(1,3,4都被访问过) 再从4->2(这时会又经过3号节点,而3号节点之前被访问过,所以不合法) 这就不是合法的; [题解] 每次走完之后都有一个接下来能…
题目链接:http://codeforces.com/contest/793/problem/D 题意:给出n个点m条边选择k个点,要求k个点是联通的而且不成环,而且选的边不能包含选过的边不能包含以前 选过的点,问最小的权值是多少. 题解:像这种取最小的一般可以考虑一下dp,然后再看一下题目,由于每次选的边都不能包括以前选的点,所以每 选择一条边能选择的区间范围就缩小了. 设dp[pos][l][r][k](这里可能会有人觉得开80*80*80*80会不会有点大了,自行计算一下不会爆内存的),p…
传送门 显然每种礼物是互相独立的,一个礼物的分配不会影响另一个礼物 对于某个礼物 $x$ , 对于每个盒子来说,要么选要么不选,那么可以看成长度为 $m$ 的二进制序列 这个序列第 $i$ 位的数就代表第 $i$ 个盒子里是否有这个礼物,那么总方案即为 $2^m-1$ ,减 $1$ 是因为全 $0$ 的序列是不合法的 然后根据乘法原理最终答案即为每个礼物的方案的乘积 :$(2^m-1)^n$ #include<iostream> #include<cstdio> #include&…
A. Puzzles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/337/A Description The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to p…
题目链接: http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either through a direct link, or through a chain of links, by relayi…
J. Computer Network Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” consists of n servers and m two-way communication links. Two servers can communicate either thr…
A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinis…
题目链接:http://codeforces.com/contest/483 A - Counterexample - [简单构造题] Your friend has recently learned about coprime numbers. A pair of numbers $(a, b)$ is called coprime if the maximum number that divides both $a$ and $b$ is equal to one. Your friend…
 2017 JUST Programming Contest 2.0 题目链接:http://codeforces.com/gym/101343/problem/A A. On The Way to Lucky Plaza time limit per test:1.0 s memory limit per test:256 MB input:standard input output:standard output Alaa is on her last day in Singapore, s…
D. Gifts by the List 题目连接: http://www.codeforces.com/contest/681/problem/D Description Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's fam…
地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One of Timofey's birthday presents is a colourbook in a shape o…
地址:http://codeforces.com/contest/764/problem/B 题目: B. Timofey and cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Young Timofey has a birthday today! He got kit of n cubes as a birthd…
Puzzles Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 337A64-bit integer IO format: %I64d      Java class name: (Any) The end of the school year is near and Ms. Manana, the teacher, will soon have t…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on…
https://codeforces.com/contest/1236/problem/B Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are nn kinds of presents. Presents of one kind are identical (i.e. there is no way to disting…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…