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 ...
随机推荐
- 虚拟机桥接模式下多台Ubuntu16.04系统互相连接
1.首先新建一个虚拟机并在该虚拟机上安装Ubuntu16.04系统.为这台虚拟机起名为Ubuntu3. 2.对Ubuntu3进行克隆,为新克隆生成的虚拟机起名为Ubuntu2.(这时我们会发现Ubun ...
- python flask豆瓣微信小程序案例
项目步骤 定义首页模板index.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- poj 1611 dsu
The Suspects Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 35918 Accepted: 17458 De ...
- 汉罗塔问题——Python
汉罗塔问题就是一个循环的过程:* (有两种情况) 如果被移动盘只有一个盘子,可以直接移动到目的盘 但是被移动盘有多个盘子,就先需要将上面的n-1个盘子通过目的盘移动到辅助盘,然后将被移动盘最下面一个盘 ...
- POJ:3684-Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...
- 17-比赛1 D - IPC Trainers (贪心 + 优先队列)
题目描述 本次印度编程训练营(Indian Programming Camp,IPC)共请到了 N 名教练.训练营的日程安排有 M 天,每天最多上一节课.第 i 名教练在第 Di 天到达,直到训练营结 ...
- 15 Django组件-中间件
中间件 中间件的概念 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨慎实用,用不好 ...
- 01,jupyter环境安装
jupyter notebook环境安装 一.什么是Jupyter Notebook? 1. 简介 Jupyter Notebook是基于网页的用于交互计算的应用程序.其可被应用于全过程计算:开发.文 ...
- Javascript Step by Step - 01
基本数据类型 简单数值类型: undefined, null, boolean, number和string,共有5种 复合数据类型:object,array,function typeof操作符用来 ...
- 1 Mongodb安装
1.NoSQL简介 NoSQL,全名Not Only SQL,指的是非关系型的数据库 随着访问量的上升,网站的数据库性能出现了问题,于是NoSQL被设计出来了 优点.缺点 优点 高扩展性 分布式计算 ...