Codeforces Round #431 (Div. 2) Tell Your World
来源:互联网 发布:战舰世界雷鸣数据 编辑:程序博客网 时间:2024/06/01 09:01
不算很水的一个题
找到和1,2不一条线的一个点。
如果不能找到,就是他们一条线了,错误,
然后3个不共线的点,如果有两条直线平行一共有三种可能。
#include<bits\stdc++.h>using namespace std;typedef long long ll;int a[1005];int main(){ int n; while(~scanf("%d",&n)) {for(int i=1;i<=n;i++)scanf("%d",&a[i]); double t1,t2,t3; t1=t2=t3=0; int cnt1,cnt11,cnt2,cnt22,cnt3,cnt33; cnt1=cnt11=cnt2=cnt22=cnt33=cnt3=1; int i; for(i=3;i<=n;i++) { if(a[i]-a[i-1]==a[2]-a[1])continue; break; } cnt1=i-1; if(i>n){printf("No\n");break;} t1=a[2]-a[1]; double b1,b2,b3,b11,b22,b33; t2=1.0*(a[i]-a[2])/(i-2); t3=1.0*(a[i]-a[1])/(i-1); b1=a[i]-i*t1; b2=a[1]-t2; b3=a[2]-2*t3; b11=a[1]-t1; b22=a[2]-2*t2; b33=a[i]-i*t3; int flag=0; for(i+=1;i<=n;i++) { if(1.0*i*t1+1.0*b1==a[i])cnt1++; else if((1.0*i*t1+1.0*b11)==a[i])cnt11++; } if(cnt1+cnt11==n)flag=1; //cout<<cnt1<<" "<<cnt11<<endl; for(i=3;i<=n;i++) { if(1.0*i*t2+1.0*b2==a[i])cnt2++; else if(1.0*i*t2+1.0*b22==a[i])cnt22++; } // cout<<cnt2<<" "<<cnt22<<endl; if(cnt2+cnt22==n)flag=1; for(i=3;i<=n;i++) { if(1.0*i*t3+1.0*b3==a[i])cnt3++; else if(1.0*i*t3+1.0*b33==a[i])cnt33++; } // cout<<cnt3<<" "<<cnt33<<endl; if(cnt3+cnt33==n)flag=1; if(flag==1)printf("Yes\n"); else printf("No\n");} return 0;}
阅读全文
0 0
- Codeforces Round #431 (Div. 2) Tell Your World
- Codeforces Round #431 (Div. 2) B. Tell Your World
- Codeforces Round #431 (Div. 2)B Tell Your World
- Codeforces Round #431 (Div. 2) B. Tell Your World(向量积)
- Codeforces Round #431 (Div. 2) 849B Tell Your World(暴力+枚举)
- Codeforces Round #431 (Div. 2) B. Tell Your World(技巧性模拟+精度坑死人系列)
- B. Tell Your World Codeforces Round #431 (Div. 2)(简单模拟)
- Codeforces Round #431 (Div. 2) A、Odds and Ends B、Tell Your World C、From Y to Y
- CodeForces #431Div. 2 849B Tell your world 几何 暴力 枚举
- Codeforces Tell Your World
- Codeforces 849 B Tell Your World
- CodeForces 849B Tell Your World 点线
- codeforces 849B. Tell Your World
- codeforces 849B Tell Your World
- Codeforces-849B Tell Your World
- Codeforces 894B. Tell Your World
- Codeforces849B Tell Your World
- codeforces 431B Tell Your World(两平行线穿过所有点)【模板】
- Codeforces Round #431 (Div. 2) Odds and Ends
- Java Socket 网络编程常见异常
- SpringMVC和rabbitmq集成使用
- Cocoapods 报警告Automatically assigning platform ios with version 9.0 on target....
- 【android学习】Toast(消息弹框)
- Codeforces Round #431 (Div. 2) Tell Your World
- Bigtable: A Distributed Storage System for Structured Data : part5 Implementation
- 代码规范和Android项目中的一些可用工具
- ASCII、Unicode和UTF-8
- 基于NGINX的安全加固
- 【binary-tree-preorder-traversal】
- 301,404,网站地图
- 【备忘】Java菜鸟到大牛学习路线之高级篇
- 数学建模程序员从入门到进阶系列博客——目录