Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:简单水过很不爽。。。

Posted by whosyourdaddy at 2010-06-20 04:24:48 on Problem 1118
In Reply To:简单水过很不爽。。。 Posted by:200831000423 at 2010-04-29 19:33:21
那就想想怎么优化呗

> #include<iostream>
> #include<cstdlib>
> #include<cstdio>
> using namespace std;
> 
> const int LEN = 700;
> int x[LEN], y[LEN];
> 
> void solve(int n) {
>     int max(0), temp_max(0);
>     for (int i = 0; i < n; ++i) {
>         for (int j = i + 1; j < n; ++j) {
>             temp_max = 0;
>             for (int k = j + 1; k < n; ++k) {
>                 if ((x[k] - x[i])*(y[j] - y[i]) == (x[j] - x[i])*(y[k] - y[i]))
>                     ++temp_max;
>             }
>             max = max > temp_max ? max : temp_max;
>         }
>     }
>     cout << max + 2 << endl;
> }
> 
> int main() {
>     int cases;
>     while (scanf("%d", &cases) && cases) {
>         for (int i = 0; i < cases; ++i)
>             scanf("%d%d", x + i, y + i);
>         solve(cases);
>     }
>     return EXIT_SUCCESS;
> }
> 
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator