NYOJ-541-strongest DE combat power (the fifth Henan Programming Competition-Big Data !!)

Source: Internet
Author: User

NYOJ-541-strongest DE combat power (the fifth Henan Programming Competition-Big Data !!)

 

Strongest DE fighting time limit: 1000 MS | memory limit: 65535 KB difficulty: 3

During the Spring and Autumn Period and the Warring States Period, Zhao Guo made great achievements in land and resources, and the people lived and operated in peace. However, many countries are eager to join in launching a war against Zhao.

Apparently, Zhao's troops are obviously at a disadvantage in the face of combat by troops from multiple countries. Combat Effectiveness is a key factor that determines the success or failure of a war. Generally, the combat effectiveness of an army is directly proportional to that of the army. However, when a unit is divided into several combat teams, the combat capability of this unit will be greatly enhanced.

The combat power of an army can be calculated using the following two rules:

1. If the strength of a combat team is N, the combat capability of this team is N;

2. If a unit is divided into several combat teams, the total combat power of the Unit is the product of the combat power of these teams.

For example, an analysis of the combat power of an army at 5 hours is as follows:

Situation

Operational Arrangement

Total combat power

1

, 1 (divided into five combat teams)

1*1*1*1*1 = 1

2

1, 1, 2 (divided into 4 combat teams)

1*1*1*2 = 2

3

1, 2 (divided into three combat teams)

1*2*2 = 4

4

, 3 (divided into three combat teams)

1*1*3 = 3

5

2, 3(Divided into two combat teams)

2*3 = 6

6

1, 4 (divided into two combat teams)

1*4 = 4

7

5 (divided into one Combat Team)

5 = 5

2
5
4
6
4

 

 

AC code:

 

#include 
 
  #include 
  
   #include using namespace std;int ans[205];int multiply(int x){    for(int up=0, i=0; i<200; i++){        up = ans[i] * x + up;        ans[i] = up % 10;        up /= 10;    }}int main(){    int N;    scanf(%d, &N);    while(N--){        memset(ans, 0, sizeof(ans)); ans[0]=1;        int a;        scanf(%d, &a);        int n = a/3, i;        if(a%3 == 1) n--;        for(i=0; i
   
    =0;i--)            if(ans[i]) break;        for(; i>0; i--)            printf(%d, ans[i]);        printf(%d, ans[0]);    }    return 0;}
   
  
 


 

 

Clearly, the troops are divided into two combat teams (one is 2 and the other is 3), and the total combat power reaches the maximum!
Enter the first line: N indicates that N groups of test data exist. (2 <= N <= 5)
Next there are N rows. Each row has an integer Ti representing the troops of Zhao guotroops. (1 <= Ti <= 1000) I = 1 ,... N
The output occupies one row of test data for each row. Only one INTEGER (S) indicates the maximum combat effectiveness of the combat arrangement.
Sample Input
Sample output

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.