【ZOJ】3889 Making Sequence【构造】
2015-07-28 09:25
295 查看
传送门:【ZOJ】3889 Making Sequence
根据题意构造即可。ZOJ月赛我们抢的第二个FBwww
my code:my~~code:
根据题意构造即可。ZOJ月赛我们抢的第二个FBwww
my code:my~~code:
[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 ; }
相关文章推荐
- ubunt tmux X Error of failed request
- Unique Paths II
- ios UITableView和UITableViewIndex
- Android Stuido 好卡怎么办?不要急,兄弟来教你
- Unique Paths
- OPEN(SAP) UI5 学习入门系列之一:扫盲与热身(下)
- OPEN(SAP) UI5 学习入门系列之一:扫盲与热身(下)
- Java simple GUI DEMO
- UI-UIImageView和Image的区别
- Arduino使用光敏电阻实验
- 3.11-break和continue
- UVA 133 The Dole Queue
- 1612 - Guess(贪心)
- UIPickerView与UIDatePicker
- Leetcode #63 Unique Paths II
- Greatest Common Increasing Subsequence-最长公共上升子序列
- 【PB】PowerBuilder中的一些不太常用的方法
- Stringbuffer StringBuilder String
- iOS动画开发之二——UIView动画执行的另一种方式
- iOS动画开发之三——UIView的转场切换