http://acm.hust.edu.cn/problem/show/1698

题目就是要把一个数n分成4段,其中中间两段一定要是奇数。

问有多少种情况。

分类,

奇数 + 奇数 + 奇数 + 奇数

奇数 + 奇数 + 奇数 + 偶数

偶数 + 奇数 + 奇数 + 奇数

偶数 + 奇数 + 奇数 + 偶数

注意看看能否拆成这样的形式,比如x是奇数的话,最后一种就没可能拆成了。

然后奇数表达成 2 * a - 1这个样子,就能列出方程。

然后就是类似于解a1 + a2 + a3 + a4 = x的问题了。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
LL C(LL n, LL m) {
if (n < m) return ; //防止sb地在循环
if (n == m) return ; //C(0,0)也是1的
LL ans = ;
LL mx = max(n - m, m); //这个也是必要的。能约就约最大
LL mi = n - mx;
for (int i = ; i <= mi; ++i) {
ans = ans * (mx + i) / i;
}
return ans;
} void work() {
int n;
scanf("%d", &n);
LL ans = ;
if ((n + ) % == ) ans += C((n + ) / - , );
if ((n + ) % == ) ans += C((n + ) / - , ) * ;
if ((n + ) % == ) ans += C((n + ) / - , );
static int f = ;
printf("Case #%d: %lld\n", ++f, ans);
} int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
int t;
scanf("%d", &t);
while (t--) work();
return ;
}

最新文章

  1. 百度上传工具webuploader,图片上传附加参数
  2. English Training Material - 02
  3. JS中的call()方法的理解
  4. 如何处理JSON中的特殊字符
  5. android92 aidl远程进程通信
  6. android 项目中使用对话框统一封装
  7. Scope and Namespace
  8. opencv----(1) mat最好用,和IplImage,cvmat 比较
  9. EQueue - 一个C#写的开源分布式消息队列的总体介绍(转)
  10. 【Android Developers Training】 34. 添加一个简单的分享行为(Action)
  11. CentOS6.9编译安装nginx1.4.7
  12. BZOJ 3938 Robot
  13. linux 常见技巧
  14. 用C++实现半透明按钮控件(PNG,GDI+)
  15. 性能测试八:jmeter进阶之beanshell
  16. DedeCMS织梦文章页图片地址为绝对路径实现方法
  17. sql语句实战
  18. 黑镜第一至二季/全集Black Mirror迅雷下载
  19. R语言使用tryCatch进行简单的错误处理
  20. Express开发性能优化

热门文章

  1. dva/dynamic
  2. Struts2之struts2标签库了解和使用
  3. POJ训练计划2299_Ultra-QuickSort(线段树/单点更新)
  4. spring实战笔记6---springMVC的请求过程
  5. 浅谈JavaScript的字符串的replace方法
  6. 刚刚做了个文件上传功能,拿来分享一下!(MVC架构及传统架构通用)
  7. 堆排序C++实现
  8. DBENV-&gt;open
  9. VCL代码的一些设计手法(使用OO虚函数的技巧)
  10. openwrt 设置samba服务器与pc共享文件