求北大ACM3428题题解!!!!!!!!!!!!

#include

#include

#include

#include

using namespace std;

char format[50050], // format string

argument[1001][50050];

bool isDigit(char c)

{

return '0'<=c && c<='9';

}

bool judgeInt( char args[])

{

if(args[0]=='\0' || args[0]=='\n' )

return false;

for( int i=0;args[i] && args[i]!='\n' ;i++)

if( isDigit(args[i])==false) return false;

return true;

}

int calPara( char format[] )

{

int k = 0;

for( int i=0; format[i] && format[i]!='\n' ;i++){

if( format[i]=='%' ){

i++;

if( format[i]=='d' && judgeInt(argument[k])) k++;

else if( format[i]=='s' ) k++;

else if( format[i]=='%' ) continue;

else return -1;

}

}

return k;

}

void printInt(char args[])

{

int idx = 0;

while( args[idx]=='0' ) idx++;

if( args[idx]=='\n' || args[idx]=='\0' ){

putchar('0');

return ;

}

while( args[idx] && args[idx]!='\n' ) putchar(args[idx++]);

}

void printStr(char args[])

{

for( int i=0;args[i] && args[i]!='\n' ;i++)

putchar( args[i] );

}

void output(char format[],char args[][50050])

{

int k = 0;

for( int i=0; format[i] && format[i]!='\n' ;i++){

if( format[i]=='%' ){

i++;

if( format[i]=='d' ) printInt(argument[k++]);

else if( format[i]=='s' ) printStr(argument[k++]);

else if( format[i]=='%' ) putchar('%');

}

else putchar( format[i] );

}

}

int main(int argc, const char *argv[])

{

gets(format);

int nPara = 0;  
while(gets(argument[nPara]))  nPara++;  

if( calPara(format) != nPara )  printf("%s","ERROR");  
else    output(format,argument);      

return 0;  

}

要怎么输入才有输出。求

如果可以给出北大ACM
1076
1246
1372
1626
2016
2884
3289
3424
3428
3571
3575
3582
3583
3584
任意一题的题解就给悬赏!!谢谢各位大神。跪求!

http://blog.csdn.net/synapse7/article/details/9698173

Bessie is playing a card game with her N-1 (2 ≤ N ≤ 100) cow friends using a deck with K (N ≤ K ≤ 100,000; K is a multiple of N) cards. The deck contains M = K/N "good" cards and K-M "bad" cards. Bessie is the dealer and, naturally, wants to deal herself all of the "good" cards. She loves winning.

Her friends suspect that she will cheat, though, so they devise a dealing system in an attempt to prevent Bessie from cheating. They tell her to deal as follows:

  1. Start by dealing the card on the top of the deck to the cow to her right

  2. Every time she deals a card, she must place the next P (1 ≤ P ≤ 10) cards on the bottom of the deck; and

  3. Continue dealing in this manner to each player sequentially in a counterclockwise manner

Bessie, desperate to win, asks you to help her figure out where she should put the "good" cards so that she gets all of them. Notationally, the top card is card #1, next card is #2, and so on.