📄 2937.txt
字号:
Problem Id:2937 User Id:fzk
Memory:48K Time:62MS
Language:C++ Result:Accepted
Source
#include <algorithm>
#include <cstdio>
#include <string.h>
#include <map>
#include <stack>
#include <memory.h>
#include <math.h>
#include <queue>
using namespace std;
int main( ) {
int n, pos, t, s;
char c[2];
while( 1 ) {
scanf( "%d", &n );
if( n == 0 )
break;
pos=0, s=1;
while( 1 ) {
if( scanf( "%1s", c ) != 1 )
break;
if( strchr( "0123456789", c[0] ) ) {
ungetc( c[0], stdin );
break;
}
scanf( "%d", &t );
if( c[0] == 'm' ) {
if( t&1 )
pos = (n-pos)%n, s=-s;
}
else
pos = (pos + t)%n;
}
if( pos == 0 && s == 1 )
printf( "\n" );
else if( pos == 0 )
printf( "m1\n" );
else if( s < 0 ) {
if( n-pos +1 < 1 + pos )
printf( "r%d m1\n", n-pos );
else
printf( "m1 r%d\n", pos );
}else {
if( pos < 2 + n-pos )
printf( "r%d\n", pos );
else
printf( "%m1 r%d m1\n", n-pos );
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -