Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Created February 17, 2014 07:51
Show Gist options
  • Save KT-Yeh/9046470 to your computer and use it in GitHub Desktop.
Save KT-Yeh/9046470 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
long long a,b;
while (scanf("%lld%lld",&a,&b)){
if (!a && !b) break;
if (a > b) swap(a,b); // a:寬 b:長
long long ans = a*b*(a-1) + a*b*(b-1); //寬 + 長
ans += 4* (2*(a*(a-1)*(a-2)/6) + (b-a+1)*a*(a-1)/2); // 對角線
printf("%lld\n",ans);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment