Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 53 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define debug(x) cerr << "  - " << #x << ": " << x << endl;
  4. #define debugs(x, y) cerr << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
  5. #define here() cerr << "here" << endl;
  6. #define all(x) (x).begin(),(x).end()
  7. #define pb push_back
  8. #define fi first
  9. #define se second
  10. #define EPS 1e-7
  11. #define INF 2000000000
  12. const int MODN = 1e9 + 7;
  13. #define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; i++)
  14. typedef long long ll;
  15. typedef pair<int, int> ii;
  16. typedef vector<int> vi;
  17. typedef vector<ii> vii;
  18. int n;
  19. int ns[1002];
  20. void work(int len, int st){
  21.     if(len<3) return;
  22.     int len1=ns[st];
  23.     int len2=len-len1;
  24.     work(len2,st+len1);
  25.     work(len1,st+1);
  26.     if(ns[st]+1<len){
  27.         int w=1;
  28.         for(int i=0;i<st;i++,w++) printf("%d ", ns[i]);
  29.         printf("%d ",ns[st]+1);
  30.         for(;w<n;w++) printf("1 ");
  31.         printf("\n");
  32.         exit(0);
  33.     }
  34. }
  35. int main(){
  36.     scanf("%d",&n);
  37.     rep(i,n) scanf("%d",&ns[i]);
  38.     work(n,1); //num feuilles / starting position
  39.     printf("0\n");
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top