Wiki with Alpha

G. Wiki with Alpha Problem
the Input File: Standard the INPUT Time limit: 1 SECOND,
the Output File: Standard the Output Memory limit: 256 megabytes
recently, in Labrador planet held a remarkable human intelligence pk tournament. Of course pk tournament protagonist remains our Wiki classmates,
his opponent is called "Alpha" super robot! Competition provisions of the final victory of the party will be " kawaii " magical scepter,
get scepter party will also rule Labrador planet.
Known " kawaii " magical scepter need to inject energy to the power play. There are now a game field k kinds of crystal energy, different crystal may
be able to have different capabilities values A I , and the energy of each crystal can be used infinitely .
Now the game requires players take turns to crystal energy injected into magic scepter, each player can in this kSelect any seed crystal in a magic injection
method token ( selected crystal must be used, not remaining ), who should fill the energy of tokens (token is assumed here that the desired energy value of magic n- , note
filled exactly equal means the n- , no more than the n- ), who will win.
Since the coin toss in the process, Wiki won, therefore, Wiki first injection of energy, Alpha after, then take turns
going until the end of the game.
As we all know, Wiki , and Alpha are very smart, they ask who will win the final victory? If Wiki get " kawaii " magical scepter, enter
the "Wiki Wins" ; otherwise, outputs "Wiki LOSES" !
Input
input of the first line of two positive integers n and K , represents the energy required to magic token value type and energy of a crystal
Number (1 < = the n-< = 100000 ; 1 < = k < = 100)
2019 Nian " Blue Bridge Cup " Software Design Competition Shanghai University campus tryouts
December 08, 2019
the next input k positive integers A i (1 < = a I < = 10000) , it represents the energy value of each of the crystal , between the number and separated by a space (subject
guaranteed a I have at least one . 1 )
the output
output Event results
Samples

standard input standard output
5 2
1 4
Wiki Loses
10 8
2 1 6 7 8 10 9 20
Wiki Wins



Ideas: the memory of the game; (very clever)

 

 1 #include <iostream>
 2 #include <cstring>
 3 #include <algorithm>
 4 
 5 using namespace std ;
 6 
 7 const int N = 100010, M = 110 ;
 8 int n, k ;
 9 bool st[N] ;
10 int q[110] ;        
11 
12 int main(){
13     cin >> n >> k ;
14     
15     for(int i=0;i<k;i++){
16         cin >> q[i] ;
17     }
18     
19     for(int i=1;i<=n;i++){
20         for(int j=0;j<k;j++){
21             if(i>=q[j] && !st[i-q[j]]){
22                 st[i] = 1 ;
23             }
24         }
25     }
26     if(st[n]){
27         cout << "Wiki Wins" << endl ; 
28     }else{
29         cout << "Wiki Loses" << endl ;
30     }
31     return 0 ;    
32 } 

Guess you like

Origin www.cnblogs.com/gulangyuzzz/p/12034717.html