codeforces 340 A. The Wall】的更多相关文章

水水的一道题,只需要找xy的最小公倍数,然后找a b区间有多少个可以被xy的最小公倍数整除的数,就是答案. //============================================================================ // Name : 2013083101.cpp // Author : xindoo // Version : // Copyright : Your copyright notice // Description : codefo…
http://codeforces.com/problemset/problem/399/D 题意:给出n和m,表示在一个n*n的平面上有n*n个方格,其中有m块已经涂色.现在随机选中一块进行涂色(如果已经涂色跳过,也消耗时间),消耗1个步骤.终止条件为每行每列都有至少有一块瓷砖被涂色.问说涂成满意的情况需要时间的期望. 思路:把整个方格分成四部分,如果选择左上角上的一块,那么行和列都将被涂上一个:右上角的话,行被涂上一个,列不变:左下角的话,行不变,列被涂上一个:右下角,行列都不变. 状态转移…
题目链接: D2. The Wall (medium) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their…
题目链接: D1. The Wall (easy) time limit per test 0.5 seconds memory limit per test 256 megabytes input standard input output standard output "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" &quo…
先上题目: A - Tourist Problem Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 340C Description Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. The…
原来我直接学的是假的莫队 原题: Bob has a favorite number k and ai of length n. Now he asks you to answer m queries. Each query is given by a pair li and ri and asks you to count the number of pairs of integers i and j, such that l ≤ i ≤ j ≤ r and the xor of the nu…
题目链接:http://codeforces.com/problemset/problem/340/A 这道题目理解不难,就是在[a, b]区间内,找出同时能够被x和y整除的个数.第一次想当然的开了两个2·109的数组,分别标记能被x和y的数字,内存受不了,返回CE.仔细想了下,开这么大的一个数组没有必要,直接在[a, b]枚举每一个数,能够同时整除x和y的数就统计下来,过了PT,然而很快就被hacked(还是第一次遇到的= =,不过也好,能帮助养成严谨的思维);  第三次,稍稍改良了算法,求x…
[Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计数,统计连续的“0”到下一个“1”的个数,然后相乘(第一个1前面的0不能算上).当然还要特判全0的情况. C.Watering Flowers 这题1A.只要按照以到某一个喷泉的距离排序,然后枚举没有被这一个喷泉覆盖到的个数,然后通过第二个喷泉覆盖,贪心一下就好了. D.Polyline 题意杀,还…
http://codeforces.com/contest/1092/problem/D2 Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The cur…
http://codeforces.com/contest/1092/problem/D1 Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The cur…