51Nod-1074-约瑟夫环 V2
来源:互联网 发布:双人自行车价格淘宝网 编辑:程序博客网 时间:2024/05/22 17:23
ACM模版
描述
题解
约瑟夫环问题在《具体数学》一书上讲得十分详细,这里我们用函数法来解它,模板题。
代码
#include <iostream>using namespace std;unsigned long long n, k;int main(){ cin >> n >> k; long long y = k % 2; long long x = 2, t = 0; long long z1 = y, z2 = x; while (x <= n) { z1 = y; z2 = x; t = (x - y) / (k - 1); if (t == 0) { t++; } y = y + t * k - ((y + t * k) / (x + t)) * (x + t); x += t; } cout << (z1 + (n - z2) * k) % n + 1 << endl; return 0;}
阅读全文
0 0
- 51nod 1074 约瑟夫环V2
- 51Nod-1074-约瑟夫环 V2
- 51nod 1074 约瑟夫环 V2
- 约瑟夫问题 51nod 1073 约瑟夫环
- 【51Nod1074】约瑟夫环 V2
- 51nod 1073 约瑟夫环
- 51nod-1073约瑟夫环
- 51nod 1073 约瑟夫环
- 51nod 1073 约瑟夫环
- 51nod 1073 约瑟夫环
- 51nod 5173 约瑟夫环
- 51NOD 1073 约瑟夫环
- 51Nod 1073 约瑟夫环
- 51 nod 1073 约瑟夫环
- 51Nod-1073-约瑟夫环
- 51nod 1073 约瑟夫环
- 51Nod 1073 约瑟夫环
- 51Nod-1073 约瑟夫环
- cad下载2010免费中文版的操作和方法
- Opencv cv::resize ZoomIn ZoomOut
- msm8937 SDP plugin and plugout log
- 如何使用EF优雅的配置一对一的关系
- BigDecimal如何比较大小
- 51Nod-1074-约瑟夫环 V2
- OPNET网络仿真分析-1.1.2、OPNET简介
- 糊涂窗口综合症和Nagle算法
- 基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构
- 深入解析String中的intern
- android studio 单步调试
- Linux下的crontab定时执行任务命令详解
- Vi命令总结
- Windows系统下配置gradle的环境变量的简单方式