584A Codeforces - Olesya and Rodion


584A Codeforces - Olesya and Rodion




Solution in c++

#include <bits/stdc++.h>

using namespace std;
int n,m;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    if(m==1)cout<<string(n,'1');
    else if(m==2)cout<<string(n,'2');
    else if(m==3)cout<<string(n-1,'1')<<3-(n-1)%3;
    else if(m==4)
    {
        if(n==1)cout<<4;
        else cout<<string(n-2,'1')<<12;
    }
    else if(m==5)cout<<string(n-1,'1')<<5;
    else if(m==6)cout<<string(n-1,'2')<<6-2*(n-1)%6;
    else if(m==7)cout<<string(n,'7');
    else if(m==8)
    {
        if(n==1)cout<<8;
        else if(n==2)cout<<16;
        else cout<<string(n-3,'1')<<"224";
    }
    else if(m==9)    cout<<string(n-1,'1')<<9-(n-1)%9;
    else if(m==10 && n>1)cout<<string(n-1,'1')<<0;
    else cout<<-1;
    return 0;
}

another Solution 

#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;
int n,m;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    if(m<10)cout<<string(n,m+'0');
    else if(m==10 && n>1)cout<<string(n-1,'1')<<0;
    else cout<<-1;
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق