Search

Blog of AsEs

Try Try && Try is The Key of Success

Uva – 11498 – Division of Nlogonia

Problem Name :  Division of Nlogonia

Problem Link : See Problem : Uva – 11498

Solution  :

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int k,n,m,x,y;
    while(1){
    cin>>k;
    if(k==0) break;
    cin>>n>>m;
    while(k--)
    {
        cin>>x>>y;
    if(x==n||y==m)
        cout<<"divisa"<<endl;
    else if(x>n&&y>m)
        cout<<"NE"<<endl;
    else if(x<n&&y>m)
        cout<<"NO"<<endl;
    else if(x>n&&y<m)
        cout<<"SE"<<endl;
    else
        cout<<"SO"<<endl;
    }
    }
    return 0;
}

Uva – 12279 – Emoogle Balance

Problem Name :  Emoogle Balance

Problem Link : See Problem : Uva – 12279

Solution  :

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a[10000];
    int n,b,i,t=0;
    while(1)
    {
        cin>>n;
        b=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        if(a[i]==0)
        {
            b++;
        }
        cout<<"Case "<<++t<<": "<<((n-b)-b)<<endl;
    }
    return 0;
}

Uva – 11547 – Automatic Answer

Problem Name :  Automatic Answer

Problem Link : See Problem : Uva – 11547

Solution  :

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    long long t,a,b,c;
    cin>>t;
    while(t--)
    {
        cin>>a;
        b=((((((a*567)/9)+7492)*235)/47)-498);
        c=((b%100)/10);
        cout<<abs(c)<<endl;

    }
    return 0;
}

Uva – 1124 – Celebrity jeopardy

Problem Name :  Celebrity jeopardy

Problem Link : See Problem : Uva – 1124

Solution  :

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char a[100000];
    while(gets(a))
    {
        cout<<a<<endl;
    }
    return 0;
}

Uva – 12250 – Language Detection

Problem Name :  Language Detection

Problem Link : See Problem : Uva – 12250

Solution  :

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string s;
    int t=0;
    while(cin>>s)
    {
        if(s=="#")
            break;
        else if(s=="HELLO")
            cout<<"Case "<<++t<<": ENGLISH"<<endl;
            else if(s=="HOLA")
                cout<<"Case "<<++t<<": SPANISH"<<endl;
            else if(s=="HALLO")
                cout<<"Case "<<++t<<": GERMAN"<<endl;
            else if(s=="BONJOUR")
                cout<<"Case "<<++t<<": FRENCH"<<endl;
            else if(s=="CIAO")
                cout<<"Case "<<++t<<": ITALIAN"<<endl;
            else if(s=="ZDRAVSTVUJTE")
                cout<<"Case "<<++t<<": RUSSIAN"<<endl;
            else
                cout<<"Case "<<++t<<": UNKNOWN"<<endl;
    }
    return 0;
}

Uva – 12403 – Save Setu

Problem Name :  Save Setu

Problem Link : See Problem : Uva – 12403

Solution  :

#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    int t,a,b=0;
    cin>>t;
    while(t--)
    {
        cin>>s;
        if(s=="donate")
        {
            cin>>a;
            b=b+a;
        }
        else if(s=="report")
            cout<<b<<endl;
    }
    return 0;
}

Uva – 272 – TEX Quotes

Problem Name :  TEX Quotes

Problem Link : See Problem : Uva – 272

Solution  :

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char a[10000];
    int b=0;
    while(gets(a))
    {
        int l=strlen(a);
        for(int i=0;i<l;i++)
        {
            if(a[i]=='"'){
                b++;
            if(b%2==0)
            {
               cout<<"''";
            }
            else
                cout<<"``";

        }
        else
            cout<<a[i];
    }
    cout<<endl;
    }
    return 0;
}

Uva – 900 – Brick Wall Patterns

Problem Name :  Brick Wall Patterns

Problem Link : See Problem : Uva – 900

Solution  :

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a[1000],n;
    while(cin>>n)
    {
        if(n==0)
            break;
        a[0]=0;
        a[1]=1;
        for(int i=2;i<=n+1;i++){
            a[i]=a[i-1]+a[i-2];
        }
        cout<<a[n+1]<<endl;
    }
    return 0;
}

Uva – 10929 – You can say 11

Problem Name :  You can say 11

Problem Link : See Problem : Uva – 10929

Solution  :

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char s[100000];
    while(gets(s))
    {
        int l=strlen(s),ans=0;
        if(s[0]=='0'&&l==1)
            break;
        for(int i=0;i<l;i++)
        {
            ans=ans*10+s[i]-48;
            ans%=11;
        }
        if(ans==0)
            cout<<s<<" is a multiple of 11."<<endl;
        else
            cout<<s<<" is not a multiple of 11."<<endl;
    }

    return 0;
}

Create a free website or blog at WordPress.com.

Up ↑