在哈尔滨的寒风中EOJ 3461【组合数学】
http://acm.ecnu.edu.cn/problem/3461/
还是能力不够,不能看出来棋盘足够大时,马是可以到达任何位置的。还是直接看题解怎么说的吧:(http://acm.ecnu.edu.cn/blog/entry/137/)
这个2*n时交替到达我是这么理解的,本来就只有两列,应该每行对应两列上的两个位置具有的点对数相同,那么只需考虑一列上的点就好了。手动模拟一下也许就有了答案的结果。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll; ll combina(int a)
{
ll ans=;
if(a%){
ans=(a-)/;
ans*=a;
}else{
ans=a/;
ans*=(a-);
}
return ans;
} int main()
{
int n,m;
ll ans=;
while(scanf("%d%d",&n,&m)==)
{
if(n==||m==) printf("0\n");
else if(n==||m==){
if(n==){
ans=*combina(m/)+*combina(m-m/);
printf("%lld\n",ans);
}else{
ans=*combina(n/)+*combina(n-n/);
printf("%lld\n",ans);
}
}else if(n==&&m==) printf("%d\n",combina());
else{
ans=combina(n*m);
printf("%lld\n",ans);
}
}
return ;
}
在哈尔滨的寒风中EOJ 3461【组合数学】的更多相关文章
- Chapter 5 Blood Type——31
I stood carefully, and I was still fine. He held the door for me, his smile polite but his eyes mock ...
- 依赖注入【转自知乎 PHP】
第一章:小明和他的手机 从前有个人叫小明 小明有三大爱好,抽烟,喝酒…… 咳咳,不好意思,走错片场了.应该是逛知乎.玩王者农药和抢微信红包 <img src="https://pic1 ...
- HZWER
我们的征途是星辰大海 2016年3月13日8,8077 尊敬的各位老师.亲爱的同学们: 大家好,我是高三(1)班的黄哲威.今天很荣幸能和大家分享一些有关竞赛的心得体会. 去年7月15日,第32届全国信 ...
- poj 3734 Blocks 快速幂+费马小定理+组合数学
题目链接 题意:有一排砖,可以染红蓝绿黄四种不同的颜色,要求红和绿两种颜色砖的个数都是偶数,问一共有多少种方案,结果对10007取余. 题解:刚看这道题第一感觉是组合数学,正向推了一会还没等推出来队友 ...
- POJ 3461 Oulipo
E - Oulipo Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- 组合数学or not ---- n选k有重
模板问题: 1. 取物品 (comb.pas/c/cpp) [问题描述] 现在有n个物品(有可能相同),请您编程计算从中取k个有多少种不同的取法.[输入] 输入文件有两行,第一行包含两个整数n,k(2 ...
- 组合数学(全排列)+DFS CSU 1563 Lexicography
题目传送门 /* 题意:求第K个全排列 组合数学:首先,使用next_permutation 函数会超时,思路应该转变, 摘抄网上的解法如下: 假设第一位是a,不论a是什么数,axxxxxxxx一共有 ...
- POJ 3461 Oulipo(乌力波)
POJ 3461 Oulipo(乌力波) Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] The French autho ...
- uestc1888 Birthday Party 组合数学,乘法原理
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=25539#problem/G 题目意思: 有n个人,每个人有一个礼物,每个人能拿 ...
随机推荐
- 2019-8-31-C++-驱动开发-error-LNK2019-unresolved-external-symbol-__CheckForDebuggerJustMyCode-referenced-...
title author date CreateTime categories C++ 驱动开发 error LNK2019 unresolved external symbol __CheckFor ...
- kuangbin带我飞QAQ 线段树
1. HDU1166 裸线段树点修改 #include <iostream> #include <string.h> #include <cstdio> #incl ...
- [Array]628. Maximum Product of Three Numbers
Given an integer array, find three numbers whose product is maximum and output the maximum product. ...
- bzoj 4373 算术天才⑨与等差数列——线段树+set
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4373 能形成公差为k的等差数列的条件:mx-mn=k*(r-l) && 差分 ...
- TZ_11_Spring-Boot的属性注入方式(jdbc为例)
1.以上一篇文档为基础 2.创建jdbc外部属性文件 application.properties此名字为默认文件名在使用是不需要使用 @Propertysource("classpath: ...
- phpstudy安装好之后mysql无法启动(亲测可行)
安装好phpstudy后,Apache可以启动,Mysql无法启动. 尝试解决办法:可能是之前已经装过Mysql,要把系统服务里面的MySQL删除,留下MySQLa服务. 在cmd命令行下输入:sc ...
- jnhs中国的省市县区邮编坐标mysql数据表
https://blog.csdn.net/sln2432713617/article/details/79412896 -- 1.之前项目中需要全国的省市区数据,在网上找了很多,发现数据要么不全,要 ...
- input只能输入数字和小数点,并且只能保留小数点后两位 - CSDN博客
1.给文本框添加一个onkeyup=’clearNoNum(this)’点击事件 2.建立clearNoNum方法 function clearNoNum(obj) { obj.value = obj ...
- django中模型
一.django需要使用数据库,则需要安装对应的驱动,比如mysql,则需要安装mysqlclient驱动: pip install mysqlclient 二.在settings.py文件中配置数据 ...
- Django项目:CRM(客户关系管理系统)--01--01PerfectCRM基本配置ADMIN01
一.CRM项目需求 二.CRM项目新建 PerfectCRM crm