POJ-1118(超时,但未找到原因)

#include<iostream>
#include<map>
#include<vector>
using namespace std; //y=kx+z
typedef struct{
double k;
double z;
int count;
}Skzc; int main(int argc, char *argv[]){
int inputCunt; while(cin>>inputCunt && inputCunt!=0){
if(inputCunt==0){
break;
} //(x,y)
multimap<int,int> place;
vector<Skzc> kzcVector;
map<int, int> countMap;
int resultCount=1;
int x,y;
int verticalFlyCunt=0; Skzc kzc; bool findFlag=false; for(int i=0;i<inputCunt;i++){
cin>>x>>y;
place.insert(pair<int,int>(x,y));
}
//input finish and sort for(multimap<int, int>::iterator iter1=place.begin();
iter1!=place.end();
++iter1){
x=iter1->first;
y=iter1->second; for(multimap<int, int>::iterator iter3=place.begin();
iter3!=iter1;
++iter3){ if(x-iter3->first==0){
verticalFlyCunt++;
}else{
kzc.k=1.0*(y-iter3->second)/(x-iter3->first);
kzc.z=y-kzc.k*x; for(vector<Skzc>::iterator iter2=kzcVector.begin();
iter2!=kzcVector.end();
++iter2){
if(iter2->k==kzc.k &&
iter2->z==kzc.z){
iter2->count++; if(iter2->count>resultCount){
resultCount=iter2->count;
} findFlag=true;
break;
}else{
findFlag=false;
}
} if(findFlag==false){
kzc.count=1;
kzcVector.push_back(kzc);
}
}
}
} if(resultCount>verticalFlyCunt){
cout<<resultCount<<endl;
}else{
cout<<verticalFlyCunt<<endl;
}
}
return 0;
}
上一篇:转!!SpringMVC与Struts2区别与比较总结


下一篇:git入门知识了解