编辑代码

#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
const int N=2e5+10;
struct line
{
    double k,b;
    bool operator<(const line& t) const
    {
        if(k!=t.k) return k<t.k;
        return b<t.b;
    }

}L[N];
int n=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(x1!=x2){
                    double k=(double)(y2-y1)/(x2-x1);
                    double b=k*x1-y1;
                    L[n++]={k,b};
                    }
                }
            }
        }
    }

    sort(L,L+n);
    int res=1;
    for(int i=1;i<n;i++){
        if(fabs(L[i].k-L[i-1].k)>1e-8||fabs(L[i].b-L[i-1].b)>1e-8){
            res++;
        }

    }
    printf("%d",res+20);
    return 0;
}