The Dole Queue】的更多相关文章

The Dole Queue 题解: 这里写一个走多少步,返回位置的函数真的很重要,并且,把顺时针和逆时针写到了一起,也真的很厉害,需要学习 代码: #include<stdio.h> #define maxn 25 int n, k, m, a[maxn]; int go(int p,int d,int t) { while(t--){ do{p=(p+d-1+n)%n+1;}while(a[p]==0); } return p; } int main() { while(scanf(&qu…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=69 13874119 133 The Dole Queue Accepted C++ 0.009 2014-07-13 02:44:49  The Dole Queue  In a serious attempt to downsize (reduce) the dole queue…
The Dole Queue Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit cid=1036#status//A/0" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="font-family:Verdana,Arial,sans…
题目链接: 啊哈哈,选我选我 思路是: 相当于模拟约瑟夫环,仅仅只是是从顺逆时针同一时候进行的,然后就是顺逆时针走能够编写一个函数,仅仅只是是走的方向的标志变量相反..还有就是为了(pos+flag+n-1)%n+1的妙用... 题目:  The Dole Queue  In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decid…
The Dole Queue Time limit 3000 ms Description In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every day all dole applicants will be placed in a large circ…
 In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every day all dole applicants will be placed in a large circle, facing inwards. Someone is arbitrarily ch…
类型:循环走步 #include <iostream> #include <sstream> #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <vector> #include <set> #include <cctype> #include <algorithm> #inc…
题意:一个长度为N的循环队列,一个人从1号开始逆时针开始数数,第K个出列,一个人从第N个人开始顺时针数数,第M个出列,选到的两个人要同时出列(以不影响另一个人数数),选到同一个人就那个人出列. 思路:用数组来操作,详情见代码吧. #include <iostream> #include <stdio.h> #include <string> /* 用数组存储序号,从左到右依次为1~n. 逆时针相当于从左往右依次数,大于n再从1开始,用right作为指针. 顺时针相当于从…
双向约瑟夫环. 数据规模只有20,模拟掉了.(其实公式我还是不太会推,有空得看看) 值得注意的是两个方向找值不是找到一个去掉一个,而是找到后同时去掉. 还有输出也很坑爹! 在这里不得不抱怨下Uva的oj,少了个s,少了个空行什么的都不会显示pe,就给个wa,让人还以为算法有问题.原本以为Uva没有pe,然后据说这边的输出空行如果不对的话就会显示pe... 代码: #include <cstdio> #include <cstring> const int maxn = 22; in…
题意:约瑟夫问题,从两头双向删人.N个人逆时针1~N,从1开始逆时针每数k个人出列,同时从n开始顺时针每数m个人出列.若数到同一个人,则只有一个人出列.输出每次出列的人,用逗号可开每次的数据. 题解:模拟. 技巧:将顺时针逆时针的模拟合并为同一个函数. p1 = go(p1, 1, k);p2 = go(p2, -1, m); 循环处理: do p = (p + d + n - 1) % n + 1; while (a[p] == 0); (int p1 = n, p2 = 1;) 别忘了 a[…