Advertisement
a53

Catalin si codul secret

a53
Jan 27th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream f("codsecret.in");
  4. ofstream g("codsecret.out");
  5. int n,x,v[100001];
  6.  
  7. int main()
  8. {
  9. f>>n;
  10. int i=0,nr=0;
  11. while(n)
  12. {
  13. if(i==0)
  14. {
  15. f>>x;v[++i]=x;
  16. f>>x;v[++i]=x;
  17. n-=2;
  18. nr=2;
  19. }
  20. f>>x;v[++i]=x,++nr;
  21. if((v[i-2]%v[i-1]==0||v[i-1]%v[i-2]==0)&&(v[i]%v[i-1]==0||v[i-1]%v[i]==0))
  22. nr-=3,i-=3;
  23. --n;
  24. }
  25. if(nr)
  26. for(int i=1;i<=nr;++i)
  27. g<<v[i]<<' ';
  28. else
  29. g<<"Merry Christmas";
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement