题意:给出n个不同的点,问能组成多少个不同的三角形 题解:对于每个点对,我们生成一个直线,用a*x+b=y表示,用map记录ab,这样就确定了一个直线,这样我们就能算出有多少点是共线的,这样复杂度就是O(N*N*lgN) 虽然这个题目n的三次方也可以过…
time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard output Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many tri…
这个题的意思就是给出一个数m.以及一个以1为首元素.w为比例常数的等比数列,数列长度为101,数列中每一个数字最多仅仅能用一次.问是否存在xa+wb+--=wc+wd+--+we+m. 非常显然,换句话说就是问,是否存在m=wa+wb+--+wf-wc-wd----we.再进行化简就能够得到.是在问,是否存在m=((((wh±1)wi±1)±1)wj±1)wk--. 那么非常显然可以进行搜索,比方说用广搜,每次当前的m±1中若有因子w就所有约掉,然后丢到队列中,否则就不用管,仅仅要队列中可以出现…
题目链接 讲道理距离上一次写这种求值的题已经不知道多久了. 括号肯定是左括号在乘号的右边, 右括号在左边. 否则没有意义. 题目说乘号只有15个, 所以我们枚举就好了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <complex> #include <cmath&…
D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/problem/D Description Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as…
枚举法: 枚举法是利用计算机速度快, 精度高的特点, 对要解决的问题所有可能情况进行霸道的, 一个不漏检验, 从中找出符合要求的答案. 特点: 1. 得到的结果一定正确. 2. 可能做了很多无用功,效率低下. 3. 一般会涉及到极值. 4. 数据量大的话可能造成时间崩溃. 结构: 循环结构. 基本思路: 1. 确定枚举对象, 枚举范围, 判定条件. 2. 枚举可能的解, 验证是否是问题的解. Vanya and Triangles : M - Vanya and Triangles Crawli…
Codeforces  492B   B. Vanya and Lanterns 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/B 题目: Description Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya is doing his maths homework. He has an expression of form , where x1, x2, -, xn are digits from 1 to 9, and sign represents either a plus '…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya has a scales for weighing loads and weights of masses w0,?w1,?w2,?-,?w100 grams where w is some integer not less than 2 (exactly one weight…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya got an important task - he should enumerate books in the library and label each book with its number. Each of the n books should be assigne…