cses

cses solutions in pure c
git clone git://git.superpozycja.net/cses
log | files | refs

s.c (387B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 
      4 int solve()
      5 {
      6 	unsigned long long x, y;
      7 
      8 	scanf("%llu %llu", &y, &x);
      9 
     10 	unsigned long long mx = x > y ? x : y;
     11 	unsigned long long mn = x < y ? x : y;
     12 	int sel = (mx % 2) ^ (y >= x);
     13 
     14 	printf("%llu\n", (mx - (sel)) * (mx - (sel)) + (2 * sel - 1) * (mn - 1 + (sel)));
     15 
     16 	return 0;
     17 }
     18 
     19 int main()
     20 {
     21 	int t;
     22 	scanf("%d", &t);
     23 	while (t--)
     24 		solve();
     25 }