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>
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的更多相关文章
- 数学+高精度 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 ...
- 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 ...
- acdream 1210 Chinese Girls' Amusement (打表找规律)
题意:有n个女孩围成一个圈从第1号女孩开始有一个球,可以往编号大的抛去(像传绣球一样绕着环来传),每次必须抛给左边第k个人,比如1号会抛给1+k号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次 ...
- zoj 2313 Chinese Girls' Amusement 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1313 题目意思:有 N 个人(编号依次为1~N)围成一个圆圈,要求求 ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
随机推荐
- 在C#中使用WIA获取扫描仪数据(利用Filter处理图片)
WIA Automation Layer不仅能从设备中捕获照片,还能进行简单的处理.当WIA Automation Layer从设备中捕获照片,保存为一个ImageFile对象,我们可以通过访问该Im ...
- 待解决)leetcode 路径和 dfs 线序遍历
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...
- 在Ant Build文件中使用正则表达式替换文件内容
这需要在build文件中使用<replaceregexp>标签, 这个标签的使用大概是这个样子的: <replaceregexp file="${src}/build.pr ...
- TC358746AXBG/748XBG 桥接器说明
为什么需要这个mipi csi-2 bridge 芯片,由于我们用的sensor 芯片是美光的MT9m021,这颗芯片并不支持MIPI 下面是网上摘录的说明可能解释这个问题: Because of t ...
- php 下载
$file='url.xlsx'; if (file_exists(EA_DIR_DATA . $file)) { header('Content-Description: Fi ...
- jsp文件中的alert等等
<script type="text/javascript"> alert("aa: ${message}") </script>
- Scrapinghub | Professional Services
VShell破解版 VShell破解版 Scrapinghub | Professional Services OUR PROFESSIONAL SERVICES INCLUDE
- hdoj 3746 Cyclic Nacklace【KMP求在结尾加上多少个字符可以使字符串至少有两次循环】
Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- bzoj2822: [AHOI2012]树屋阶梯
咦,这里有好多东西https://en.wikipedia.org/wiki/Catalan_number 每个矩形最多贡献一个拐角 枚举左上角的点和那个拐角是一个矩形 #include<cst ...
- WPF的进度条progressbar,运行时间elapse time和等待spinner的实现
今天用.NET 4.5中的TPL的特性做了个小例子,实现了WPF的进度条progressbar,运行时间elapse time和等待spinner. 先上图吧. 这个例子包含4个实现,分别是同步版 ...