【省赛】山东省第七届ACM省赛(部分水题)

链接:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/problemlist/cid/1761

B

Fibonacci

Time Limit: 2000 ms Memory Limit: 131072 KiB
Submit Statistic

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.

Sample Input

4
5
6
7
100

Sample Output

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


1 // 下次粘贴上
View Code

E

The Binding of Isaac

 

Time Limit: 2000 ms Memory Limit: 65536 KiB

 

Submit Statistic

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.

Sample Input

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

Sample Output

8
4

代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 
 5 int main()
 6 {
 7     int t,n,m;
 8     cin >> t;
 9     while(t--)
10     {
11         char a[110][110];
12         scanf("%d %d",&n,&m);
13         getchar();
14 
15         for(int i = 0;i <= n+1;i++)
16         {
17                 a[i][0] = a[i][m+1] = '.';
18         }
19         for(int i = 0;i <= m+1;i++)
20         {
21             a[0][i] = a[n+1][i] = '.';
22         }
23         for(int i = 1;i <= n;i++)
24         {
25             for(int j = 1;j <= m;j++)
26             {
27                 scanf("%c",&a[i][j]);
28             }
29             getchar();
30         }
31         // for(int i = 0;i <= n+1;i++)
32         // {
33          //    for(int j = 0;j <= m+1;j++)
34           //  {
35             //    printf("%c ",a[i][j]);
36             //}
37             //printf("\n");
38        // }
39         int sum = 0;
40         for(int i = 1;i <= n;i++)
41         {
42             if(a[i][1] == '#')  sum++;
43             if(a[i][m] == '#')  sum++;
44         }
45         for(int i = 1;i <= m;i++)
46         {
47             if(a[1][i] == '#')  sum++;
48             if(a[n][i] == '#')  sum++;
49         }
50         for(int i = 1;i <= n;i++)
51         {
52             for(int j = 1;j <= m;j++)
53             {
54                 if(a[i][j] == '.')
55                 {
56                     if(a[i-1][j] == '#' && a[i+1][j] != '#' && a[i][j-1] != '#' && a[i][j+1] != '#')
57                         sum++;
58                     if(a[i-1][j] != '#' && a[i+1][j] == '#' && a[i][j-1] != '#' && a[i][j+1] != '#')
59                         sum++;
60                     if(a[i-1][j] != '#' && a[i+1][j] != '#' && a[i][j-1] == '#' && a[i][j+1] != '#')
61                         sum++;
62                     if(a[i-1][j] != '#' && a[i+1][j] != '#' && a[i][j-1] != '#' && a[i][j+1] == '#')
63                         sum++;
64                 }
65             }
66         }
67         printf("%d\n",sum);
68     }
69     return 0;
70 }
View Code

J

Execution of Paladin

 

Time Limit: 2000 ms Memory Limit: 65536 KiB

 

Submit Statistic

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.

Sample Input

3
3 1
Coldlight Oracle
Coldlight Oracle
Murloc Warleader
3 8
Old Murk-Eye
Old Murk-Eye
Coldlight Oracle
7 30
Old Murk-Eye
Bluegill Warrior
Bluegill Warrior
Murloc Warleader
Murloc Warleader
Coldlight Oracle
Coldlight Oracle

Sample Output

Tell you a joke, the execution of Paladin.
Mrghllghghllghg!
Tell you a joke, the execution of Paladin.

Hint

 In the first test case, none of the Murlocs can attack.

In the second test case, every Old Murk-Eye has +2 ATTACK because there is another Old Murk-Eye and a Coldlight Oracle. So the total damage is 8.

In the last test case, Old Murk-Eye has 12 ATTACK (2 basic ATTACK, 6 other Murlocs and 2 Murloc Warleader), two Bluegill Warriors has 6 ATTACK(2 basic ATTACK, and 2 Murloc Warleader) each. So the total damage is 24.

代码:

// 下次贴上
View Code

 

K

Reversed Words

Time Limit: 2000 ms Memory Limit: 131072 KiB
Submit Statistic Discuss

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.

Sample Input

2
eno owt eerht
abcde

Sample Output

one two three
edcba


水题
 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 
 6 
 7 void print(string s,int st,int en)
 8 {
 9     for(int i = en;i >= st;i--)
10         printf("%c",s[i]);
11     return ;
12 };
13 
14 int main()
15 {
16     int t;
17     cin >> t;
18     getchar();
19     for(int k = 1;k <= t;k++)
20     {
21 
22         string s;
23         getline(cin,s);
24         // getchar();
25         int st = 0;
26         for(int i = 0;i < s.size();i++)
27         {
28             if(s[i] == ' ')
29             {
30                 print(s,st,i-1);
31                 printf(" ");
32                 st = i+1;
33             }
34             else
35             {
36                 if(i == s.size()-1)
37                 {
38                     print(s,st,s.size()-1);
39                     printf("\n");
40                 }
41             }
42         }
43     }
44 
45     return 0;
46 }
View Code

猜你喜欢

转载自www.cnblogs.com/duny31030/p/8973642.html