ACM思维题训练集合

There is a board with a grid consisting of n rows and m columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number i and column number j as (i, j).

A group of six numbers (a, b, c, d, x0, y0), where 0 ≤ a, b, c, d, is a cross, and there is a set of cells that are assigned to it. Cell (x, y) belongs to this set if at least one of two conditions are fulfilled:

|x0 - x| ≤ a and |y0 - y| ≤ b

|x0 - x| ≤ c and |y0 - y| ≤ d

The picture shows the cross (0, 1, 1, 0, 2, 3) on the grid 3 × 4.

Your task is to find the number of different groups of six numbers, (a, b, c, d, x0, y0) that determine the crosses of an area equal to s, which are placed entirely on the grid. The cross is placed entirely on the grid, if any of its cells is in the range of the grid (that is for each cell (x, y) of the cross 1 ≤ x ≤ n; 1 ≤ y ≤ m holds). The area of the cross is the number of cells it has.

Note that two crosses are considered distinct if the ordered groups of six numbers that denote them are distinct, even if these crosses coincide as sets of points.

Input

The input consists of a single line containing three integers n, m and s (1 ≤ n, m ≤ 500, 1 ≤ s ≤ n·m). The integers are separated by a space.

Output

Print a single integer — the number of distinct groups of six integers that denote crosses with area s and that are fully placed on the n × m grid.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

2 2 1

Output

4

Input

3 4 5

Output

4

Note

In the first sample the sought groups of six numbers are: (0, 0, 0, 0, 1, 1), (0, 0, 0, 0, 1, 2), (0, 0, 0, 0, 2, 1), (0, 0, 0, 0, 2, 2).

In the second sample the sought groups of six numbers are: (0, 1, 1, 0, 2, 2), (0, 1, 1, 0, 2, 3), (1, 0, 0, 1, 2, 2), (1, 0, 0, 1, 2, 3).

这个题我就贴个代码吧,从10.00多做到了2.00多还没读懂这题要干什么,花了无数张图,题解我都看了,我真的不知道这个题的意思,还做个屁呀。

#include <bits/stdc++.h>
using namespace std;
int n, m, s, r;
long long f(int h, int w) { return (n - h + 1) * (m - w + 1); }
long long ans;
int main()
{
scanf("%d%d%d", &n, &m, &s);
ans = 0;44
for (int i = 1; i <= n; i += 2)
{
for (int j = 1; j <= m && (r = s - i * j) >= 0; j += 2)
{
if (r == 0)
{
ans += ((i + 1) * (j + 1) / 2 - 1) * f(i, j);
}
else
for (int k = 1; k < j; k += 2)
if (r % (2 * k) == 0 && i + r / k <= n)
ans += 2 * f(i + r / k, j);
}
}
cout << ans << endl;
return 0;
}

CF--思维练习-- CodeForces - 215C - Crosses(思维题)的更多相关文章

  1. cf 443 D. Teams Formation](细节模拟题)

    cf 443 D. Teams Formation(细节模拟题) 题意: 给出一个长为\(n\)的序列,重复\(m\)次形成一个新的序列,动态消除所有k个连续相同的数字,问最后会剩下多少个数(题目保证 ...

  2. codeforces 407 div1 B题(Weird journey)

    codeforces 407 div1 B题(Weird journey) 传送门 题意: 给出一张图,n个点m条路径,一条好的路径定义为只有2条路径经过1次,m-2条路径经过2次,图中存在自环.问满 ...

  3. codeforces 407 div1 A题(Functions again)

    codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on ...

  4. 什么是老板思维,什么是员工思维,深有体会,最近被N个行业洗脑……

    什么是老板思维,什么是员工思维,深有体会,最近被N个行业洗脑……

  5. 2个快速制作完成一幅思维导图的iMindMap思维导图用法

    随着思维导图的流行,与其相关的思维导图制作软件如雨后春笋,纷纷进入我们的视野中,更让人难以选择.那想要入门的萌新该如何开始这个新的旅途呢? 各式各样的思维导图制作软件当中,有一个软件得到了大家一致的好 ...

  6. cf A. Inna and Pink Pony(思维题)

    题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题, ...

  7. CF思维联系--CodeForces - 218C E - Ice Skating (并查集)

    题目地址:24道CF的DIv2 CD题有兴趣可以做一下. ACM思维题训练集合 Bajtek is learning to skate on ice. He's a beginner, so his ...

  8. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

  9. CF思维联系– CodeForces - 991C Candies(二分)

    ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal am ...

随机推荐

  1. PAT 链表倒序的算法优化

    之前的答案错误问题已经解决了,现在还有运行超时的问题,先贴上之前的代码 1 #include <iostream> 2 #include <string.h> 3 using ...

  2. Golang Web入门(1):自顶向下理解Http服务器

    摘要 由于Golang优秀的并发处理,很多公司使用Golang编写微服务.对于Golang来说,只需要短短几行代码就可以实现一个简单的Http服务器.加上Golang的协程,这个服务器可以拥有极高的性 ...

  3. RESTful API设计的点

    RESTful API 前言 一直在使用RESTful API,但是好像概念还是很模糊的,总结下使用到的点 设计的规范 协议 API与用户的通信协议,总是使用HTTPs协议. 域名 应该尽量将API部 ...

  4. 《MySQL实战45讲》学习笔记4——MySQL中InnoDB的索引

    索引是在存储引擎层实现的,且在 MySQL 不同存储引擎中的实现也不同,本篇文章介绍的是 MySQL 的 InnoDB 的索引. 下文将以这张表为例开展. # 创建一个主键为 id 的表,表中有字段 ...

  5. Linux C++ 网络编程学习系列(4)——多路IO之epoll基础

    epoll实现多路IO 源码地址:https://github.com/whuwzp/linuxc/tree/master/epoll 源码说明: server.cpp: 监听127.1:6666,功 ...

  6. Css3 新增的属性以及使用

    Css3基础操作 . Css3? css3事css的最新版本 width. heith.background.border**都是属于css2.1CSS3会保留之前 CSS2.1的内容,只是添加了一些 ...

  7. unity3d之简单动画

    Unity3d中有两个关于动画的概念,Animation和Animator,看一下他们的创建和区别 1.创建一个物体后可以添加Animator和Animation组件如图所示 2.Animation和 ...

  8. stand up meeting 12-2

    今天因为各位组员组里项目原因没有集中在一起进行stand up meeting.但是士杰和天赋国庆分别对项目进度和前后端的结合进行的沟通. 针对后端部分,天赋完成了GetRankingData API ...

  9. reactnavigation 5.x简单例子

    随着RN和reactnavigation的版本更新,网上很多老版的例子都不能用了. 自己摸索着跑通了一些简单的功能. 使用的是最新的    "react-native": &quo ...

  10. C语言二维数组超细讲解

    用一维数组处理二维表格,实际是可行的,但是会很复杂,特别是遇到二维表格的输入.处理和输出. 在你绞尽脑汁的时候,二维数组(一维数组的大哥)像电视剧里救美的英雄一样显现在你的面前,初识数组的朋友们还等什 ...