ACdream 1210 Chinese Girls' Amusement(高精度)
Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu
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>
#include <cstdio>
using namespace std;
int main()
{
int a[],b[];
char c[];
while(scanf("%s",c)!=EOF)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
int len=strlen(c);
int cnt=;
for(int i=; i<len; i++)
a[i]=c[i]-'';
for(int i=; i<len; i++)
{
b[i]=(a[i]+cnt*)/;
if(a[i]%==)
cnt=;
else
cnt=;
}
int jian=;
int sum=a[len-]*+a[len-];
//奇数就是除以2 偶数4的倍数除以2减1 偶数非4的倍数除以2减2
if(sum%==)
{
if(sum%==)
jian=;
else
jian=;
}
int sumb=,k=;
if(jian==)
{
int flag1=;
for(int i=len-; i>=; i--)
{
if(b[i]==)
{
flag1=;
continue;
}
else
{
k=i;
for(int j=k;j<len-;j++)
b[j]--;
if(flag1)
b[len-]=;
else
b[len-]--;
break;
}
}
}
else if(jian==) //
{
int flag=;
int flag2=;
if(b[len-]>=) //这个和上面的len-1不一样
{
b[len-]-=;
flag=;
flag2=;
}
for(int i=len-; i>=; i--) //最后一位肯定不行的
{
if(flag)
break;
if(b[i]==)
{
flag2=;
continue;
}
else
{//
k=i;
for(int j=k;j<len-;j++)
b[j]--;
b[len-]=b[len-]+-;
break;
}
}
}
int j=;
while(b[j]==) j++;
for(; j<len; j++)
printf("%d",b[j]);
printf("\n");
} return ;
}
ACdream 1210 Chinese Girls' Amusement(高精度)的更多相关文章
- acdream 1210 Chinese Girls' Amusement (打表找规律)
题意:有n个女孩围成一个圈从第1号女孩开始有一个球,可以往编号大的抛去(像传绣球一样绕着环来传),每次必须抛给左边第k个人,比如1号会抛给1+k号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次 ...
- ACDream:1210:Chinese Girls' Amusement【水题】
Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Oth ...
- 数学+高精度 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 ...
- 2016NEFU集训第n+5场 A - Chinese Girls' Amusement
Description You must have heard that the Chinese culture is quite different from that of Europ ...
- 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 ...
- zoj 2313 Chinese Girls' Amusement 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1313 题目意思:有 N 个人(编号依次为1~N)围成一个圆圈,要求求 ...
- SGU 193.Chinese Girls' Amusement
/* 实际上就是求一个k,满足k<=n/2,且gcd(n,k)=1 如果n为奇数,k为[n/2] 如果n为偶数,k=n/2-1-(n/2)%2 */ #include <iostream& ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
随机推荐
- python web框架的介绍
随着互联网的兴起,web开发变得愈发的重要.Python作为当前火热的语言, 其中的web开发框架可以说是百花齐放,下面聊一聊这些框架. 一: 基于Python的代表性Web框架 Django Dja ...
- 呕心沥血写的python猜数字
#猜数字 import random num_rd=random.randint(0,100) count=1 while 1<=count<=10: num_ip=input('请输入0 ...
- 基于HDP版本的YDB安装部署(转)
第三章 YDB依赖环境准备 一.硬件环境 硬件如何搭配,能做到比较高的性价比,不存在短板.合理的硬件搭配,对系统的稳定性也很关键. 1.CPU不是核数越高越好,性价比才是关键. 经常遇到很多的企业级客 ...
- Altium Designer之模块复用——设备图表符与Snippets
Altium Designer中的设备图表符(Device Sheet Symbol)和Snippets是设计中模块复用的利器,下面简单介绍下这个两个功能的使用. 一.设备图表符(Device She ...
- FCS校验 C语言简单实现
static uint8 calcFCS(uint8 *pBuf, uint8 len){ uint8 rtrn = 0; while (len--) { rtrn ^= *pBuf++; ...
- Javascript Step by Step - 03
前言 ajax 即“Asynchronous JavaScript and XML”(异步的JavaScript和XML).现在这个词的覆盖面有所扩展,把允许浏览器与服务器通信而无需刷新当前页面的技术 ...
- Result Maps collection does not contain value for XXXXX
在做mybatis多表查询的时候,出现了下面的错误: java.lang.IllegalArgumentException: Result Maps collection does not conta ...
- WPFDataGrid可以编辑某列Bug,困惑已久
这个问题困扰了好几天,最近在做DataGrid编辑列,有一个添加按钮,当我点击添加按钮的时候自动生成一行,并别生成序列号,然后按回车键完成添加,但是有一个问题就是:当我点击完添加按钮以后,然后继续添加 ...
- 《1024伐木累-周末特别篇》-中彩票了,开发APP
本周发布的<1024伐木累>,受到了很多码汪们的好评,博主在这里感谢大家的支持,同时,博主临时起意,增加一期周末对话特别篇,让大家在“满血复活”的时间里,充分感受快乐的味道~ 1.中彩票 ...
- DOS程序员手册(一)
当今MS-Windows横扫大江南北,让我们这就来研究一下它的祖宗——MS-DOS! 这本书很难得,希望读者好好学习! DOS程序员手册(一) DOS教程 (以下内容全部为原作者的阐述,照样保留) 这 ...