根据题意构造即可。ZOJ月赛我们抢的第二个FBwww
my code:
#include <bits/stdc++.h>
using namespace std ;
typedef unsigned long long ULL ;
const int MAXN = 205 ;
ULL n , a , b , s , t ;
ULL S[MAXN] , T[MAXN] , tmp[MAXN] ;
bool calc ( ULL s , ULL a , ULL S[] ) {
if ( s > n ) return 0 ;
s -= a ;
for ( int i = 1 ; i <= s ; ++ i ) S[i] = i ;
for ( int i = 0 ; i < a ; ++ i ) {
tmp[1] = 1 ;
for ( int j = 1 ; j <= s ; ++ j ) {
if ( n < tmp[j] || n - tmp[j] < S[j] ) return false ;
tmp[j + 1] = tmp[j] + S[j] ;
}
++ s ;
for ( int j = 1 ; j <= s ; ++ j ) S[j] = tmp[j] ;
}
return true ;
}
void solve () {
if ( !calc ( s , a , S ) ) printf ( "-1\n" ) ;
else for ( int i = 1 ; i <= s ; ++ i ) printf ( "%llu%c" , S[i] , i < s ? ' ' : '\n' ) ;
if ( !calc ( t , b , T ) ) printf ( "-1\n" ) ;
else for ( int i = 1 ; i <= t ; ++ i ) printf ( "%llu%c" , n - T[i] + 1 , i < t ? ' ' : '\n' ) ;
}
int main () {
int f = 0 ;
while ( ~scanf ( "%llu%llu%llu%llu%llu" , &n , &a , &b , &s , &t ) ) {
if ( f ++ ) puts ( "" ) ;
solve () ;
}
return 0 ;
}