2020-6-1 线性分类器
问题描述
试题编号: | 202006-1 |
试题名称: | 线性分类器 |
时间限制: | 1.0s |
内存限制: | 512.0MB |
问题描述: |
|
/*2020-6-1 线性分类器*/ #include<stdio.h> struct point { int a,b; char c; }p[1010]; int main() { int n,m; int count1=0,count2=0,count3=0,count4=0; int q1,q2,q3; scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { scanf("%d%d %c",&p[i].a,&p[i].b,&p[i].c); } for(int i=0;i<m;i++) { scanf("%d%d%d",&q1,&q2,&q3); count1=0; count2=0; count3=0; count4=0; for(int j=0;j<n;j++) { if(q1+q2*p[j].a+q3*p[j].b>0) { if(p[j].c == 'A') { count1++;//A>0的点 } else { count2++;//B>0的点 } } else if(q1+q2*p[j].a+q3*p[j].b<0) { if(p[j].c == 'A') { count3++;//A<0的点 } else { count4++;//B<0的点 } } } //printf("%d %d\n",count1,count2); if((count1!=0&&count3!=0)||(count2!=0&&count4!=0)) { printf("No\n"); } else { printf("Yes\n"); } } return 0; } /* 输入 9 3 1 1 A 1 0 A 1 -1 A 2 2 B 2 3 B 0 1 A 3 1 B 1 3 B 2 0 A 0 2 -3 -3 0 2 -3 1 1 */
本文来自博客园,作者:永恒&,转载请注明原文链接:https://www.cnblogs.com/Sun-yuan/p/14455986.html