poj3750

简单题

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

#define maxn 100

int n, w, s;
char name[maxn][100];
bool out[maxn];

int main()
{
//freopen("t.txt", "r", stdin);
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf(
"%s", name[i]);
scanf(
"%d,%d", &w, &s);
memset(
out, 0, sizeof(out));
int pos = w - 1;
for (int i = n; i > 0; i--)
{
int x = s % (i + 1);
while (out[pos % n])
pos
++;
for (int j = 0; j < x; j++)
{
while (out[pos % n])
pos
++;
if (j == x - 1)
break;
pos
++;
}
out[pos % n] = true;
printf(
"%s\n", name[pos % n]);
pos
%= n;
}
return 0;
}

posted @ 2011-07-10 16:23  金海峰  阅读(259)  评论(0编辑  收藏  举报