2 qq 37242775 qq_37242775 于 2017.01.03 20:17 提问

求北大ACM3428题题解!!!!!!!!!!!! 20C

#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
任意一题的题解就给悬赏!!谢谢各位大神。跪求!

2个回答

caozhy
caozhy   Ds   Rxr 2017.01.03 22:30
sinat_35134348
sinat_35134348   2017.01.04 11:01

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.

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!