玲珑学院problem1068
来源:互联网 发布:python 机器人 编辑:程序博客网 时间:2024/04/29 15:20
DESCRIPTION
Mr. Van is given a regular polygon of size N, which is a positive odd number. At each vertex there is a guard which can be rotated. Initially, all the guards face to the inner center of the vertex. Now Mr. Van wants to rotate all guards faced to the outside. A guard can only be rotated 180 degree in one step. When he rotates the a guard 180 degree, the guard itself and the two guards which are opposite to it will also rotate 180 degree. Now given N, please tell Mr.Van the minimum steps of rotating in order to turn all the guards faced to the outside.
INPUT
The first line is a single integer TT, indicating the number of test cases.
For each test case:
The input contains a single odd integer N (3≤N≤1000)N (3≤N≤1000).
For each test case:
The input contains a single odd integer N (3≤N≤1000)N (3≤N≤1000).
OUTPUT
For each test case, output the answer in a single line.
SAMPLE INPUT
2
5
3
SAMPLE OUTPUT
5
1
思路还是挺简单的:每一次的旋转,都会有三个点的旋转,当每个点的旋转次数都为奇数次的时候也就达到目的了。所以可以直接从1开始枚举操作次数,假设多边形的边数是n,当操作次数i满足条件:i*3能被n整除,且i*3/n(表示每个定点被操作的次数)为奇数时就得到答案了,我们不用去管怎么操作,只用知道最少操作这么多次就可达到目的。
#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;int T;void init(){freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);}void readdata(){scanf("%d", &T);}void work(){int n;while(T--){scanf("%d", &n);for(int i = 1; ; i++){int cnt = i*3;if(cnt%n == 0 && cnt/n%2 == 1){printf("%d\n", i);break;}}}}int main(){init();readdata();work();return 0;}
0 0
- 玲珑学院problem1068
- 玲珑学院 1058 - Coco
- 玲珑学院1072 【DFS】
- 玲珑学院 1097
- 玲珑学院-1107【贪心】
- 玲珑学院OJ 1126
- 玲珑学院OJ 1125
- 玲珑学院OJ 1131
- 玲珑学院1131
- 玲珑学院1129
- 玲珑学院OJ 1121
- 玲珑学院1129
- 玲珑学院OJ 1130
- 玲珑学院 1132
- 【玲珑学院 1050 - array 】+ dp
- 【玲珑学院 1051 - My-graph】
- 【玲珑学院 1046 - chess play】
- 玲珑学院 1050 - array--dp
- UVA - 10054 The Necklace 欧拉回路
- Java 集合类图(转)
- win10怎么调cmd
- 提高Xcode编译速度
- ios中音视频录制,以及 压缩
- 玲珑学院problem1068
- Java集合总结汇总(链接)
- Android 面试题
- atitit. 深入理解Cohesion)原理ad attilax大总结
- shell判断文件或文件夹是否存在
- vector<char> to string
- unity在安卓下的播放在线视频,但不能做全景视频
- listview 带轮播的上拉刷新下拉刷新
- 阿里巴巴矢量图标库