链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2533
三个方向, 横,竖,对角线~
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int main() 6 { 7 long long int n,m; 8 while(scanf("%lld%lld",&n,&m)!=EOF&&n&&m) 9 { 10 if(n>m) 11 swap(n,m); 12 long long int ans=(n-1)*n*m + (m-1)*m*n + 2*n*(n-1)*(m-n+1); 13 ans+=2*2*(n-2)*(n-1)*(n)/3; 14 printf("%lld ",ans); 15 } 16 return 0; 17 }