EOJ Monthly 2017.12
来源:互联网 发布:淘宝网的赌石是真的吗 编辑:程序博客网 时间:2024/06/05 02:48
B. 在哈尔滨的寒风中
Time limit per test: 1.0 seconds
Memory limit: 256 megabytes
kblack 来到了寒冬中的哈尔滨,哈尔滨的寒风令 kblack 瑟瑟发抖。
世界上最远的距离,是你与宾馆只差一条冰街,而你却忘了穿上秋裤。
kblack 终于冲进了宾馆,宾馆大厅的地板铺满了五颜六色的地砖,可以被看作是一块
kblack 居然想知道有多少对地砖(无序点对)他可以通过若干步马步互相抵达!
Input
输入包含一行两个正整数
Output
输出包含一个整数,表示 kblack 可以通过马步互相到达的无序地砖对数。
Examples
input
1 2
output
0
input
4 2
output
4
n=1 2 3 4 m= 1 2 3 4
就能发现规律。
先让n<=m。
当n>=3时,全部可以走到,就是c(n*m,2),特殊的有n=3,m=3.
当n==2时,答案也可以计算出来。
当n==1时,为0 。
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;#define LL long longconst int maxn = 1e5+55;int main(){int n,m;scanf("%d %d",&n,&m);if(n>m) swap(n, m);if(n==1){printf("0\n");//}else if(n==2&&m==3){//printf("2\n");//}else if (n==2&&m==4){//printf("4\n");}else if(n==2){LL a=1LL*(m+1)/2;LL b=1LL*m/2;printf("%lld\n",a*(a-1)+b*(b-1));}else if(n==3&m==3){printf("28\n");}else{LL x=1LL*n;LL y=1LL*m;printf("%lld\n",(x*y)*(x*y-1)/2);}}
阅读全文
0 0
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12
- EOJ Monthly 2017.12 A+B+C
- EOJ Monthly 2017.12 (暨 ECNU 12 月内部选拔)
- EOJ Monthly 2017.12 A. 唐纳德先生和假骰子
- EOJ Monthly 2017.12 G1. 唐纳德与子串 (Easy)
- EOJ Monthly 2017.12 C题 3451. 易位构词 题解
- EOJ Monthly 2017.12 B. 在哈尔滨的寒风中(规律)
- EOJ Monthly 2017.12 C.易位构词 (anagram)(模拟)
- EOJ Monthly 2017.12 题解 3449. 唐纳德和他的数学老师
- EOJ Monthly 2017.12 (暨 ECNU 12 月内部选拔) 题解
- EOJ Monthly 2017.12 (暨 ECNU 12 月内部选拔)G1. 唐纳德与子串 (Easy)
- EOJ Monthly 2017.12 (暨 ECNU 12 月内部选拔)B. 在哈尔滨的寒风中 (xjbg)
- 高斯函数以及在图像处理中的应用总结
- hexo yilia主题的所有文章功能不能用
- 图片旋转
- PAT (Basic Level) Practise (中文) 1075. 链表元素分类(25)
- 虚幻4菜单编辑蓝图笔记
- EOJ Monthly 2017.12
- BZOJ1088
- 用notepad++书写java,编译java程序是出现:错误: 编码GBK的不可映射字符问题的解决
- Cannot complete the request. This installation has not been configured properly for softWare Updat
- MYSQL性能优化的最佳20+条经验
- 剑指offer—字符串中第一次只出现一次的字符
- 【SpringBoot】2小时学会SpringBoot学习笔记(第4章 Controller的使用)
- wordcount
- C++实现AES的S-box