给一个n*m的方格,求周长小于等于k的矩形有多少个。
简单的思考题。
代码:
  #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <set> #include <vector> #include <map> #include <queue> #include <set> #include <algorithm> #include <limits> using namespace std; typedef long long LL; const LL LL_INF=numeric_limits<LL>::max(); LL n,m,k; int main() {          while(~scanf("%lld%lld%lld",&n,&m,&k)){         LL ans=0;         for(LL x=1;x<=n;x++){             LL tmax=(k-2*x)/2;             if(tmax>0){                 if(tmax>=m)tmax=m;                 if(tmax%2==0){                     ans+=(n-x+1)*(m+m-tmax+1)*(tmax/2);                 }                 else {                     ans+=(n-x+1)*((m+m-tmax+1)/2)*tmax;                 }                                               }         }         printf("%lld\n",ans);     }     return 0; }
 
 
  |