Skip to main content

Let's Do It Again(long contest) || solve

A - Boys & Girls


#include <stdio.h>
int main() {
int n, m, a, b, k = 0, l = 0;
scanf("%d %d",&n,&m);
while (n--) {
scanf("%d %d",&a,&b);
k=k+a;
l=l+b;
}
printf("%d\n",(k+m-1)/m+(l+m-1)/m);
return 0;}

B - Conversion



#include<stdio.h>
int main()
{
    int n,s,o,u;
    scanf("%d",&n);
    s=n/10;
    o=(n/100)*10+(n%10);
    u=n%100;
    if(u==0)
    {
            printf("%d\n",s);
    }
    else if(u>0&&u<10)
    {
    if(s<o)
        printf("%d\n",s);
        else
        printf("%d\n",o);
    }
    else if(s==o&&u>s)
        printf("%d\n",s);
    else if(s==o&&u<s)
        printf("%d\n",u);

    else
    {
    if(s<o&&s<u)
        printf("%d\n",s);
    else if(o<s&&o<u)
        printf("%d\n",o);
    else
        printf("%d\n",u);
    }

    return 0;

}

C - Product



#include <stdio.h>

int main() {

int n,a,b,o;
scanf("%d",&n);
if (n < 0){
        n = -n;
}
a=n%10;
b=n/100%10;
o=n/10000;
printf("%d",a*b*o);
return 0;

}



D - Product 2



#include<stdio.h>
int main()
{
    long long int s,o,u=1,x;
    scanf("%lld",&s);
    if(s<0)
        s=s*(-1);
        x=s;
    while(s!=0)
    {
      o=s%10;
      if(o%2==0)
            u=u*o;
      s=s/10;
    }
    if(u==1&&x!=0)
         printf("-1\n");
         else if(x==0)
            printf("%lld\n",u-1);
    else
        printf("%lld\n",u);
    return 0;

}



E - CB



#include <stdio.h>
int main()
{
int a, b, n, c=1;
scanf("%d %d %d", &a, &b, &n);
while (a* b*c% n > 0)
    {
        c++;

    }

    printf("%d\n", c);
return 0;

}



F - First and Last



#include <stdio.h>
#include<stdlib.h>

int main()

{
    long int n,sum=0,f,l;
    scanf("%ld", &n);
    n=abs(n);
    l=n%10;
    f=n;
    while(n>=10)
    {
        n=n/10;
    }
    f=n;
    sum =f+l;

    printf("%ld\n", sum);


    return 0;


}


G - Conversion 2


 #include<stdio.h>
int main()
{
int a;
    scanf("%d",&a);
printf("%d\n",(a%1000)/10);
return 0;
}


H - Time Machine


#include <stdio.h>

int main() {
int h1, m1, s1, h2, m2, s2, h3, m3, s3, t1, t2,d;
scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
t1=h1*3600+m1*60+s1;
t2=h2*3600+m2*60+s2;
d=(t2-t1+3600*24)%(3600*24);
h3=d/3600;
    d=d%3600;
m3=d/60;
s3=d%60;
printf("%02d:%02d:%02d\n",h3,m3,s3);
return 0;
}

I - S.O.D


#include<stdio.h>
int main()
{
    int n,v,mini,t,j=0,k=0,l,m;
    scanf("%d",&n);
    t=n;
    while(n){
        int c=0,tem;
        scanf("%d",&v);
        tem=v;
        while(v){
            c=c+v%10;
            v=v/10;
        }
        if(t==n){
            mini=c;
        }
        if(c<=mini){
            m=tem;
        mini=c;
    }
    n--;
}

printf("%d\n",m);
return 0;
}


J - Bet

#include<stdio.h>
int main()
{
    int a,b,c,x,y,t;
    scanf("%d",&t);
    for(c=1;c<=t;c++)
    {
        scanf("%d %d",&a,&b);
        if (a>=b&&(a+b)%2==0)
        {
            x=(a+b)/2;
            y=(a-b)/2;
            printf("%d %d\n",x,y);
        }
        else
        {
            printf("impossible\n");
        }
    }
    return 0;

}

K - A.A

#include<stdio.h>
int main()
{
    int n,a,t;
    scanf("%d",&t);

    for(a=1; a<=t; a++)
    {
        scanf("%d",&n);
        n=((((((n*567)/9)+7492)*235)/47)-498);
        n=abs(n);
        n=n/10%10;
        printf("%d\n", n);
    }

     return 0;


}


L - Wrong Answer

#include<stdio.h>
#include<math.h>
int main(){
    long long int a=0,b=0,c,d,i,j,n,m,k=0;
    scanf("%lld %lld", &n, &a);
    for(i=1; i<=a; i++){
        b=n%10;
    if(b==0){
        n/=10;
    }
    else{
        n=n-1;
    }
    }
    printf("%lld\n",n);
    return 0;

}

M - Watermelon

#include<stdio.h>
int main(){
    int m;
    scanf("%d",&m);
    if( (m%2==0)&&m>2)
    printf("YES\n");
    else
    printf("NO\n");

    return 0;


}


N - D.P


#include <stdio.h>

int main()
{
    int N,M;
    scanf("%d %d",&M,&N);
    printf("%d",(M*N)/2);
    return 0;

}


O - Find Team

#include <stdio.h>
int main()
{
 int n,a,t=0,p,q,r;
 scanf("%d",&n);
 while(n!=0){
  scanf("%d %d %d",&p,&q,&r);
  if(p+q+r>1){
    t++;
 }
    n--;
 }
 printf("%d\n",t);
 return 0;
} 

P - Lost


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

scanf("%d",&n);

if(n < 5)
        printf("few\n");
else if(n < 10)
printf("several\n");
else if(n < 20)
printf("pack\n");
else if(n < 50)
printf("lots\n");
else if(n < 100)
printf("horde\n");
else if(n < 250)
printf("throng\n");
else if(n < 500)
printf("swarm\n");
else if(n < 1000)
printf("zounds\n");
else
printf("legion\n");

return 0;
} 

Q - Circle

#include <stdio.h>
#include <math.h>
int main()
{
double r,s,c,area;
int t,i;

scanf("%d", &t);

for (i = 1; i <= t; i++) {
scanf("%lf", &r);
c=2*acos(0.0)*r*r;
s=(2*r)*(2*r);
area=s-c;

printf("Case %d: %.2lf\n",i, area);
}
     return 0;


}

R - Reverse

#include<stdio.h>
int main() {
 int T, n,a;
 scanf("%d",&T);
 for (a=1;a<=T;a++)
    {
  scanf("%d",&n);
  if (n > 10) {
   printf("%d %d\n",(n - 10),(n - (n - 10)));
  }
  else {
   printf("0 %d\n",n);
  }
 }
 return 0;

}


S - Physician

#include<stdio.h>
int main()
{
    int n, x, y, z, xsum=0, ysum=0, zsum=0;
    scanf("%d",&n);

    while (n--)
    {
        scanf("%d %d %d",&x,&y,&z);
        xsum=xsum+x;
        ysum=ysum+y;
        zsum=zsum+z;
    }

    if (xsum==0&&ysum==0&&zsum==0)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}

T - DIstinct

 #include<stdio.h>

int main()
{
    int y,a,b,c,d;
    scanf("%d",&y);
    while(1)
    {
        y=y+1;
        a=y/1000;
        b=y/100%10;
        c=y/10%10;
        d=y%10;
        if (a!=b&&a!=c&&a!=d&&b!=c&&b!=d&&c!=d)
        {
            break;
        }
    }
    printf("%d\n",y);
    return 0;
}


U - Limak and Bob

 #include<stdio.h>
int main()
{
    int a,b,c=1;
    scanf("%d %d",&a,&b);
    while(1){
        a=a*3;
        b=b*2;
        if(a>b){
            break;
            }
            c++;
    }
    printf("%d\n",c);
    return 0;
}

V - Woh Woc

#include <stdio.h>
int main() {
    int T,t,m,x,y,x1,x2,y1,y2,i;
    scanf("%d",&T);
    for(t=1;t<=T;t++) {

        scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
        printf("Case %d:\n",t);
        scanf("%d",&m);
        for(i=0; i<m; i++) {
            scanf("%d %d",&x,&y);

            if(x>x1&&x<x2&&y>y1&&y<y2){
                printf("Yes\n");
                }
            else{

             printf("No\n");
        }
    }
}
return 0;
}


W - Grading Students

 #include <stdio.h>
int main()
{
    int n,a[60],i,d,e;
    scanf("%d",&n);
    for(i=0;i<n; i++){
        scanf("%d",&a[i]);
        if(a[i]>=38){
            d=(a[i]/5)+1;
            e=d*5;
            if(e-a[i]<3)
                printf("%d\n",e);
            else
                printf("%d\n",a[i]);

        }
        else
            printf("%d\n",a[i]);
    }
    return 0;
}

X - Even Odds

#include <stdio.h>
int main()
{
    long long n, k;
    scanf("%lld %lld",&n,&k);
    if (k<=(n+1)/2)
    {
        printf("%lld\n",(k*2)-1);
    }
    else
    {
        printf("%lld\n",(k-(n+1)/2)*2);
    }
    return 0;

}


Y - Mishka and Game

#include <stdio.h>
int main() {
    int a,c, n, m, mis, chr;
    scanf("%d",&n);
    for(c= 0;c<n;c++){
        scanf("%d %d",&a,&m);
        if (a > m) {
            mis++;
        } else if(a < m) {
            chr++;
        }
    }
    if (mis > chr) {
        printf("Mishka\n");
    } else if (chr > mis) {
         printf("Chris\n");
    } else {
        printf("Friendship is magic!^^\n");
    }
    return 0;

}


Z - World cup

#include<stdio.h>
int main()
{
    int T,X,Y,a;
    scanf("%d",&T);
    for(a=1;a<=T;a++){
        scanf("%d %d",&X,&Y);
        if(X>Y){
            printf("Bashar\n");
        }
        else if(Y>X){
            printf("Hamada\n");
        }
        else if(X==Y){
            printf("Iskandar\n");
        }
    }
    return 0;
}

Comments

Popular posts from this blog

Shamim Sir Lap Report 2

1) WAP to accept any character from user and display its ASCII number on  screen. Ans: #include<stdio.h> void main() { char s; printf("Input the character here: "); scanf("%c",&s); printf("The ASCII of this Character: %d",s); } 2) WAP to input any ASCII number and display appropriate character on screen. Ans: #include<stdio.h> void main() { int s; printf("Input the ASCII number here: "); scanf("%d",&s); printf("The Character of ASCII:%c",s); } 3) WAP to input any Capital letter and display it with small letter. Ans: #include<stdio.h> void main() { char s; printf("Enter the Capital letter here :"); scanf("%c",&s); printf("the small letter is: %c", s+32); } 4) WAP to input any Small letter and display it with capital letter. Ans: #include<stdio.h> void main() { char s...

URI Online Judge | 1001

Extremely Basic Read 2 variables, named  A  and  B  and make the sum of these two variables, assigning its result to the variable  X . Print  X  as shown below. Print endline after the result otherwise you will get “ Presentation Error ”. Input The input file will contain 2 integer numbers. Output Print the letter  X  (uppercase) with a blank space before and after the equal signal followed by the value of X, according to the following example. Obs.: don't forget the endline after all. Samples Input Samples Output 10 9 X = 19 -10 4 X = -6 ANS: #include<stdio.h> int main() { int A,B,X; scanf("%d %d",&A,&B); X=A+B; printf("X = %d\n",X); return 0; }