Header Ads

Header ADS

Solution of URI 1132::Multiples of 13

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.





#include <stdio.h>

int main()
{
    int i,X,Y,small,big;
    long long int sum=0;

    while(scanf("%d%d",&X,&Y) !=EOF) {

            small=X<Y? X:Y;
            big=X>Y? X:Y;

            for(i=small;i<=big;i++) {
        if(i%13 !=0) {
            sum+=i;
        }
      }
      printf("%lld\n",sum);
      sum=0;
   }

    return 0;
}

No comments

Theme images by konradlew. Powered by Blogger.