Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("codsecret.in");
- ofstream g("codsecret.out");
- int n,x,v[100001];
- int main()
- {
- f>>n;
- int i=0,nr=0;
- while(n)
- {
- if(i==0)
- {
- f>>x;v[++i]=x;
- f>>x;v[++i]=x;
- n-=2;
- nr=2;
- }
- f>>x;v[++i]=x,++nr;
- 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))
- nr-=3,i-=3;
- --n;
- }
- if(nr)
- for(int i=1;i<=nr;++i)
- g<<v[i]<<' ';
- else
- g<<"Merry Christmas";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement