题目背景

1997年普及组第一题

题目描述

有一个n*m方格的棋盘,求其方格包含多少正方形、长方形

输入输出格式

输入格式:

n,m因为原来数据太弱,现规定m小于等于5000,n小于等于5000(原来是100,100)

输出格式:

方格包含多少正方形、长方形

输入输出样例

输入样例#1:

2 3
输出样例#1:

8 10

计算矩形中小矩形个数公式:(((1+n)*(1+m))*(n*m))/4;
注:n,m为其边长,个数中仍包含有特殊矩形(正方形);
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
long long n,m;
long long ans1=,ans2=;
cin>>n>>m;
ans1=n*m;
long long p=(((+n)*(+m))*(n*m))/;
while(n--&&m--)
{
ans1+=(n*m);
}
cout<<ans1<<" "<<p-ans1;
}
 

luogu P2241 统计方形的更多相关文章

  1. 洛谷——P2241 统计方形(数据加强版)

    https://www.luogu.org/problem/show?pid=2241 题目背景 1997年普及组第一题 题目描述 有一个n*m方格的棋盘,求其方格包含多少正方形.长方形 输入输出格式 ...

  2. 洛谷 P2241统计方形(数据加强版) 题解

    题目传送门 说是加强版,其实可以把棋盘那道题的代码粘过来(注意要开long long): #include<bits/stdc++.h> using namespace std; ,c; ...

  3. P2241 统计方形(数据加强版)

    题目背景 1997年普及组第一题 题目描述 有一个n*m方格的棋盘,求其方格包含多少正方形.长方形 输入输出格式 输入格式: n,m因为原来数据太弱,现规定m小于等于5000,n小于等于5000(原来 ...

  4. [洛谷] P2241 统计方形(数据加强版)

    点击查看代码 #include<bits/stdc++.h> using namespace std; long long n, m, total, sum1, sum2; int mai ...

  5. 统计方形(NOIP1997)

    给链接:统计方形 这题是棋盘问题的数据加强版. 其实由于洛谷的数据比较水,所以你把我在棋盘问题题解中写的代码提交,也能AC. 但让给我们来看一个更优的解法. 先给代码: #include<bit ...

  6. luogu P1026 统计单词个数

    题目链接 luogu P1026 统计单词个数 题解 贪心的预处理母本串从i到j的最大单词数 然后dp[i][j] 表示从前i个切了k次最优解 转移显然 代码 #include<cstdio&g ...

  7. [luogu]P1026 统计单词个数[DP][字符串]

    [luogu]P1026 统计单词个数 题目描述 给出一个长度不超过200的由小写英文字母组成的字母串(约定;该字串以每行20个字母的方式输入,且保证每行一定为20个).要求将此字母串分成k份(1&l ...

  8. [Luogu] 区间统计Tallest Cow

    https://www.luogu.org/problemnew/show/P2879 差分 | 线段树 #include <iostream> #include <cstdio&g ...

  9. luogu 1026 统计单词个数

    此题 字符串匹配+dp 确实我的kmp,哈希需要练一练了,忘干净可咋办 补救用下string,十分方便 e.g: 1.询问a[i]是否是x子串,可以截取并判断前缀 x为截取串 x.find(a[i]) ...

随机推荐

  1. 模板 - 字符串 - Manacher

    求最长回文子串. #include<bits/stdc++.h> using namespace std; #define ll long long ; ]; ]; int Manache ...

  2. Codeforces711C 【DP】

    题意: 有n个点,m种颜色,你要给n个点上没有颜色的点染色.每个点i对应染的颜色j有一个颜料消耗,p[i][j]是点i染成j颜色的花费,你必须保证有k段颜色的点,输出最少花费多少颜料. 还有一个就是本 ...

  3. hdoj5301

    题意: 有一个n*m的大矩阵, 其中有一个1*1的不要的位置(x,y), 然后用若干个小矩阵去覆盖大矩阵, 不要的不能被覆盖. 问小矩阵中面积最大的面积最小是多少. 思路: 巨巨先画一个矩形,看看那个 ...

  4. python __builtins__ staticmethod类 (64)

    64.'staticmethod', 返回静态方法 class staticmethod(object) | staticmethod(function) -> method | | Conve ...

  5. two_sum问题

    def two_sum(li, target): for i in range(len(li)): for j in range(i+1, len(li)): if li[i] + li[j] == ...

  6. bzoj 5015 [Snoi2017]礼物

    题面 https://www.lydsy.com/JudgeOnline/problem.php?id=5015 题解 首先把k=1,k=2,k=3的手推一遍 然后发现一些规律 就是数列可以表示成$a ...

  7. Codeforces Round #418 (Div. 2) C

    Description Nadeko's birthday is approaching! As she decorated the room for the party, a long garlan ...

  8. 题解报告:poj 2631 Roads in the North(最长链)

    Description Building and maintaining roads among communities in the far North is an expensive busine ...

  9. CentOS 7.2最小化安装没有ifconfig命令,使用yum provides ifconfig找不到相关的包

    [root@sishen yum.repos.d]# yum provides ifconfig Loaded plugins: fastestmirror Loading mirror speeds ...

  10. 动手实现 Redux(五):不要问为什么的 reducer

    经过了这么多节的优化,我们有了一个很通用的 createStore: function createStore (state, stateChanger) { const listeners = [] ...