【ZOJ】3889 Making Sequence【构造】
来源:互联网 发布:查看mac激活时间 编辑:程序博客网 时间:2024/05/16 01:53
传送门:【ZOJ】3889 Making Sequence
根据题意构造即可。ZOJ月赛我们抢的第二个FBwww
#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 ;}
0 0
- 【ZOJ】3889 Making Sequence【构造】
- ZOJ 3952 Fibonacci Sequence Chicken Edition(构造/模拟)
- ZOJ 1463 Brackets Sequence
- zoj 2105 Number Sequence
- [ZOJ 1463] Brackets Sequence
- zoj 1410 Number Sequence
- ZOJ 2105 Number Sequence
- ZOJ 3293 Simple Sequence
- HDU_4377_Sub Sequence(构造)
- zoj 2421 Recaman's Sequence
- zoj 2421 Recaman's Sequence
- zoj 3672 Gao The Sequence
- zoj - 3672 - Gao The Sequence
- ZOJ 2421 Recaman's Sequence
- ZOJ 2421 Recaman's Sequence
- ZOJ 3290 Longest Subtrahend Sequence
- ZOJ 3672 Gao The Sequence
- ZOJ 3892 Available Computation Sequence
- HDU 2012 素数的判定
- bat 运行后不自动关闭
- 数据库ACID
- HDU oj 密码
- ie打印横打
- 【ZOJ】3889 Making Sequence【构造】
- 3.2.用户空间客体管理器
- LeetCode OJ 之 Different Ways to Add Parentheses(增加括号的不同方法)
- Agri-Net (POJ 1258)
- StringBuffer内容清空效率比较
- MFC绘图
- 获取手机的IMEI,MSISDN,ICCID,IMSI
- 某互联网金融公司“产品经理”培训圆满结束!
- C/C++中的void 和 void *