UVALive 6179 Windmill Animation 规律题
来源:互联网 发布:淘宝购物人群分析 编辑:程序博客网 时间:2024/06/01 08:17
题目链接:点击打开链接
打表找规律
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<cmath>#include<vector>using namespace std;const double Pi = acos(-1.0);typedef long long ll;const int N = 100;int n, k, now, pre;struct node{double x, y, ans;}a[N];double jiao;double work(double x){while(x<0)x+=Pi;while(x>Pi)x-=Pi;return x;}double dis(node i, node j, node k){j.x -= i.x; j.y -= i.y;k.x -= i.x; k.y -= i.y;return acos((j.x*k.x+j.y*k.y)/(sqrt(j.x*j.x + j.y*j.y) * sqrt(k.x*k.x + k.y*k.y)));}bool xmul(node i, node j, node k){j.x -= i.x; j.y -= i.y;k.x -= i.x; k.y -= i.y;return (j.x*k.y - j.y*k.x) > 0;}void solve(){int ans = -1; double hehe;node X, Y;X.x = a[now].x + 1000.0*cos(jiao);Y.x = a[now].x + 1000.0*cos(jiao+Pi);X.y = a[now].y + 1000.0*sin(jiao);Y.y = a[now].y + 1000.0*sin(jiao+Pi);for(int i = 1; i <= n; i++) if(i!=now){ if(i==pre) {a[i].ans = Pi;} else { // double a1 = dis(a[now], X, a[i]), a2 = dis(a[now], Y, a[i]);printf("a[%d] : %.6f %.6f\n", i, a1, a2); if(xmul(a[now], X, a[i])) a[i].ans = work(dis(a[now], X, a[i])); else a[i].ans = work(dis(a[now], Y, a[i])); }if(ans == -1 || hehe > a[i].ans){ans = i;hehe = a[i].ans;}}jiao += a[ans].ans;jiao = work(jiao);pre = now;now = ans;}int main(){int T, Cas;scanf("%d",&T);while(T--){scanf("%d %d %d %d %lf",&Cas,&n,&k,&now,&jiao);jiao = jiao/180.0*Pi;for(int i = 1; i <= n; i++){int num; double x,y;scanf("%d %lf %lf",&num,&x,&y);a[num].x = x;a[num].y = y;}pre = -1;printf("%d",Cas);while(k--){solve();printf(" %d", now);}puts("");}return 0;}/**/
0 0
- UVALive 6179 Windmill Animation 规律题
- UVALive 6179 Windmill Animation 解题报告
- hdu 4491 Windmill Animation
- hdu4491 Windmill Animation (几何)
- H - Windmill Animation
- hdu4491 Windmill Animation(计算几何)
- 简单计算几何 hdu-4491 Windmill Animation
- hdu 4491 Windmill Animation(几何+模拟)
- 【找规律】UVALive
- UVALive 6177 The King's Ups and Downs 规律题
- UVALive 6174 Pen Counts 规律
- UVALive 6847Zeroes(规律)
- UVALive 6847 Zeroes(找规律)
- UVALive 6844Combination(打表找规律)
- UVALive - 6832 Bit String Reordering (找规律)
- UVALive 7045 Last Defence(找规律)
- Beehive UVALive - 7528 (找规律+数学思维)
- UVALive 6270 Edge Case(找规律,大数相加)
- ibatis查询的两种映射方式
- 沃尔玛电商“迷途”:与1号店协同之难
- HDU 5029 - Relief grain (树链剖分 很巧妙的离线标记法)
- java对象
- leetcode-Recover Binary Search Tree
- UVALive 6179 Windmill Animation 规律题
- {转官网}ROS-Hydro安装
- JavaIO模型
- java 面向对象一
- 【产品经理】App应用产品法则
- ******二维数组&指针的指针******
- UVALive 6181 Mystery (水
- struts中OGNL表达式
- java Date类介绍