650A Watchmen 637A Voting for Photos 点击查看原题 650A又是一个排序去重的问题,一定要注意数据范围用long long ,而且在写计算组合函数的时候注意也要用long long 虽然10^9没有超过long的范围,但是在计算n*(n-1)/2的过程中超了,所以需要用long long ,否则会出错. #include<iostream> #include<cmath> #include<cstdlib> #include<c…
http://codeforces.com/contest/794/problem/C Description Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the…
651B Beautiful Paintings 651A Joysticks 点击可查看原题 651B是一个排序题,只不过多了一步去重然后记录个数.每次筛一层,直到全为0.从这个题里学到一个正确姿势:给定一个排好序的的数组,怎么把它变成一个去重加权的新数组. 只需要一个while循环+一个指针. #define N 10 #include<iostream> using namespace std; int main() { ,,,,,,,,,}; int b[N]={}; int c[N]…
http://codeforces.com/problemset/problem/786/A Description Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer. In this game…
Description There are n cities in Berland, each of them has a unique id - an integer from 1 to n, the capital is the one with id 1. Now there is a serious problem in Berland with roads - there are no roads. That is why there was a decision to build n…
Description As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters "(" and &quo…
Watchmen CodeForces - 650A Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi). They need to arra…
PE刷题记录 PE60 / 20%dif 这道题比较坑爹. 所有可以相连的素数可以构成一张图,建出这张图,在其中找它的大小为5的团.注意上界的估算,大概在1W以内.1W内有1229个素数,处理出这些素数的关系,然后dfs这张图找出大小为5的团. /*** * @name Prime pair sets * @author zball * @algorithm Sieve for primes and dfs search for finding a set of primes */ #inclu…
大四狗找工作,要刷题了,leetcode上面题目比较适合面试算法类题目,也不纯粹为了蒙题,锻炼一下面试类型的思维 Single Number: 有N个数,其中只有一个数出现了一次,其他都是两次,找出那个数 把所有数求一下异或 Maximum Depth of Binary Tree: 求树的最大深度 递归遍历一遍 Same Tree: 给两个树的根节点,看两棵树是否相同 两棵树同时遍历一遍 Reverse Integer: 输出这个数倒过来的数 注意负数情况,模拟一下即可 Best Time t…
写在前面:因为要准备面试,开始了在[LeetCode]上刷题的历程.LeetCode上一共有大约150道题目,本文记录我在<http://oj.leetcode.com>上AC的所有题目,以Leetcode上AC率由高到低排序,基本上就是题目由易到难.我应该会每AC15题就过来发一篇文章,争取早日刷完.所以这个第一篇就是最简单的15道题了. 部分答案有参考网上别人的代码,和leetcode论坛里的讨论,很多答案肯定有不完美的地方,欢迎提问,指正和讨论. No.1 Single NumberGi…