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. GlusterFS 4.1 版本选择和部署

    GlusterFS 4.1 版本选择和部署 目录 GlusterFS 4.1 版本选择和部署 1 前言相关 1.1 glusterfs优势 1.2 版本选择 1.3 volume知识 2 服务部署 2 ...

  2. (js描述的)数据结构[树结构1.2](12)

    1.先序遍历 2.中序遍历 3.后序遍历 4.递归调用栈详解: 详细见: https://zhuanlan.zhihu.com/p/24291978 5.删除节点操作分析: 5.代码封装 //封装二叉 ...

  3. Java第二十八天,Lambda表达式

    一.函数式编程 1.什么是函数式编程 函数式编程是种编程方式,是一种编程的思维,它属于"结构化编程"的一种,主要思想是把运算过程尽量写成一系列嵌套的函数调用.它的地位等同于面向对象 ...

  4. Linux服务器架设篇,Windows中的虚拟机linux上不了外网怎么办?

    1.将电脑的网线口直连路由器内网接口(确保该路由器可以直接正常上网,切记不可以使用宽带连接和无线网连接). 2.在实体机电脑可以上网的前提下,在命令框窗口输入 ipconfig 3.记录下电脑以太网的 ...

  5. C语言 文件操作(五)

    (1)size_t fread ( void * ptr, size_t size, size_t count, FILE * stream ); 其中,ptr:指向保存结果的指针:size:每个数据 ...

  6. python10

     一.多进程multiprocessing multiprocessing包是Python中的多进程管理包.与threading.Thread类似,它可以利用multiprocessing.Proce ...

  7. 29.2 Iterator 迭代器ConcurrentModificationException:并发修改异常处理

    /** Iterator:迭代器* * 需求:判断集合中是否包含元素java,如果有则添加元素android * Exception in thread "main" java.u ...

  8. Linux c++ vim环境搭建系列(3)——Ubuntu18.04.4编译安装youcompleteme

    3. youcompleteme编译安装 参考网址: https://github.com/ycm-core/YouCompleteMe#linux-64-bit 建议不要用这个博客的方法: http ...

  9. iOS获取剩余存储空间

    //ios获取剩余存储空间 -(void)usedSpaceAndfreeSpace{ NSString* path = [NSSearchPathForDirectoriesInDomains(NS ...

  10. [译]使用开发工具来调试 Beta 版 WebView

    自2014年以来,Android WebView 已经作为一个可更新的系统组件铺平了道路,为 Android 应用程序和用户提供了稳定性和性能改进.现代网络平台功能和安全补丁. 然而,更新可能是一把双 ...