zoukankan      html  css  js  c++  java
  • 【省赛】山东省第七届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("
    ");
    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
    ",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.

    代码:

     1 #include <string>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <iostream>
     5 #include <algorithm>
     6 
     7 using namespace std;
     8 
     9 
    10 struct node
    11 {
    12     char x;
    13     int att;
    14 }a[10];
    15 
    16 
    17 int main()
    18 {
    19 
    20     int t,n,h;
    21     cin >> t;
    22     while(t--)
    23     {
    24         string s;
    25         cin >> n >> h;
    26         getchar();
    27         for(int i = 1;i <= n;i++)
    28         {
    29             getline(cin,s);
    30             // getchar();
    31             if(s[0] == 'C')
    32             {
    33                 a[i].x = 'C';
    34                 a[i].att = 2;
    35             }
    36             if(s[0] == 'M')
    37             {
    38                 a[i].x = 'M';
    39                 a[i].att = 3;
    40             }
    41             if(s[0] == 'B')
    42             {
    43                 a[i].x = 'B';
    44                 a[i].att = 2;
    45             }
    46             if(s[0] == 'O')
    47             {
    48                 a[i].x = 'O';
    49                 a[i].att = 2;
    50             }
    51         }
    52 
    53         for(int i = 1;i <= n;i++)
    54         {
    55             if(a[i].x == 'O')
    56             {
    57                 a[i].att += (n-1);
    58             }
    59             if(a[i].x == 'M')
    60             {
    61                 for(int j = 1;j <= n;j++)
    62                 {
    63                     if(j == i)
    64                         continue;
    65                     else
    66                         a[j].att += 2;
    67                 }
    68             }
    69         }
    70 
    71         int attack = 0;
    72         for(int i = 1;i <= n;i++)
    73         {
    74             if(a[i].x == 'O')
    75             {
    76                 // printf("attack+%d
    ",a[i].att);
    77                 attack += a[i].att;
    78             }
    79             if(a[i].x == 'B')
    80             {
    81                 // printf("attack+%d
    ",a[i].att);
    82                 attack += a[i].att;
    83             }
    84         }
    85 
    86         // printf("attack = %d
    ",attack);
    87 
    88         if(attack >= h)
    89         {
    90             printf("Mrghllghghllghg!
    ");
    91         }
    92         else
    93         {
    94             printf("Tell you a joke, the execution of Paladin.
    ");
    95         }
    96     }
    97     return 0;
    98 }
    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("
    ");
    40                 }
    41             }
    42         }
    43     }
    44 
    45     return 0;
    46 }
    View Code
    文章搬运自我的个人博客http://duny31030.top 原博客为静态博客,因备份丢失无法继续更新,所以又搬运回博客园,可能部分文章阅读体验不好,可以到我的静态博客搜索相同标题查看
  • 相关阅读:
    All about Python
    All about TestComplete
    All about Ranorex
    围观大神们的博客
    CRP实施方法论(转)
    启发式测试策略模型(Heuristic Test Strategy Model,简称HTSM)(转)
    soapUI学习笔记---断言的小使用(转)
    soapUI学习笔记--用例字段参数化(转)
    常用功能测试点汇总(转)
    记一次性能测试实践1
  • 原文地址:https://www.cnblogs.com/duny31030/p/8973642.html
Copyright © 2011-2022 走看看