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号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次 ...
随机推荐
- 字符函数库 - cctype 和 climits 中的符号常量
一. C++从C语言中继承一个与字符相关的.非常方便的函数软件包,他可以简化诸如确定字符是否为大写字母‘数字.标点符号等工作,这些函数的原型在头文件cctype(老式的为ctype.h)中定义的.例如 ...
- vedio_note_1
同步复位 always @ (posedge clk) ....... 异步复位 always @ (posedge clk or negedge rst_n) ....... 异步复位和同步复位的优 ...
- Atom编辑器之加快React开发的插件汇总
汇总下比较实用的atom插件[偏react开发的]-- 博主发现这个还是比较全面的! atom-react-autocomplete–项目内,组件名及状态的自动补全 autocomplete-js- ...
- insertable = false, updatable = false的使用
转自:insertable = false, updatable = false的使用 当使用JPA配置实体时,如果有两个属性(一个是一般属性,一个是多对一的属性)映射到数据库的同一列,就会报错. 这 ...
- html-webpack-plugin
插件地址:https://www.npmjs.com/package/html-webpack-plugin 这个插件用来简化创建服务于 webpack bundle 的 HTML 文件,尤其是对于在 ...
- 浙大pat 1012题解
1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
- Openjudge-NOI题库-和数
题目描述 Description 给定一个正整数序列,判断其中有多少个数,等于数列中其他两个数的和. 比如,对于数列1 2 3 4, 这个问题的答案就是2, 因为3 = 2 + 1, 4 = 1 + ...
- (从零开始java开发) IDEA+MAVEN构建一个webapp骨架项目(解决一直downloading问题)
折腾了一段时间终于解决了, 可能是因为网络问题 xml一直没法访问 maven 骨架生成项目速度慢的令人发指,都在Generating project in Batch mode等待,Idea状态显示 ...
- JQuery笔记(一)jq的使用方法
我用的jq版本是支持pc版为主的最高1版本里最高的1.124版本 官网的链接是只有最新的3下载,我把我在官网下载的jq代码链接发出来,如下 点我获取jq代码 和js不同的是,jq开发者封装了一些方法 ...
- 数据库连接池druid
推荐一个带监控的数据库连接池druid,阿里的,据说比c3p0连接池性能要好点,主要是带sql,spring,uri等访问监控,比较直观地址: https://github.com/alibaba/d ...