ACM: SCU 4440 Rectangle - 暴力

  SCU 4440 Rectangle
Time Limit:0MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

Description

Rectangle

frog has a piece of paper divided into nn rows and mm columns. Today, she would like to draw a rectangle whose perimeter is not greater than kk.

There are 8 (out of 9) ways when n = m = 2, k = 6

There are 88 (out of 99) ways when n=m=2,k=6n=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 33 integer n,m,kn,m,k (1n,m5104,0k1091≤n,m≤5⋅104,0≤k≤109).

Output

For each test, write 11 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
  
  一开始以为是dp,但是数据会爆掉,然后放在一边了。。
  后来其他题目不会写了后,回过来想这题,想了好久是暴力还是数学计算。。
  虽然最后用的是暴力加数学计算。。。
  单纯暴力坑定会超时,仔细想了下,可以暴力去枚举一条边,再去考虑另一条的具体情况。
最后在模拟另一条边的情况的时候推算要注意一点。
  
  AC代码:
#include"algorithm"
#include"iostream"
#include"cstring"
#include"cstdlib"
#include"cstdio"
#include"string"
#include"vector"
#include"queue"
#include"cmath"
#include"map"
using namespace std;
typedef long long LL ;
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define FK(x) cout<<"["<<x<<"]\n"
#define bigfor(T)  for(int qq=1;qq<= T ;qq++)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1

int main() {
	LL n,m,k;
	while(cin>>n>>m>>k) {
		k>>=1;
		LL ans = 0;
		for(int i=1; i<=n&&k-i>0; i++) {
			LL x=min(k-i,m);
			LL a=n-i+1;
			LL b=(m+m-x+1)*x/2;
			ans+=a*b;
		}
		cout<<ans<<endl;
	}
	return 0;
}

  





转载于:https://www.cnblogs.com/HDMaxfun/p/5782073.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值