A. Madoka and Math Dad codeforce solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
int t,n,i,c=0,co=0,che,r;
cin>>t;
while(t--)
{
cin>>n;
c=0;
co=0;
r=n;
che=0;
while(r>0)
{
if(che==0)
{
r-=2;
c++;
che=1;
}
else
{
r-=1;
co++;
che=0;
}
}
if(r!=0)
{
c=0;
co=0;
r=n;
che=0;
while(r>0)
{
if(che==0)
{
r-=1;
co++;
che=1;
}
else
{
r-=2;
c++;
che=0;
}
}
}
if(co>c)
{
che=0;
while(n!=0)
{
if(che==0)
{
cout<<"1";
che=1;
n--;
}
else
{
cout<<"2";
che=0;
n-=2;
}
}
cout<<endl;
}
else
{
che=0;
while(n!=0)
{
if(che==0)
{
cout<<"2";
che=1;
n-=2;
}
else
{
cout<<"1";
che=0;
n--;
}
}
cout<<endl;
}
}
return 0;
}
0 Comments