Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define left Stanga
- #define right Dreapta
- using namespace std;
- ifstream fin("cochilie.in");
- ofstream fout("cochilie.out");
- int v[832040];
- int left, right;
- int Fibo[32];
- int line;
- void divide(int step)
- {
- if(step<0)
- return;
- if(step%4==0)
- {
- if(line<=Fibo[step])
- {
- while(left<=right)
- v[left++]=step+1;
- return;
- }
- line-=Fibo[step];
- }
- if(step%4==1)
- {
- for(int i=0; i<Fibo[step]; i++)
- v[right--]=step+1;
- }
- if(step%4==2)
- {
- if(line>Fibo[step-1])
- {
- while(left<=right)
- v[left++]=step+1;
- return;
- }
- }
- if(step%4==3)
- {
- for(int i=0; i<Fibo[step]; i++)
- v[left++]=step+1;
- }
- divide(step-1);
- return;
- }
- int main()
- {
- int c,n,p;
- fin>>c;
- fin>>n;
- int len[2]={1,1};
- p=1;
- Fibo[0]=Fibo[1]=1;
- for(int i=1; i<n; i++)
- {
- len[p]+=len[p^1];
- Fibo[i+1]=len[p];
- p^=1;
- }
- if(c==1)
- {
- fout<<len[0]<<' '<<len[1] <<'\n';
- }
- else
- {
- fin>>line;
- n--;
- left=0;
- right=len[1]-1;
- divide(n);
- for(int i=0; i<len[1]; i++)
- fout<<v[i]<<' ';
- fout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement