Description

      You must have heard that the Chinese culture is quite different from that of Europe or Russia. So some Chinese habits seem quite unusual or even weird to us. 
      So it is known that there is one popular game of Chinese girls. N girls stand forming a circle and throw a ball to each other. First girl holding a ball throws it to the K-th girl on her left (1 ≤ K ≤ N/2). That girl catches the ball and in turn throws it to the K-th girl on her left, and so on. So the ball is passed from one girl to another until it comes back to the first girl. If for example N = 7 and K = 3, the girls receive the ball in the following order: 1, 4, 7, 3, 6, 2, 5, 1. 
 To make the game even more interesting the girls want to choose K as large as possible, but they want one condition to hold: each girl must own the ball during the game.

Input

Input contains one integer number N (3 ≤ N ≤ 10 2000) — the number of Chinese girls taking part in the game.

Output

Output the only number — K that they should choose.

Sample Input

7
6

Sample Output

3
1
#include <iostream>
#include <cstring>
using namespace std;
char data[];
int a[],d,c[]; int main()
{
while(cin>>data)
{
memset(a,,sizeof(a));
int len1=strlen(data);
for(int i=;i<len1;i++)
a[i]=data[len1-i-]-'';
d=;
for(int i=len1-;i>=;i--)
{
d=d*+a[i];
c[i]=d/;
d=d%;
}
if(a[]%==){
while(c[len1-]==&&len1>) len1--;
for(int i=len1-;i>=;i--)
cout<<c[i];
cout<<endl;}
else
{
if(c[]%==)//得到奇数减2
{
if(c[]>=)
c[]-=;
else
{
for(int i=;i<len1;i++)
{
if(c[i]<=)
{
c[i+]--;
c[i]=(c[i]+)-;
}
else
break;
}
}
}
else //得到偶数减1
{
if(c[]>=)
c[]-=;
else
{
for(int i=;i<len1;i++)
{
if(c[i]<=)
{
c[i+]--;
c[i]=(c[i]+)-;
}
else
break;
}
}
}
while(c[len1-]==&&len1>) len1--;
for(int i=len1-;i>=;i--)
cout<<c[i];
cout<<endl;
}
}
return ;
}

2016NEFU集训第n+5场 A - Chinese Girls' Amusement的更多相关文章

  1. 数学+高精度 ZOJ 2313 Chinese Girls' Amusement

    题目传送门 /* 杭电一题(ACM_steps 2.2.4)的升级版,使用到高精度: 这次不是简单的猜出来的了,求的是GCD (n, k) == 1 最大的k(1, n/2): 1. 若n是奇数,则k ...

  2. Acdream Chinese Girls' Amusement

    A - Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Jav ...

  3. ACdream 1210 Chinese Girls' Amusement(高精度)

     Chinese Girls' Amusement Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & ...

  4. ACDream:1210:Chinese Girls' Amusement【水题】

    Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Oth ...

  5. A - Chinese Girls' Amusement ZOJ - 2313(大数)

    You must have heard that the Chinese culture is quite different from that of Europe or Russia. So so ...

  6. 2016NEFU集训第n+3场 E - New Reform

    Description Berland has n cities connected by m bidirectional roads. No road connects a city to itse ...

  7. 2016NEFU集训第n+3场 G - Tanya and Toys

    Description In Berland recently a new collection of toys went on sale. This collection consists of 1 ...

  8. 2016NEFU集训第n+3场 D - Bicycle Race

    Description Maria participates in a bicycle race. The speedway takes place on the shores of Lake Luc ...

  9. acdream 1210 Chinese Girls' Amusement (打表找规律)

    题意:有n个女孩围成一个圈从第1号女孩开始有一个球,可以往编号大的抛去(像传绣球一样绕着环来传),每次必须抛给左边第k个人,比如1号会抛给1+k号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次 ...

随机推荐

  1. pack://application:,,,/

    FrameworkElementFactory gridFactory = new FrameworkElementFactory(typeof(Grid)); gridFactory.SetValu ...

  2. 字符函数库 - cctype 和 climits 中的符号常量

    一. C++从C语言中继承一个与字符相关的.非常方便的函数软件包,他可以简化诸如确定字符是否为大写字母‘数字.标点符号等工作,这些函数的原型在头文件cctype(老式的为ctype.h)中定义的.例如 ...

  3. CodeForces 670E Correct Bracket Sequence Editor

    链表,模拟. 写一个双向链表模拟一下过程. #pragma comment(linker, "/STACK:1024000000,1024000000") #include< ...

  4. 《C++反汇编与逆向分析技术揭秘》——流程控制语句的识别

    if...else...语句 示例: if构成多分支语句 switch 有序线性的switch: 3E82D8位置存放了一个表,标明了要跳转到的地址: 这里的每四字节都标明的是每个case块的首地址: ...

  5. HDU 4520 小Q系列故事——最佳裁判

    Time Limit : 500/200ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Problem Description 过 ...

  6. linux for 使用

    第一种:命令使用方法 例子1: cat test.txt 1 2 3 for i in $(cat test.txt) do echo $i done 例子2: for i in 1 2 3 4 do ...

  7. MultipartResolver 文件上传

    SpringMVC 中文件上传 MultipartResolver 博客分类: SpringMVC - 基础篇   基于前面文章的基础上. 一.准备 需要的jar  二.配置 1.  spmvc-se ...

  8. LINQ_to_SQL语法及实例大全

    LINQ To SQL 语法及实例大全 2011/4/5 目录 LINQ to SQL语句(1)之Where. 2 Where操作... 2 1.简单形式:... 2 2.关系条件形式:... 2 3 ...

  9. java实现的快速排序算法

    快速排序的原理:选择一个关键值作为基准值.比基准值小的都在左边序列(一般是无序的),比基准值大的都在右边(一般是无序的).一般选择序列的第一个元素. 一次循环:从后往前比较,用基准值和最后一个值比较, ...

  10. C++友元

    通过friend关键字,我们可以将不属于当前类的一个函数在当前类中加以声明,该函数便可以成为当前类的友元函数. 例1: #include<iostream>using namespace ...