Search This Blog

Saturday, 25 July 2015

UVA SOME EASY Problems FOR BEGINNERS

UVA Some Easy Problems For BEGINNERS

Monday, 15 June 2015

UVA 12372-Packing for holiday

 

 Problem Link: Click Here!

 

12372-Packing for holiday


#include<stdio.h>

int main(void){

int i,t,L,W,H;

scanf("%d",&t);

i=1;

while(i<=t){

        scanf("%d %d %d",&L,&W,&H);

        if(L<=20 && W<=20 && H<=20)
                   printf("Case %d: good\n",i);
       else printf("Case %d: bad\n",i);

       i++;
    }

return 0;

}


Sunday, 14 June 2015

10035-Primary Arithmatic

 Problem Link:Click Here!!

 

Problem Solution:

#include<stdio.h>
int main(void){

long long int a,b,res,c,d;
int o;

while(scanf("%lld %lld",&a,&b)==2){

o=0;
res=0;

if(a==0 && b==0)break;

else{
        if(a<b){c=a;
        a=b;
        b=c;
     }

      while(a!=0){
       c=a%10;
       a=a/10;
       d=b%10;
       b=b/10;
       res=c+d+res;

      if(res>=10){o++;
               res=res/10;
                  }

       else res=0;
       }

if(o==0)printf("No carry operation.\n");
        else if(o==1)printf("%d carry operation.\n",o);
                 else if(o>1)printf("%d carry operations.\n",o);
              }
      }
return 0;
}

369 - Combinations

 Problem Link: Click Here!!

 Solution:


#include <stdio.h>

int main (void) {
    double m,n,a,b,c;

    while(scanf("%lf %lf",&m,&n)==2 && m && n){


        c=1;
        a=m;
        b=m-n;

        if(b>n) b=n;

        while(b) {
            c = c*(a/b);
            a--;
            b--;
        }


        printf("%.0lf things taken %.0lf at a time is %.0lf exactly.\n",m,n,c);

    }

    return 0;
}

Saturday, 13 June 2015

11219 - How old are you?

 Problem Link:Click Here!!


Solution:

#include<stdio.h>
int main()
{

int i,t,y,y1,y2,m1,m2,d1,d2;

scanf("%d",&t);

i=1;

while(i<=t){

scanf("%d/%d/%d",&d1,&m1,&y1);
scanf("%d/%d/%d",&d2,&m2,&y2);

     y=(y1-y2);

            if(m1<m2)
                y--;

            else if(m1==m2)
            {
                if(d1<d2)
                y--;
            }

            if(y<0)
                printf("Case #%d: Invalid birth date\n", i );
            else if(y>130)
                printf("Case #%d: Check birth date\n", i);
            else
                printf("Case #%d: %d\n",i,y);

    i++;

  }

return 0;

}

Friday, 12 June 2015

11799 - Horror Dash

11799 - Horror Dash

Problem Link: Click Here!

Solution:

#include<stdio.h>

int main(void){
int i,t,m,v=0;
char ch;
i=1;
scanf("%d",&t);

while(i<=t){
ch='a';
v=0;

while(ch !='\n'){
scanf("%d",&m);
scanf("%c",&ch);
if(m>v)v=m;
}

printf("Case %d: %d\n",i,v);

i++;
}

return 0;
}

10879 - Code Refactoring

10879 - Code Refactoring

Problem Link: Click Here!

Solution:

#include<stdio.h>
int main(void){
int i,t,m,ao[5];
long long int a,j;
scanf("%d",&t);
i=1;
while(i<=t){
m=0;
scanf("%lld",&a);
for(j=2;j<=a/2;j++){
if(a%j==0){
        ao[m]=j;
        ao[++m]=a/j;
        m++;
        }
if(m==4)break;
}
printf("Case #%d: %lld = %d * %d = %d * %d\n",i,a,ao[0],ao[1],ao[2],ao[3]);
i++;
}
return 0;
}

11192 - Group Reverse

11192 - Group Reverse

 

Problem Link:Click Here!


Solution:


#include<stdio.h>
#include<string.h>
int main(void){
      int a,l,i,j,m,n;
      char str[101],temp;


      while(scanf("%d",&a)==1 && a!=0){
         scanf(" %s",str);
         l=strlen(str);
         n=l/a;


         for(i=0;i<=l-n;i=i+n){
               m=i;
                j = (m+n)-1;


               while (m < j) {
                       temp = str[m];
                       str[m] = str[j];
                       str[j] = temp;
                       m++;
                        j--;
                  }


            }
       printf("%s\n",str);
       }
return 0;
}

Thursday, 11 June 2015

12577 - Hajj-e-Akbar

11530 - SMS Typing

Uva-11530 - SMS Typing

Problem link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2525

Solution:

#include<stdio.h>
int main(void){

int t,i=1,sum=0;
char a,b;

scanf("%d",&t);
scanf("%c",&b);

while(i<=t){

while(scanf("%c",&a)==1){

if(a=='\n'){
printf("Case #%d: %d\n",i,sum);
sum=0;
break;
}

switch(a){
case'a':
case'd':
case'g':
case'j':
case'm':
case'p':
case't':
case'w':
sum=sum+1;
break;

case'b':
case'e':
case'h':
case'k':
case'n':
case'q':
case'u':
case'x':
sum=sum+2;
break;

case 'c':
case'f':
case'i':
case'l':
case'o':
case'r':
case'v':
case'y':
sum=sum+3;
break;

case's':
case'z':
sum=sum+4;
break;

default:
sum=sum+1;
break;

}
}
i++;
}
return 0;
}

Tuesday, 9 June 2015

10812 - Beat the Spread!

494 - Kindergarten Counting Game

How to Count Words From a String

Counting Words From a String

Two Cases:

case no.1

If there is a single space between every words,like,
Have a nice day.
Then first you have to count the spaces,then the number of the words will be <number of spaces+1>.
In the above example we can see that there is 3 spaces .So the number of words is 3+1=4.

So the code will be in C,

#include<stdio.h>
#include<string.h>
 
int main(void){
   int i,l,count;
   char str[150];

   gets(str);
   count=0;
   l=strlen(str);
   for(i=0;i<=l;i++){
            if(str[i]==' ')count++;
          }
   printf("The number of Words: %d\n",count);
   return 0;
}

case no.2

But what if the sentence is,
Have  .. a nice   day.

here there is 7 spaces and 2 fullstops in the middle of the words.Here we can not apply the previous formula.
Here,There are some steps to count the words.Well,In most programming contest,you will find these types of sentences to calculate words.

Steps are:

1>> First find the start of a word by a loop and if case.
2>>then went on by i++ to find the last of that word.
3>>then continue the loop till the end of the string.

Here is a C code for better understanding the steps.

#include<stdio.h>

#include<string.h>

 int main(void)
    {
   int i,l,count;

   char str[150];   
//variables

   gets(str);

   count=0;      /
/the variable for counting the words

   l=strlen(str);

   for(i=0;i<=l;i++)
    {
      if((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
                    //conditions if the ith member of the string is an alphabet(step1)
             {
            count++;

     while((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
                    {
             i++;        
//conditions for finding the last of the word(step 2)
                     }
             }
   }

   printf("The number of Words: %d\n",count);

   return 0;

   }

 if you have any question you can comment.Thank you.

Thursday, 14 May 2015

UVA Problem no:10469

UVA Problem no:10469

To Carry or not to Carry

Solution:

Now for this problem,I will suggest you to know a rational operator.
"Exclusive or"  or XOR is a bitwise operation, so it operates on individual bits.
XOR operator (also called "logical addition") is defined like this:

 so as the problem stated above in the picture,we can see that Mofiz is asked to not carry the bits while adding to numbers in binary form.So, It's mean 1+1=0,
1+0=1, 0+1=1 which exactly like exclusive or operator.
So,This is the code,
If you still can't understand,You can comment.I will try to explain.Thank you.

Tuesday, 5 May 2015

Organizational Paradigms for Teams of Software Engineers

The best team structure depends on the management style of the organization. Constantine suggests four “organizational paradigms” for software engineering teams. Here are some differences between the paradigms.



No.
Open Paradigm
Synchronous Paradigm
1.
The open paradigm attempts to structure a team in a manner that achieves some of the controls but also much of the innovation.
The synchronous paradigm relies on the natural compartmentalization of a
problem
2.
This paradigm is like the mixer of closed and random paradigm.
This paradigm is exceptional. Its type is different from the others.
3.
Work is performed collaboratively, with heavy communication under open paradigm.
Little active communication among the team members is the characteristic of this paradigm.
4.
Open paradigm team structures are well suited to the solution of complex problems.
Synchronous Paradigm organizes team members to work on pieces of the problem.
5.
This paradigm interests through negotiation and discussion.

It has alignment with a common vision or direction

No.
Closed Paradigm
Random Paradigm
1.
A closed paradigm structures a team along a traditional hierarchy of authority.
The random paradigm structures a team loosely and depends on individual initiative of the team members.
2.
This paradigm is similar to a Controlled Centralized (CC) team.
This paradigm is similar to a Democratic decentralized (DD) team.
3.
This team can work well when producing software which is quite similar to past efforts.
This team does not deal with the work what is similar to past efforts.
4.
The works done by this paradigm are less likely to be innovative.
When innovation or technological breakthrough is required, teams following the random paradigm will excel.
5.
This team works easily with orderly performance.
Such team may struggle when “orderly performance” is required.