UVa133 - The Dole Queue
2017-02-19 00:54
323 查看
//UVa133 - The Dole Queue #include<cstdio> #define maxn 25 using namespace std; int n, k, m, a[maxn]; //p为初位置,逆时针走t步,d为-1时顺时针走,返回新位置 int go(int p, int d, int t){ while(t--){ do{ p = (p+d+n-1)%n+1; }while(a[p] == 0); } return p; } int main(){ while(scanf("%d%d%d", &n, &k, &m) == 3 && n){ for(int i = 1; i <= n; i++) a[i] = i; int left = n; int x = n, y = 1; while(left--){ x = go(x, 1, k); y = go(y, -1, m); printf("%3d", x); left--; if(y != x){ printf("%3d", y); left--;} a[x] = a[y] = 0; if(left) printf(","); } printf("\n"); } return 0; } /* 10 4 3 4 8, 9 5, 3 1, 2 6, 10, 7, */
相关文章推荐
- uva 133 The Dole Queue 双向约瑟夫环 模拟实现
- uva 133 - The Dole Queue
- UVA 133 - The Dole Queue
- UVA133 The Dole Queue
- UVA - 133 The Dole Queue(自顶向下 模拟)
- UVa 133 The Dole Queue 一些反思
- uva-133 - The Dole Queue
- 【模拟】【环形数组】-UVA-133- The Dole Queue
- 例题 4-3 救济金发放(The Dole Queue) UVa 133
- UVa 133 - The Dole Queue
- uva133--The Dole Queue
- UVA - 133 The Dole Queue
- The Dole Queue(子过程设计)(UVa 133)
- uva 133 The Dole Queue 双向约瑟夫环 模拟实现
- UVA 133 The Dole Queue
- UVa 133 - The Dole Queue 数据结构专题
- The Dole Queue UVA - 133
- UVA - 133 The Dole Queue 单纯模拟:1A
- uva133 The Dole Queue ( 约瑟夫环的模拟)
- Uva 133 - The Dole Queue