About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

বৃহস্পতিবার, ১ জানুয়ারী, ২০১৫

UVA solution :11787 - Numeral Hieroglyphs

#include <iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
     //freopen("in.txt","r",stdin);
    int test,ary[600],b,u,s,p,f,t,m;
    string ss;
    scanf("%d",&test);
    while(test--)
    {
        cin>>ss;
        int len=ss.length();
        b=0;
        u=0;
        s=0;
        p=0;
        f=0;
        t=0;
        m=0;
        int in=0,cnt=0;
        long long sum=0;
        for(int i=0; i<len; i++)
        {
            if(ss[i]=='B')
            {
                b++;
                ary[in++]=1;
                sum+=1;
            }
            else  if(ss[i]=='U')
            {
                u++;
                ary[in++]=2;
                sum+=10;
            }
            else  if(ss[i]=='S')
            {
                s++;
                ary[in++]=3;
                sum+=100;
            }
            else  if(ss[i]=='P')
            {
                p++;
                ary[in++]=4;
                sum+=1000;
            }
            else  if(ss[i]=='F')
            {
                f++;
                ary[in++]=5;
                sum+=10000;
            }
            else  if(ss[i]=='T')
            {
                t++;
                ary[in++]=6;
                sum+=100000;
            }
            else  if(ss[i]=='M')
            {
                m++;
                ary[in++]=7;
                sum+=1000000;
            }


        }
        int as=0,ds=0;
        for(int i=0; i<in-1; i++)
        {
            if(ary[i]>ary[i+1]) ds++;
            else if(ary[i]<ary[i+1]) as++;
        }


        if(as>0||(as==0&&ds==0))
        {
            for(int i=0; i<in; i++)
            {
                for(int j=0; j<in-1; j++)
                {
                    if(ary[j]>ary[j+1]) cnt++;
                }
            }
        }
        else if(ds>0)
        {
            for(int i=0; i<in; i++)
            {
                for(int j=0; j<in-1; j++)
                {
                    if(ary[j]<ary[j+1]) cnt++;
                }
            }


        }

        if(cnt>0||b>9||u>9||s>9||p>9||f>9||t>9||m>9)
         {
             printf("error\n");
         }
         else
         {
             cout<<sum<<endl;
         }



    }


    return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন