现在的位置: 首页 > 综合 > 正文

hdu 4841

2019年09月06日 ⁄ 综合 ⁄ 共 687字 ⁄ 字号 评论关闭
//坑爹的格式,PE了5次
//用vector模拟约瑟夫环,基本没算法

#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
using namespace std;
bool ans[70000];
int main()
{
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
	int n,step,i,m,zz,th=1;
	while(~scanf("%d%d",&n,&step))
	{
		vector<int> v;
		m=2*n;
		for(i=1;i<=m;i++)
		{
			v.push_back(i);
			ans[i]=false;
		}
		zz=1; 
		while( m>n )
		{
			zz+=(step-1);
			if( zz<=m )
			{
				ans[ v[zz-1] ]=true;
				v.erase(v.begin()+zz-1);
				zz=(zz==m?1:zz);
			}
			else
			{
				zz%=m;
				zz=(zz==0?m:zz);
				ans[ v[zz-1] ]=true;
				v.erase(v.begin()+zz-1);
				zz=(zz==m?1:zz);
			}
			m--;
		}
		for(i=1;i<=2*n;i++)
		{
			if( ans[i] )
				printf("B");
			else
				printf("G");
			if( i%50==0 ) printf("\n");
 		}
 		if( (2*n)%50!=0 ) printf("\n");
 		printf("\n");
	}
    return 0;
}

【上篇】
【下篇】

抱歉!评论已关闭.