BNUOJ---E. Rectangle

E. Rectangle

Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format: %lld      Java class name: Main
题意:给定矩形的最大周长,求长n宽m中所含满足要求的矩形的个数:
思路:矩形的性质:(对边相等)枚举k/2的半周长,代码如下;
frog has a piece of paper divided into n rows and m columns. Today, she would like to draw a rectangle whose perimeter is not greater than k .
 
 
There are 8 (out of 9 ) ways when n=m=2,k=6
 
Find the number of ways of drawing.

Input

The input consists of multiple tests. For each test:
 
The first line contains 3 integer n,m,k ( 1n,m5104,0k109 ).

Output

For each test, write 1 integer which denotes the number of ways of drawing.

Sample Input

2 2 6
1 1 0
50000 50000 1000000000

Sample Output

8
0
1562562500625000000
Submit Status

#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;

int main()
{
   LL n,m,k;
   LL ans;
   LL y;
   while(~scanf("%lld%lld%lld",&n,&m,&k))
   {
       ans=0;
       LL l=k/2;
       LL tmp;
       for(LL i=1;i<=n&&i<=l;i++)
       {
            y=min(l-i,m);
            tmp=(m+1-y+m)*(y)/2;
           ans+=tmp*(n+1-i);
       }
       printf("%lld\n",ans);
   }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值