My code looks like this:
#include <stdio.h>
int main()
{
unsigned long int L, N;
scanf("%lu%lu", &L, &N);
printf("%lu\n", (L-(N-1))*(L-(N-1)) + (N-1));
return 0;
}
When the test case has low numbers, the program works. However, when the numbers are beyond the capacity of unsigned long int
, with entries like 1,000,000 and 9 (the correct answer would be 999984000072) the program gives the wrong answer.
How can I operate with larger integers?