| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:看我用pair, 代码如何。想当年做topcoder跟misof学的,的确好用阿!In Reply To:看我用pair, 代码如何。想当年做topcoder跟misof学的,的确好用阿! Posted by:Hacker_QC at 2010-03-16 13:33:19 > #include <cstdio>
> #include <cstdlib>
> #include <string>
> #include <set>
> #include <algorithm>
> using namespace std;
> #define F(i,m,n) for (int i = m; i < n; ++i)
> typedef pair<int, int> PII;
> set<PII> lines;
> int x[202], y[202];
>
> int main() {
> // freopen("in.txt", "r", stdin);
> int dx, dy, N;
>
> while (scanf("%d", &N) == 1) {
> lines.clear();
> F(i, 0, N) scanf("%d %d", &x[i], &y[i]);
> F(i, 0, N-1) F(j, i+1, N) {
> dx = x[j] - x[i], dy = y[j] - y[i];
> int gcd = __gcd(dx, dy);
> dx /= gcd, dy /= gcd;
> lines.insert(PII(dx, dy));
> }
> printf("%lu\n", lines.size());
> }
>
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator