Tuesday 26 January 2016

Solution of URI 1035 :: Selection Test 1


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int A, B, C, D;
    scanf ("%d%d%d%d", &A,&B,&C,&D);
    if(B>C && D>A && C+D>A+B && C>=0 && D>=0 && A%2==0)
        printf("Valores aceitos\n");
    else
        printf ("Valores nao aceitos\n");
    return 0;
}

2 comments:

  1. i also gave the same logic, but uri showed wrong answer, why??

    ReplyDelete
  2. wrong answer 20%, for what?

    #include

    int main (){

    int A, B, C, D;

    scanf ("%d %d %d %d",&A, &B, &C, &D);

    if( (D-A>B-C) && (C>=0) && (D>=0) && (A%2==0) ){
    printf ("Valores aceitos\n");
    }else{
    printf ("Valores nao aceitos\n");
    }
    return 0;
    }

    ReplyDelete

Note: only a member of this blog may post a comment.