这题不难,我写的一个复杂度 $ O(n^2) $ 的递归算法。。

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define index(a) (a - 'A')
#define transUpp(a) (a - 32)
#define transLow(a) (a + 32)
#define ll long long
#define PB push_back
int gcd(int a, int b){return b == 0 ? a : gcd(a%b, a);}
const int N = 782;
int num[N] = { 6,2,5,5,4,5,6,3,7,6 }, has[N][N];
int counts = 0;
void re(int n, int l1, int l2)
{
if (l1 + l2 < N)
{
has[l1][l2] = 1;
if (n == num[l1] + num[l2] + num[l1 + l2]) counts++;
if (!has[l1][l2 + 1]) re(n, l1, l2 + 1);
if (!has[l1 + 1][l2]) re(n, l1 + 1, l2);
}
}
int main()
{
// rep(i, 0, N) rep(j, 0, N) has[i][j] = 0; // 去掉这行初始化,投机优化一点速度
for (int k = 10; k < N; k++)
num[k] = num[k%10] + num[k/10];
int n;
cin >> n;
re(n - 4, 0, 0);
cout << counts << endl;
return 0;
}

  

  

最新文章

  1. BZOJ 4581: [Usaco2016 Open]Field Reduction
  2. URL编码:不同的操作系统、不同的浏览器、不同的网页字符集,将导致完全不同的编码结果。
  3. git学习相关资料
  4. Swift之UIBezierPath
  5. 1654 方程的解 - Wikioi
  6. windows mysql 中文乱码和中文录入提示太大错误的解决方法
  7. 2440裸 Delay(); 和 while(!(rUTRSTAT0 &amp;amp; 0x2)); 问题
  8. ZooKeeper概述
  9. CSS学习笔记一:css 画平面图形
  10. STL初始化initializer_list
  11. Hbase学习01
  12. Shell学习之Bash变量详解(二)
  13. swust oj 1015
  14. mysql awr v1.0.3修正说明以及发布
  15. kubernetes核心组件kube-proxy 学习总结
  16. openwrt git 代码下载地址
  17. jQuery表格列宽可变,兼容firfox
  18. Go语言中使用MySql数据库
  19. openvswitch BFD 简介
  20. linux下使用find命令根据系统时间查找文件用法

热门文章

  1. exists和not exists关键字
  2. java项目中的异常处理总结
  3. 命令行(二):Anaconda3
  4. JAVA Feign
  5. [前端] html限制input输入数字和小数
  6. Led Night Light Factory: Traveler Led Night Light
  7. fdssd
  8. Codeforces Round #567 (Div. 2) A.Chunga-Changa
  9. VIM学习(转)
  10. 【StarUML】时序图