2016NEFU集训第n+5场 A - Chinese Girls' Amusement
Description
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
Output
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的更多相关文章
- 数学+高精度 ZOJ 2313 Chinese Girls' Amusement
题目传送门 /* 杭电一题(ACM_steps 2.2.4)的升级版,使用到高精度: 这次不是简单的猜出来的了,求的是GCD (n, k) == 1 最大的k(1, n/2): 1. 若n是奇数,则k ...
- Acdream Chinese Girls' Amusement
A - Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Jav ...
- ACdream 1210 Chinese Girls' Amusement(高精度)
Chinese Girls' Amusement Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & ...
- ACDream:1210:Chinese Girls' Amusement【水题】
Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Oth ...
- 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 ...
- 2016NEFU集训第n+3场 E - New Reform
Description Berland has n cities connected by m bidirectional roads. No road connects a city to itse ...
- 2016NEFU集训第n+3场 G - Tanya and Toys
Description In Berland recently a new collection of toys went on sale. This collection consists of 1 ...
- 2016NEFU集训第n+3场 D - Bicycle Race
Description Maria participates in a bicycle race. The speedway takes place on the shores of Lake Luc ...
- acdream 1210 Chinese Girls' Amusement (打表找规律)
题意:有n个女孩围成一个圈从第1号女孩开始有一个球,可以往编号大的抛去(像传绣球一样绕着环来传),每次必须抛给左边第k个人,比如1号会抛给1+k号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次 ...
随机推荐
- 【ARM】S5PV210芯片中的BL0的作用
S5PV210芯片中的BL0的作用:(1)关闭看门狗:(2)清除指令寄存器:(3)初始化栈区域:(4)初始化堆区域:(5)初始化块设备复制功能:(6)初始化PLL和设置系统时钟:(7)拷贝BL1到片内 ...
- tcp异常终止连接
服务端: #include <sys/socket.h> #include <unistd.h> #include <sys/types.h> #include & ...
- Java学习日志(20170111)
今日新知识点: 1.关键字volatile sychronized是同步锁,这个之前接触过,在类/方法或代码块前加该修饰词,即可实现线程同步: volatile也是一个修饰符,被volatile修饰的 ...
- POJ 3111 K Best
二分,排序,贪心. 最优比率生成树,可以二分$+$贪心来实现,不过这样做精度不行. 如果是这样一个问题,该如何解决:问你$n$个里面选择$k$个,能否使得$\frac{{\sum\limits_{j ...
- 消息队列 RabbitMQ 与 Spring 整合使用
一.什么是 RabbitMQ RabbitMQ 是实现 AMQP(高级消息队列协议)的消息中间件的一种,最初起源于金融系统,用于在分布式系统中存储转发消息,在易用性.扩展性.高可用性等方面表现不俗.消 ...
- js数组操作-数组去重
第一个和第二个,都是对新数组或新json进行操作,而第三个是对原数组本身进行indexOf.第一个是用新数组的indexOf来判断是否有重复元素,而第二个是通过nHash[item]来判断是否存在. ...
- Elasticsearch相关配置(二)
一.关于elasticsearch的基本概念 term 索引词,在elasticsearch中索引词(term)是一个能够被索引的精确值.foo,Foo Foo几个单词是不相同的索引词.索引词(ter ...
- js检测对象中是否存在某个属性
1.使用in关键字.该方法可以判断对象的自有属性和继承来的属性是否存在. 2.使用对象的hasOwnProperty()方法.该方法只能判断自有属性是否存在,对于继承属性会返回false. 3.用un ...
- 为OLED屏增加GUI支持
为OLED屏增加GUI支持1:OLED驱动 为OLED屏增加GUI支持2:2D图形库 为OLED屏增加GUI支持3:字库 为OLED屏增加GUI支持4:文本框控件 为OLED屏增加GUI支持5:图片控 ...
- mysql 分组按条件统计
百度经验 COUNT(CASE WHEN (S.rank = 1) THEN S.loanContractId END ) AS 'MZ', //根据loanContractId 分组,并统计ran ...