UVa starter


UVa Online Judge Problems Solution with Hint and Critical TestCases

Most of the problems are listed here applicable for absolute beginners. Though these post are formatted in a fashion that will help anyone who are trying to solve the problems.
On regular basis i will add more posts in this page. Meanwhile take a look [ Online Judges ] for problem rankList based on difficulty and some other useful links .. hope you may find it useful. 🙂

*******************
Update
*******************
I will try to post the following problems sequentially in this page. I think these problems would be a good start for UVa Beginners

100, 102, 113, 200, 256, 272, 299, 414, 424, 445, 458, 483, 484, 488, 489, 490, 494, 499, 573,
575, 591, 661, 694, 739, 10035, 10055, 10071, 10082, 10222, 10260, 10281, 10300, 10370,
10420, 10703, 10812, 10921, 11044, 11150, 11172, 11185, 11192, 11223, 11340, 11498,
11547, 11616, 11727, 12602

Volume 1:
// UVa : 100 (The 3n + 1 problem) //
// UVa : 102 (Ecological Bin Packing) //
// UVa : 113 (Power of Cryptography) //
// UVa : 136 (Ugly Numbers) //

Volume 2:
// UVa : 200 (Rare Order) //
// UVa : 256 (Quirksome Squares) //
// UVa : 272 (TeX Quotes) — coming soon //
// UVa : 299 (Train Swapping) //

Volume 4:
// UVa : 482 (Permutation Arrays) //

Volume 5:
// UVa : 534 (Frogger) //
// UVa : 544 (Heavy Cargo) //
// UVa : 558 (Wormholes) //
// UVa : 574 (Sum It Up) //

Volume 6:
// UVa : 642 (Word Amalgamation) //

Volume 100:
// UVa : 10048 (Audiophobia) //
// UVa : 10067 (Playing with Wheels) //
// UVa : 10074 (Take the Land) //

Volume 101:
// UVa : 10152 (ShellSort) //
// UVa : 10190 (Divide, But Not Quite Conquer!) //
// UVa : 10198 (Counting) //
// //

Volume 102:
// UVa : 10219 (Find the ways !) //

Volume 104:
// UVa : 10474 (Where is the Marble?) //

7 thoughts on “UVa starter

  1. // program to find the factorial of a number
    #include
    #include
    void main()
    {
    int i,fact=1,n;
    clrscr();
    printf(“\nenter the limit”);
    scanf(“%d”,&n);
    printf(“\nenter the no:”);
    for(i=1;i<=n;i++)
    {
    fact=fact*i;
    }
    printf("\nfactorial of %d is %d",n,fact);
    getch();
    }

  2. // 10494
    #include
    #include
    int main(){

    long int f,s,ans,i=0;
    char sign;

    while(1) {
    scanf(“%ld”,&f);

    scanf(” %c “,&sign);
    scanf(“%ld”,&s);

    if(f>=s && s>0){
    if(sign==’%’ ){
    ans=f-(f/s)*s;
    printf(“%ld”,ans);

    }
    else if (sign==’/’){

    printf(“%ld”,f/s);

    }

    }}
    return 0;
    }

    // what is problem of it ??????????

  3. #include

    int main()
    {
    int a,b,c,i,test;
    scanf(“%d”,&test);
    for(i=1;ib)
    {
    if(a>c)
    {
    if(a*a==b*b+c*c)
    printf(“case %d : scalene\n”,i);
    else
    printf(“case %d : invalid\n”,i);
    }
    else
    {
    if(c*c==a*a+b*b)
    printf(“case %d : scalene\n”,i);
    else
    printf(“case %d : invalid\n”,i);
    }
    }
    else if(b>a)
    {
    if(b>c)
    {
    if(b*b==c*c+a*a)
    printf(“case %d : scalene\n”,i);
    else
    printf(“case %d : invalid\n”,i);
    }
    else
    {
    if(c*c==a*a+b*b)
    printf(“case %d : scalene\n”,i);
    else
    printf(“case %d : invalid\n”,i);
    }
    }

    }
    return 0;
    }
    //this code why shows incorrect result for critical input??????

  4. #include
    using namespace std;

    int main()
    {
    int a,b,i,j,n,count=0;
    cin>>a>>b;
    if(a>b)
    {
    swap(a,b);
    }

    for(i=a;i<=b;i++)
    {
    unsigned int n=i;
    for(j=0;;j++)
    {
    if(n==1)
    {
    count++;
    break;
    }
    else if(n%2==1)
    {
    n=3*n+1;
    count++;
    }
    else if (n%2==0)
    {
    n=n/2;
    count++;
    }
    }
    }

    cout<<"cycle_length:"<<count;
    }

    whats the problem here? For critical input the output doesn't mach with my result. And my code also take much run time. what can I do? What are the possible change I have to do in my code….

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.