Friday, 18 March 2016

Solution of URI 1132 :: Multiples of 13


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=0,x;
    scanf("%d%d", &a, &b);
    if(a<b)
    {
        for(x=a; x<=b; x++)
        {
            if(x%13==0) continue;
            c+=x;
        }
    }
    else if(a>b)
    {
        for(x=b; x<=a; x++)
        {
            if(x%13==0) continue;
            c+=x;
        }
    }
    printf("%d\n",c);
    return 0;
}

1 comment:

  1. #include
    int main(){
    int x,y,i,sum;
    while (1)
    {
    scanf("%d\n%d",&x,&y);
    for (i=x;i<=y;i++)
    if(i%13!=0)
    sum+=i;
    printf("%d\n",sum);

    }
    return 0;
    }



    time limit error!!! why???

    ReplyDelete

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