2016山东省第七届ACM省赛-部分题解

sdut-3560-julyed:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3560.html

Julyed

Problem Description

    Julyed is preparing for her CET-6. She has N words to remember, but there is only M days left. If she can’t remember all these words, she won’t pass CET-6. If she can’t pass CET-6, she will be unhappy. But if she remember too many words in one day, she will be unhappy, too. If she is unhappy, tomriddly will be unhappy. So she will remember as little words as she can in one day. For the happiness of both tomriddly and Julyed, how many words at most will Julyed remember in one day?

Input

 Multiple test cases. The first line is an integer T (T <= 10000), indicating the number of test cases.

Each test case is a line with two integers N, M (1 <= N, M <= 200), indicating the number of words to remember and the number of days left.

Output

 One line per case, an integer indicates the answer.

Example Input

5
6 3
2 1
1 2
5 2
4 3

Example Output

2
2
1
3
2

题解:水题
题目大意:小明一天背m个单词,一共n个单词,最少需要几天背完。
 
   
#include 
#include 

using namespace std;

int main()
{
    int t;
    int n,m;
    while(cin>>t)
    {
        while(t--)
        {
            cin>>n>>m;
            if(m>=n)cout<<"1"<


sdut-3561-Fibonacci
:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3561.html

 Fibonacci

Problem Description

Fibonacci numbers are well-known as follow:

 

Now given an integer N, please find out whether N can be represented as the sum of several Fibonacci numbers in such a way that the sum does not include any two consecutive Fibonacci numbers.

Input

Multiple test cases, the first line is an integer T (T<=10000), indicating the number of test cases.

Each test case is a line with an integer N (1<=N<=109).

Output

One line per case. If the answer don’t exist, output “-1” (without quotes). Otherwise, your answer should be formatted as “N=f1+f2+…+fn”. N indicates the given number and f1, f2, … , fn indicating the Fibonacci numbers in ascending order. If there are multiple ways, you can output any of them.

Example Input

4
5
6
7
100

Example Output

5=5
6=1+5
7=2+5
100=3+8+89

题目大意:给一个数n,判断能否由斐波那契数组成n。

题解:思维题,打表找规律,斐波那契的变形

通过打表找出所有的斐波那契数。可以看出,对于每一个n都可以有斐波那契数组成,找到一个小于n的最大的斐波那契数x,让n减去x,直到n==0.。这个题在比赛的时候也打表了,但是没有找出规律来,最近又翻出来做一做,还是看了大牛的解析才知道的,至于怎么证明只这样的规律自己还是无从知晓的。通过这个题,自己知道罪域一些题还是要大胆的才结论的。

#include 
#include 

using namespace std;

int f[50];
int a[50];

int main()
{
    f[1]=1;
    f[2]=2;
    const int m=45;
    for(int i=3;i<=m;i++)
    {
        f[i]=f[i-1]+f[i-2];
    }
    int t,n,k;
    cin>>t;
    while(t--)
    {
        cin>>n;
        k=n;
        int top=0;
        for(int i=m;i>=1;i--)
        {
            if(f[i]<=n)
            {
                a[top++]=f[i];
                n=n-f[i];
            }
        }
        if(n==0)
        {
            cout<=0;i--)
            {
                if(i==top-1)cout<

sdut-3562-proxy:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3562.html

Problem Description

Because of the GFW (Great Firewall), we cannot directly visit many websites, such as Facebook, Twitter, YouTube, etc. But with the help of proxy and proxy server, we can easily get to these website.
    You have a list of several proxy servers, some of them can be connected directly but others can’t. But you can visit proxy servers through other proxy server by a one-way connection. 
    As we all know, the lag of internet visit will decide our feelings of the visit. You have a very smart proxy software which will find the least lag way to reach the website once you choose a directly reachable proxy server. 
    You know the lag of every connection. The lag of your visit is the all the lags in your whole connection. You want to minimize the lag of visit, which proxy server you will choose?

Input

    Multiple test cases, the first line is an integer T (T <= 100), indicating the number of test cases.
The first line of each test case is two integers N (0 <= N <= 1000), M (0 <= M <= 20000). N is the number of proxy servers (labeled from 1 to N). 
0 is the label of your computer and (N+1) is the label of the server of target website.
Then M lines follows, each line contains three integers u, v, w (0 <= u, v <= N + 1, 1 <= w <= 1000), means u can directly connect to v and the lag is w.

Output

    An integer in one line for each test case, which proxy server you will choose to connect directly. You can only choose the proxy server which can be connected directly from your computer.
If there are multiple choices, you should output the proxy server with the least label. If you can’t visit the target website by any means, output “-1” (without quotes). If you can directly visit the website and the lag is the least, output “0” (without quotes).

Example Input

4
3 6
0 1 10
1 2 1
2 4 4
0 3 2
3 2 1
3 4 7
2 4
0 2 10
0 1 5
1 2 4
2 1 7
1 3
0 2 1
0 1 2
1 2 1
1 3
0 2 10
0 1 2
1 2 1

Example Output

3
-1
0
1

题目大意:服务器的使用,有一台电脑0,想访问n这台电脑,但是有可能不能直接访问,需要间接的服务器,但是间接的服务器需要费用。那么问题来了,从0到n需要的最小花费是多少呢?输出最小花费的那条路径的和0相连的编号最小的那个点。如果最小的花费的路径时直接从0到n的话就输出0.

题解:两个条件的最短路问题

直接套用最短路的知识加上另一个条件就行,那么另一个条件怎么加的?先说另一个条件是当前点来自于哪一个和0相连的点。如果路径费用相同的话,当前点就赋值为和0肚的小的编号。(原谅我的口齿不清,自己的解释越描越黑了,尴尬,结合代码看看吧)

#include 
#include 
#define INF 0x3f3f3f3f

using namespace std;

int mp[1005][1005];
int dist[1005],vis[1005],pos[1005];
void spfa(int s,int e)
{
    for(int i=s; i<=e; i++)
    {
        dist[i]=INF;
        vis[i]=0;
    }
    queueq;
    while(!q.empty())q.pop();
    dist[s]=0;
    vis[s]=1;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=s; i<=e; i++)
        {
            if(mp[u][i]dist[u]+mp[u][i])
                {
                    dist[i]=dist[u]+mp[u][i];
                    if(u!=s)pos[i]=pos[u];
                    if(!vis[i])
                    {
                        vis[i]=1;
                        q.push(i);
                    }
                }
                else if(dist[i]==dist[u]+mp[u][i]&&u!=s)
                {
                    if(pos[i]>pos[u])
                    {
                        pos[i]=pos[u];
//                        if(!vis[i])
//                        {
//                            vis[i]=1;
//                            q.push(i);
//                        }
                    }
                }
            }
        }
    }
    if(dist[e]

sdut-3563-Swiss-system tournament:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3563.html

Problem Description

A Swiss-system tournament is a tournament which uses a non-elimination format. The first tournament of this type was a chess tournament in Zurich in 1895, hence the name "Swiss system". The tournament will be held based on following rules.

    2*N contestants (indexed 1, 2, ..., 2*N) will have R rounds matches. Before the first round, every contestant has an origin score. After every match, winner will get 1 score and loser will get 0 score. Before and after every round, contestants will be sorted by their scores in descending order. Two contestants with the same score will be sorted by their index with ascending order.

    In every round, contestants will have match based on the sorted list. The first place versus the second place, the third place versus the forth place, ..., the Kth place versus the (K + 1)th place, ..., the (2*N - 1)th place versus (2*N)th place.

   Now given the origin score and the ability of every contestant, we want to know the index of the Qth place contestant. We ensured that there won’t be two contestants with the same ability and the contestant with higher ability will always win the match.

Input

 Multiple test cases. The first line contains a positive integer T (T<=10) indicating the number of test cases.

For each test case, the first line contains three positive integers N (N <= 100,000), R (R <= 50), Q (Q <= 2*N), separated by space.

The second line contains 2*N non-negative integers, s1, s2, ..., s2*N, si (si<= 108) indicates the origin score of constant indexed i.

The third line contains 2*N positive integers, a1, a2, ..., a2*N, ai (ai<= 108) indicates the ability of constant indexed i.

Output

 One line per case, an integer indicates the index of the Qth place contestant after R round matches.

Example Input

1
2 4 2
7 6 6 7
10 5 20 15

Example Output

1

题目大意:题意很简单,就是有n个人,每个人有能力值和分数值,每次根据分数值从小到大排序,然后0和1战斗,2和3战斗,,,,,以此类推。战斗时能力值大的一方获胜,获胜的一方加1分,输的一方加0分。然后在排序,重复上述。进行r轮。求最后的排序中第Q大的人的编号。

题解:归并排序。

这个题都死在TLE上了,毕竟考察的就是归并。那么为什么是归并呢。先进行sort一遍后就是有序的了,然后赢得一方+1,放到一个数组中;输的一方+0放到一个数组中,此时这两个数组都是有序的,很显然的这是。然后进行归并一次仍然有序。时间大大缩减了。

#include 
#include 

using namespace std;

struct node
{
    int id;
    int ab;
    int so;
} s[200200],a[200200],b[200200];
bool cmp(node x,node y)
{
    if(x.so!=y.so)return x.so>y.so;
    return x.ids[i+1].ab)
                {
                    s[i].so++;
                    a[aa++]=s[i];
                    b[bb++]=s[i+1];
                }
                else
                {
                    s[i+1].so++;
                    a[aa++]=s[i+1];
                    b[bb++]=s[i];
                }
            }
            int i,j;
            i=j=0;
            while(ib[j].so)
                {
                    s[ss++]=a[i];
                    i++;
                }
                else if(a[i].so==b[j].so)
                {
                    if(a[i].id

sdut-3564

The Binding of Isaac

Problem Description

Ok, now I will introduce this game to you...

Isaac is trapped in a maze which has many common rooms…

Like this…There are 9 common rooms on the map.

And there is only one super-secret room. We can’t see it on the map. The super-secret room always has many special items in it. Isaac wants to find it but he doesn’t know where it is.Bob 
tells him that the super-secret room is located in an empty place which is adjacent to only one common rooms. 
Two rooms are called adjacent only if they share an edge. But there will be many possible places.

Now Isaac wants you to help him to find how many places may be the super-secret room.

Input

Multiple test cases. The first line contains an integer T (T<=3000), indicating the number of test case.
Each test case begins with a line containing two integers N and M (N<=100, M<=100) indicating the number
of rows and columns. N lines follow, “#” represent a common room. “.” represent an empty place.
Common rooms 
maybe not connect. Don’t worry, Isaac can teleport.

Output

 One line per case. The number of places which may be the super-secret room.

Example Input

2
5 3
..#
.##
##.
.##
##.
1 1
#

Example Output

8
4
题解:水题
#include 
#include 
#define INF 0x3f3f3f3f

using namespace std;

char mp[105][105];

int main()
{
    int t;
    int n,m;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(int i=0;i=0&&mp[i-1][j]=='#')num++;
                    if(i+1=0&&mp[i][j-1]=='#')num++;
                    if(j+1

sdut-3565

Feed the monkey

Problem Description

Alice has a monkey, she must feed fruit to the monkey every day.She has three kinds of fruits, bananas, 
peaches and apples. Every day, she chooses one in three, and pick one of this to feed the monkey. 
But the monkey is picky, it doesn’t want bananas for more than D1 consecutive days, peaches for more than D2 
consecutive days, or apples for more than D3 consecutive days. Now Alice has N1 bananas, N2 peaches and N3 
apples, please help her calculate the number of schemes to feed the monkey.

Input

 Multiple test cases. The first line contains an integer T (T<=20), indicating the number of test case.
Each test case is a line containing 6 integers N1, N2, N3, D1, D2, D3 (N1, N2, N3, D1, D2, D3<=50).

Output

 One line per case. The number of schemes to feed the monkey during (N1+N2+N3) days.
The answer is too large so you should mod 1000000007.

Example Input

1
2 1 1 1 1 1

Example Output

6

Hint

 Answers are BPBA, BPAB, BABP, BAPB, PBAB, and ABPB(B-banana P-peach A-apple)

题目大意:有一个猴子,每天要吃一个苹果或者梨子或者香蕉,但是对于每种水果都有连续吃它的限制,比如有n1个苹果,不能连续d1天都吃苹果。然后给出三种水果的数量和连续吃的限制天数。求有多少种给猴子吃水果的方案。
题解:dp
ps:看这个dp也是看的比较费劲,以前在hiho上做过种连续数量的限制求方案数的dp题。可以说是一类的dp题吧。总算是在遇到这种题能知道怎么去想吧。
令dp[a][b][c][k]表示苹果剩余a个,梨子剩余b个,香蕉剩余c个,以第k种水果结尾时的方案数。
那么当定住a,b,c时,遍历min(di,a||b||c),先让一种水果连续放j个,(拿苹果来举例)那么就是dp[a-j][b][c][苹果]+=dp[a][b][c][梨子]+dp[a][b][c][香蕉],最后计算dp[0][0][0][苹果]+ dp[0][0][0][梨子]+dp[0][0][0][香蕉]就可以了。(表示都剩余0时以不同水果结尾时的方案数)
#include 
#include 
#define MOD 1000000007
using namespace std;

long long dp[55][55][55][5];
int main()
{
    int t;
    int n1,n2,n3,d1,d2,d3;
    scanf("%d",&t);
    while(t--)
    {
        memset(dp,0,sizeof(dp));
        scanf("%d%d%d%d%d%d",&n1,&n2,&n3,&d1,&d2,&d3);
        for(int i=n1;i>=0;i--)
        {
            for(int j=n2;j>=0;j--)
            {
                for(int k=n3;k>=0;k--)
                {
                    for(int s=1;s<=min(i,d1);s++)
                    {
                        if(i==n1&&j==n2&&k==n3)
                        {
                            dp[i-s][j][k][0]=(dp[i][j][k][0]+1)%MOD;
                        }
                        else
                        {
                            dp[i-s][j][k][0]=((dp[i-s][j][k][0]+dp[i][j][k][1])%MOD+(dp[i][j][k][2]))%MOD;
                        }
                    }
                    for(int s=1;s<=min(j,d2);s++)
                    {
                        if(i==n1&&j==n2&&k==n3)
                        {
                            dp[i][j-s][k][1]=(dp[i][j][k][1]+1)%MOD;
                        }
                        else
                        {
                            dp[i][j-s][k][1]=((dp[i][j-s][k][1]+dp[i][j][k][0])%MOD+(dp[i][j][k][2]))%MOD;
                        }
                    }
                    for(int s=1;s<=min(k,d3);s++)
                    {
                        if(i==n1&&j==n2&&k==n3)
                        {
                            dp[i][j][k-s][2]=(dp[i][j][k][2]+1)%MOD;
                        }
                        else
                        {
                            dp[i][j][k-s][2]=((dp[i][j][k-s][2]+dp[i][j][k][0])%MOD+(dp[i][j][k][1]))%MOD;
                        }
                    }
                }
            }
        }
        long long ans=((dp[0][0][0][0]+dp[0][0][0][1])%MOD+dp[0][0][0][2])%MOD;
        printf("%lld\n",ans);
    }
    return 0;
}
///关于组合数的连续放与不放问题的DP,也是比较经典的DP了
///主要在于找他的状态,对某一物件物品在条件下进行连续放

sdut-3566

Triple Nim


Problem Description

Alice and Bob are always playing all kinds of Nim games and Alice always goes first. Here is the rule of Nim game:

    There are some distinct heaps of stones. On each turn, two players should remove at least one stone from just one heap. Two player will remove stone one after another. The player who remove the last stone of the last heap will win.

    Alice always wins and Bob is very unhappy. So he decides to make a game which Alice will never win. He begins a game called “Triple Nim”, which is the Nim game with three heaps of stones. He’s good at Nim game but bad as math. With exactly N stones, how many ways can he finish his target? Both Alice and Bob will play optimally.

Input

 Multiple test cases. The first line contains an integer T (T <= 100000), indicating the number of test case. Each case contains one line, an integer N (3 <= N <= 1000000000) indicating the number of stones Bob have.

Output

 One line per case. The number of ways Bob can make Alice never win.

Example Input

3
3
6
14

Example Output

0
1
4
题解:(这个自己反正想不出来,对于二进制几乎不怎么敏感,自己只想到了NIM游戏的方法。转一下他人的解释吧)

题意,就是有一堆石子,一共有n个,把n个石子分成三堆,求有多少种分配的方式能够使得bob win?

很容易就能够明白题目是让干什么的,这道题目就是一道尼姆博弈的题目,先来讲下尼姆博弈,其实很简单,有n堆石子,如果n堆石子的异或和是0,则先手必败,否则先手胜。尼姆博弈是利用二进制的思想,那么本题也可以利用二进制的思想,可知,如果要使得Alice输并且Alice为先手,只需要使得三堆石子异或等于0 即可,首先共有n个石子,把n转化成二进制来表示,假设其中有k个1存在,如果要使得三堆石子异或为0,则在三堆石子数的二进制数的每位上1的个数都要是偶数位,又可知,在二进制中,高位的1是由低位进位而得到的,也就是说高位的1可以分解成两个低位的1,当n是奇数的时候,最低位为1且没有办法分解,所以输出0,所以当n为偶数的时候,就有(3^k - 3)/6个,减去3是去掉一个为0的情况,除6是应为本题求得是排列。。。

#include 
#include 

using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long n;
        cin>>n;
        if(n%2)cout<<"0"<

sdut-3567

Memory Leak

Problem Description

Memory Leak is a well-known kind of bug in C/C++. When a string is longer than expected, it will visit the memory of next array which will cause the issue and leak some information. You can see a simple example bellow:

As we see, if the length of the input string is equal to or larger than the limit length of array, the extra part won’t be stored and the information of next array will be leaked out while outputting. The output will stop until a ‘\0’ character (the symbol of end of a string) is found. In this problem, there will never be unexpected end of the program and the last array won’t leak other information.

Source code given as follow:

Now a simpler source code will be given. What will the output be?

Input

 Multiple test cases, the first line is an integer T (T <= 20), indicating the number of test cases.

The first line of each test case contains a non-empty string, the definition of strings, formatted as “char s1[s1_len], s2[s2_len]...;”. “char ” is the type of the array which will never change. s1, s2... is the name of the array. s1_len, s2_len... is the length limit. If nothing goes wrong, the array should be able to store the input string and a ‘\0’. The definitions of different arrays will be separated by a comma and a space. The length limits are positive and the Sum of length limit will be less than 10000.

Then, there will be several lines of string which consists two or three parts.

The first part is “gets” or “cout”, the second part will a string s, indicates the name of the array. s will contains only lower case letters and number digits and start with letters. s will be different in one case. If the first part is “gets”, then there will be the third part, a string which should be input into array s, the length of input string will be less than 1000 and contains only visible ASCII characters. “gets” operation will rewrite the array no matter what was in the array before and add a ‘\0’ after the string. Different parts are separated by a space.

Case ends with “return 0;”

The whole input file is less than 10MB.

Output

 For each “cout”, you should output a line contains what will actually output, which means you should consider the issue of memory leak. If the requested array is empty, you should output an empty line.

Example Input

3char a[5], b[5], c[5];gets a C++gets b Hello, world!gets c guyscout acout bcout creturn 0;char a[5];cout agets a 233gets a 2333cout agets a 12345cout areturn 0;char str1[7], str2[2], str3[5];gets str1 welcomegets str2 togets str3 Shandongcout str1return 0;

Example Output

C++Helloguysguys233312345welcometoShand

Hint

 题目大意:按照图片上说的模拟就行了。
题解:模拟
#include

using namespace std;

struct node
{
    int l,r;
}q[100005];
char s[100005];
char ch[100005];
char name[100005][1000];

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(s,0,sizeof(s));
        int num=0;
        int pos=0;
        scanf("%s",ch);
        while(1)
        {
            scanf("%s",ch);
            int len=strlen(ch);
            int i;
            for(i=0;i
sdut-3569

Execution of Paladin

Problem Description

Murloc is a powerful race in Hearthstone. In the set League of Explorers, a new Paladin ability card called Anyfin Can Happen is released with the ability to summon 7 Murlocs that died this game. If there aren’t enough dead Murlocs, it may summon less than 7 Murlocs.
        

There are many different minions in Murloc race, here are four of them:

Coldlight Oracle: 3 MANA, 2 ATTACK, 2 HP. Battlecry: Each player draws 2 cards.

Murloc Warleader: 3 MANA, 3 ATTACK, 3 HP. ALL other Murlocs have +2/+1.

Bluegill Warrior: 2 MANA, 2 ATTACK, 3 HP. Charge.

Old Murk-Eye: 4 MANA, 2 ATTACK, 3 HP. Charge. Has +1 Attack for each other Murloc on the Battlefield.


Here are some explanations:

MANA: The cost of summon the minion. Minions summoned by ability cards cost no mana besides the cost of the ability cards. Every player has 10 MANAs at most.

ATTACK: How many damage can the minion make once.

HP: How many attacks can the minion or heroes take.

Battlecry: An ability where a particular effect activates when the card with the Battlecry is played directly from the hand. The minions summoned by ability won’t activate their Battlecry.

Charge: Minions cannot attack at once when they are summoned unless they have Charge description. They will have to wait until next turn.

Battlefield: The battlefield (or game board) is where the action takes place, representing the board on which each game is played out.

+2/+1: +2 ATTACK and +1 HP.

Now, it is your turn. You have 10 MANAs and only one card: Anyfin Can Happen. There are nothing on the Battlefield, which means your minions can directly attack enemy hero. You can remember the list of dead Murlocs. You know how many HP the enemy hero remains. Will you win this game through this only card you have?

Input

 Multiple test cases. The first line contains an integer T (T<= 22000), indicating the number of test case.

The first line of each test contains two integers, n (the number of dead Murlocs, 0 <= n <= 7) and h (the HP of enemy hero, 0 < h <= 30).

Then n lines follows, each line contains a string, indicates the name of dead Murloc. The string will only be “Coldlight Oracle”, “Murloc Warleader”, “Bluegill Warrior” or “Old Murk-Eye”.

Output

 One line per case. If you can win the game in this turn, output “Mrghllghghllghg!”(Without quotes). Otherwise, output “Tell you a joke, the execution of Paladin.” You will win the game if you attack enemy hero with your minions and make his/her HP less or equal than 0.

Example Input

33 1Coldlight OracleColdlight OracleMurloc Warleader3 8Old Murk-EyeOld Murk-EyeColdlight Oracle7 30Old Murk-EyeBluegill WarriorBluegill WarriorMurloc WarleaderMurloc WarleaderColdlight OracleColdlight Oracle

Example Output

Tell you a joke, the execution of Paladin.Mrghllghghllghg!Tell you a joke, the execution of Paladin.
题解:根据炉石的玩法求解就行了。
#include 
#include 

using namespace std;

char s[111];

int main()
{
    int t,n,m;
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        getchar();
        int O,W,B;
        O=W=B=0;
        for(int i=0;i=m)printf("Mrghllghghllghg!\n");
        else printf("Tell you a joke, the execution of Paladin.\n");
    }
    return 0;
}


sdut-3570

Reversed Words

Problem Description

Some aliens are learning English. They have a very strange way in writing that they revered every word in the sentence but keep all the words in common order. For example when they want to write “one two three”, they will write down “eno owt eerht”.

Now we’ve got some sentence written by these aliens, translate them! And maybe we will know some of their secrets!

Input

 Multiple test cases. The first line contains a positive integer T (T <= 1000), indicating the number of test cases.

For each test cases, there will be one line contains only lower case letters and spaces. The length of each line will be no more than 10000. Test cases which are longer than 5000 will be less than 50. Continuous letters are seen as a word, words are separated by spaces. There won’t be two adjacent spaces in the input. Space won’t be the first or the last character.

Output

 One line per case, the translated sentence.

Example Input

2eno owt eerhtabcde

Example Output

one two threeedcba
题解:
字符串处理
#include 
#include 

using namespace std;

char s[10005];
stackq;
int main()
{
    int t;
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        while(!q.empty())q.pop();
        gets(s);
        int len=strlen(s);
        int i=0;
        while(i7)break;
            if(s[i]==' ')
            {
                printf("%c",s[i]);
                i++;
            }
            else
            {
                while(s[i]!=' '&&s[i]!='\0')
                {
                    q.push(s[i]);
                    i++;
                }
                while(!q.empty())
                {
                    printf("%c",q.top());
                    q.pop();
                }

            }
        }
        printf("\n");
    }
    return 0;
}


你可能感兴趣的:(#,ACM-数学,#,ACM-图论,#,ACM-动态规划,#,ACM-数据结构,#,ACM-算法设计)