题目链接:点击打开链接
Time Limit:1s Memory Limit:1024MByte
Submissions:205Solved:106
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.
For each test case:
The input contains a single odd integer N (3≤N≤1000)N (3≤N≤1000).
大意:给出一个奇多边形,每次操作可以使一个顶点和这个顶点所对应的对面的两个顶点旋转 180 度,每个点的初始状态都是朝向多边形中心,问最少需要几次操作使得所有的顶点都朝向外边。
思路:规律题,3 的倍数时需要 n/3 次,其他需要 n 次。
#include<cstdio>
using namespace std;
int n;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n%3==0)
printf("%d\n",n/3);
else
printf("%d\n",n);
}
return 0;
}