Chinese Girls' Amusement

Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)

SubmitStatisticNext Problem

Problem 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 ≤ 102000) — 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

题目大意:一个n个女士的环传球,每次向左穿k个人(1<=k<=n>>1),要求每个人都穿到球,问k最大为多少

思路:这题显然要求max(k)|(1<=k<=n>>1),(k,n)=1

当n为奇数时 显然(n-1)/2为所求,当n为偶数时当n/2为偶数时减一就行 当n/2为奇数时减2就行,然后就是ACDREAM逗比的输入,while(scanf(xxx)!=EOF)竟然报WA!

#include <stdio.h>

#include <string.h>

#define maxn 2000

char ch[maxn];

void dec(char *ch,int &l)

{

ch[1]--;

for(int i=1;i<=l;i++)if(ch[i]<0)ch[i]+=10,ch[i+1]--;

if(ch[l]==0)l--;

}

int main()

{

scanf("%s",ch+1);

int l=strlen(ch+1),flag=0;

for(int i=1;i<=(l>>1);i++){

int temp=ch[i];ch[i]=ch[l-i+1];ch[l-i+1]=temp;

}

for(int i=1;i<=l;i++)ch[i]-='0';

if((ch[1])&1)dec(ch,l);else flag=1;

for(int i=l;i>=1;i--)if(!ch[i]%2)ch[i]>>=1;else

{

ch[i-1]+=(ch[i]%2)*10;

ch[i]=ch[i]/2;

}

if(ch[l]==0)l--;

if(flag && !(ch[1]&1))dec(ch,l);else

if(flag && (ch[1]&1))for(int i=1;i<=2;i++)dec(ch,l);

for(int i=l;i>=1;i--)printf("%d",ch[i]);

printf("\n");

return 0;

}

ACDream:1210:Chinese Girls' Amusement【水题】的更多相关文章

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

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

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

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

  3. Acdream Chinese Girls' Amusement

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

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

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

  5. 2016NEFU集训第n+5场 A - Chinese Girls' Amusement

    Description       You must have heard that the Chinese culture is quite different from that of Europ ...

  6. 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 ...

  7. 2013成都网络赛 C We Love MOE Girls(水题)

    We Love MOE Girls Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. Chinese Zodiac (水题)

    The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle rel ...

  9. acdream B - 郭式树 (水题 卡cin,cout, 卡LL)

    题目 输入正好是long long的最大, 但是答案超long long 所以用unsigned, 不能用cin cout否则一定超时: 不能用abs(), abs 只用于整数. unsigned   ...

随机推荐

  1. 如何轻松实现MySQL数据库的读写分离和负载均衡?

    配置好了 Mysql 的主从复制结构后,我们希望实现读写分离,把读操作分散到从服务器中,并且对多个从服务器能实现负载均衡.读写分离和负载均衡是 Mysql 集群的基础需求,MaxScale 就可以帮着 ...

  2. 远程桌面连接windowsServer

    1.win+R 打开windows运行工具栏: 2.输入 mstsc ,确定: 3.登录设置: 计算机:目标服务器ip地址:用户名:管理员或者用户的用户名,例如:administrator:密码:账户 ...

  3. 年度精品 XP,32/64位Win7,32/64位Win10系统【电脑城版】

    随着Windows 10Build 10074 Insider Preview版发布,有理由相信,Win10离最终RTM阶段已经不远了.看来稍早前传闻的合作伙伴透露微软将在7月底正式发布Win10的消 ...

  4. Outlook 数据文件(.pst 和 .ost)简介

    使用 Microsoft Outlook 时,电子邮件.日历.任务和其他项目保存在邮件服务器或计算机上,或者同时保存在这两个位置.如果 Outlook 项目保存在计算机上,则它们保存在 Outlook ...

  5. MATLAB GUI制作快速入门

    创建空白的GUI在MATLAB命令行中输入guide新建GUI,选择Blank GUI (Default),点击确定后就生成了一个空白的GUI制作界面,如下图所示 图1制作GUI的具体过程简单加法器将 ...

  6. 为什么要使用spl_autoload_unregister

    最近学习 laravel 源码,发现他的 autoload_real.php 里面有一段: spl_autoload_register(array('ComposerAutoloaderInit290 ...

  7. 聊天室(C++客户端+Pyhton服务器)_1.框架搭设

    聊天室 一.客户端发送 用MFC可视化做个客户端登录界面. 先点击注册账号按钮,注册账号的时候就需要连接到服务器, 服务器需要查数据库,并做出相应的回应. 所以开始写C++客户端套接口类用来连接到服务 ...

  8. 细说PHP-5.3.4变量的引用赋值

    变量总是传值赋值.也就是说,当讲一个表达式的值赋予一个变量时,整个原始表达式的值被赋值到目标变量.这意味着,当一个变量的值赋予另个一变量时,改变其中一个变量的值,将不会影响到另一个变量.PHP中提供了 ...

  9. ios之coredata

    Core Data数据持久化是对SQLite的一个升级,它是ios集成的,在说Core Data之前,我们先说说在CoreData中使用的几个类. (1)NSManagedObjectModel(被管 ...

  10. spring注解开发-扩展原理(源码)

    1.BeanFactoryPostProcessor BeanPostProcessor:bean后置处理器,bean创建对象初始化前后进行拦截工作的; BeanFactoryPostProcesso ...