HOJ 2258 Rotating
来源:互联网 发布:js获取img的alt 编辑:程序博客网 时间:2024/06/06 04:01
http://acm.hit.edu.cn/hoj/problem/view?id=2258
正n边形外接圆半径R=1
沿贴地的那一边滚动m次
求最开始在最左下那个顶点的移动轨迹长度
正n边形内角A=2*pi/n
易知该正n边形滚动n次之后回到初始状态
以正五边形为例
五边形如上图滚动4次
每次滚动半径如左图
可以计算出一个滚动周期内的顶点走过的距离
其余见代码
#include <stdio.h>#include <math.h>const double pi = acos(-1);int main(){ int t, n, m, i, c; double angle, r, arclength[1024], circle, totalength; scanf("%d",&t); while (t--) { scanf("%d %d", &n, &m); angle = 2*pi/n; c = m / n; m = m % n; totalength = 0, circle = 0; for (i = 1; i <= n / 2; i++) { r = sqrt(2 - 2 * cos(i*angle) ); arclength[i] = arclength[n-i] = angle * r; } arclength[n] = 0; for (i = 1; i <= n; i++) circle += arclength[i]; for (i = 1; i <= m; i++) totalength += arclength[i]; totalength += c*circle; printf("%.2lf\n", totalength); } return 0;}
- HOJ 2258 Rotating
- HOJ
- Rotating Sentences
- Rotating Rings
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Sentences
- Rotating Scoreboard
- 490 - Rotating Sentences
- POJ 3509 Rotating Rings
- uvaoj 490 - Rotating Sentences
- XCode基础知识
- show_space(查看表空间使用情况)
- 数独(sudoku)C++
- VBA中给变量赋值使用set和不使用set的区别
- WLAN与WIFI的区别
- HOJ 2258 Rotating
- Trie 树的简单实现
- SQL Server数据库备份还原时,提示“数据库正在使用”的解决办法
- window.opener用法
- 条款26的一个补充小例子
- POJ 1459 Power Network
- 一问一答
- __attribute__机制介绍
- 基于S3C2440的linux-3.6.6移植——内核移植,建立自己的平台系统