Project Euler #228: Minkowski Sums

  • + 0 comments

    i got through the sample test cases just with this code -_- i know its not the logic but i just used image explanation to formulate the idea.

    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <stdlib.h>
    
    int main() {
    
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
        unsigned long n,a,b;
        unsigned long sum=0;
        scanf("%lu",&n);
        for(unsigned long i=0;i<n;i++)
        {
            scanf("%lu %lu",&a,&b);
      
            for(unsigned long j=a;j<=b;j++)
            {
                sum+=j;
            }
            printf("%lu",(sum-(b-a)));
        }
        return 0;
    }