/*
实际上就是求一个k,满足k<=n/2,且gcd(n,k)=1
如果n为奇数,k为[n/2]
如果n为偶数,k=n/2-1-(n/2)%2
*/
#include <iostream>
using namespace std;
string s;
void div2() {
string t;
int l = s.size() - 1, tem = s[0] - '0';
if (tem > 1) t += '0' + tem / 2;
tem &= 1;
for (int i = 1; i <= l; i++) {
tem = tem * 10 + s[i] - '0';
t += '0' + tem / 2;
tem &= 1;
}
s = t;
}
void cut1() {
int t = s.size() - 1;
while (s[t] == '0')
s[t--] = '9';
s[t] = s[t] - 1;
}
int main() {
cin >> s;
int l = s.size() - 1;
if ( (s[l] - '0') & 1) {
cut1(); div2();
cout << s;
}
else {
div2();
l = s.size() - 1;
if ( (s[l] - '0') & 1) cut1();
cut1();
cout << s;
}
return 0;
}

  

SGU 193.Chinese Girls' Amusement的更多相关文章

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

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

  2. Acdream Chinese Girls' Amusement

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

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

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

  4. ACDream:1210:Chinese Girls' Amusement【水题】

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

  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. acdream 1210 Chinese Girls' Amusement (打表找规律)

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

  8. zoj 2313 Chinese Girls' Amusement 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1313 题目意思:有 N 个人(编号依次为1~N)围成一个圆圈,要求求 ...

  9. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

随机推荐

  1. HDU-1035 Robot Motion

    http://acm.hdu.edu.cn/showproblem.php?pid=1035 Robot Motion Time Limit: 2000/1000 MS (Java/Others)   ...

  2. Linux学习笔记22——线程属性(转)

    本文来自博客园:http://www.cnblogs.com/yc_sunniwell/archive/2010/06/24/1764204.html 一.线程属性线程具有属性,用pthread_at ...

  3. Y86处理器的各个阶段

    0x00e:30f480000000        |              irmovl $128,%esp  实现所有Y86指令所需要的计算分为6个基本阶段:取值.译码.执行.访存.写回和更新 ...

  4. jQuery、实例大全

    文章出处 http://www.cnblogs.com/suoning/p/5683047.html 一.简介 定义 jQuery创始人是美国John Resig,是优秀的Javascript框架: ...

  5. 适配器模式 java

    结构模式:将类和对象结合在一起构成更大的结构,就像是搭积木. 1.适配器模式 源接口---适配器--目标接口 2.使用场景: 现在你有一个很古老的类,里面的一些方法很有用,你如何使用这些方法? 当然你 ...

  6. ANDROID Porting系列二、配置一个新产品

    ANDROID Porting系列二.配置一个新产品 详细说明 下面的步骤描述了如何配置新的移动设备和产品的makefile运行android. 1.         目录//vendor/创建一个公 ...

  7. linux-kernel/CodingStyle

    https://www.kernel.org/doc/Documentation/zh_CN/CodingStyle Chinese translated version of Documentati ...

  8. [置顶] Array ArrayList LinkList的区别剖析

    这是一个面试中我们经常被问到的问题 Array.ArrayList.LinkList之间的区别:Array.ArrayList.LinkList均属于泛型的范畴,都用来存放元素,主要区别是Array是 ...

  9. 如何将ER图转换成关系模式集

    在ER图中,主要是实体类型和联系类型. 1.实体类型的转换 (“——”表示对应关系) 实体类型——关系模式 实体的属性——关系模式的属性 实体标识符——关系模式的键 2.联系的转换 一元联系较简单,三 ...

  10. 使用jq工具在Shell命令行处理JSON数据

    由于近期要处理一些 JSON 数据格式.一大早经过一番搜索后,终于找到了 jq 这个非常棒的工具.jq 同意你直接在命令行下对 JSON 进行操作,包含分片.过滤.转换等等. 首先在mac下安装jq. ...