2 solutions

  • 0
    @ 2022-3-11 17:04:23

    #include<iostream> #include<cmath> #include<vector> #include<algorithm> using namespace std;

    struct kb{ double k; double b;

    } l; vector<kb> op;

    bool cmp(kb a,kb b) { if(a.k<b.k) { return 0; }else if(a.k>b.k) { return 1; }else{ if(a.b>b.b) { return 1; }else{ return 0; } } }

    int main() {

    for(int x1=0;x1<=19;x1++)
    {
    	for(int y1=0;y1<=20;y1++)
    	{
    		for(int x2=0;x2<=19;x2++)
    		{
    			for(int y2=0;y2<=20;y2++)
    			{
    				if(x2-x1!=0)
    				{
    					l.k=(double)(y2-y1)/(x2-x1);
    					l.b=y2-l.k*x2;
    					op.push_back(l);	
    				}
    				
    			}
    		}
    	}
    }
    sort(op.begin(),op.end(),cmp);
    
    int res=1;
    
    for(auto it=op.begin()+1;it!=op.end();it++)
    {
    	if(abs((*it).k-(*(it-1)).k)>1e-8||abs((*it).b-(*(it-1)).b)>1e-8)
    	{
    		
    		res++;
    	} 
    }
    
    cout<<res+20;
    

    }

    • 1

    Information

    ID
    1558
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    92
    Accepted
    32
    Uploaded By