博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 1452 Jump 约瑟夫环
阅读量:6709 次
发布时间:2019-06-25

本文共 1250 字,大约阅读时间需要 4 分钟。

分用三次约瑟夫环数学方法就行了。具体见

//#pragma comment(linker, "/STACK:1024000000,1024000000")#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;typedef pair
pii;#define pb(a) push_back(a)#define INF 0x1f1f1f1f#define lson idx<<1,l,mid#define rson idx<<1|1,mid+1,r#define PI 3.1415926535898template
T min(const T& a,const T& b,const T& c){ return min(min(a,b),min(a,c));}template
T max(const T& a,const T& b,const T& c){ return max(max(a,b),max(a,c));}void debug(){#ifdef ONLINE_JUDGE#else freopen("d:\\in.txt","r",stdin); freopen("d:\\out1.txt","w",stdout);#endif}char getch(){ char ch; while((ch=getchar())!=EOF) { if(ch!=' '&&ch!='\n')return ch; } return EOF;}int main(){ int t; scanf("%d",&t); for(int ca=1;ca<=t;ca++){ int n,k; scanf("%d%d",&n,&k); int x; x=(k+2)%3; for(int i=4;i<=n;i++) x=(x+k)%i; printf("%d ",x+1); x=(k+1)%2; for(int i=3;i<=n;i++) x=(x+k)%i; printf("%d ",x+1); x=0; for(int i=2;i<=n;i++) x=(x+k)%i; printf("%d\n",x+1); } return 0;}
View Code

 

转载于:https://www.cnblogs.com/BMan/p/3264283.html

你可能感兴趣的文章
Centos 7下如何安装bzip2
查看>>
centos x64搭建 hadoop2.4.1 HA
查看>>
Android第四天
查看>>
ListView的缓存数据复用导致的显示错乱问题
查看>>
让Rails程序出现异常错误等自动发送错误邮件 - exception_notification
查看>>
java代码操作properties属性文件
查看>>
linux账号群组删除等相关操作
查看>>
Scala avoid null
查看>>
oracle性能优化学习062201
查看>>
Python小练习之使用for循环对列表内元素进行排序
查看>>
Java基础学习总结(8)——super关键字
查看>>
Maven学习总结(七)——eclipse中使用Maven创建Web项目
查看>>
Node.js中实现文件的循环写入
查看>>
大型网站技术架构(七)网站的可扩展性架构
查看>>
处理 ps cs3 打开提示 产品已停止 故障
查看>>
2015年终总结
查看>>
RSync实现文件备份同步
查看>>
linux系统定时任务
查看>>
js数组的操作 和 数组对象的3个属性
查看>>
POJ 1603: Risk
查看>>