#include <stdio.h>int numOfDigits, base;
int result;void isValid(int digits, int preDigit){if (digits > numOfDigits){result++;return;}int digit;for (digit = 0; digit < base; digit++){if (preDigit == 0 && digit == 0)//剪枝后可以通过continue;isValid(digits + 1, digit);}
}int main(){scanf("%d %d", &numOfDigits, &base);isValid(1, 0);printf("%d\n", result);return 0;
}

URAL 1009 K-based Numbers (DFS)相关推荐

  1. ural 1009 K-based Numbers

     1009. K-based Numbers Time limit: 1.0 second Memory limit: 64 MB Let's consider K-based numbers, ...

  2. ural 1009. K-based Numbers - dp

    1009. K-based Numbers Let's consider K-based numbers, containing exactlyN digits. We define a number ...

  3. 51nod 1268 和为K的组合 dfs

    题目: 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使他们的和为K.如果可以,输出:& ...

  4. 2412 - 和为K ---深搜dfs剪枝

    **2412 - 和为K ---深搜dfs优化 **来源:东方博宜oj oj.czos.cn #include<bits/stdc++.h> using namespace std; co ...

  5. Ural 1009 K-based Numbers

    1009. K-based Numbers Time limit: 0.5 second Memory limit: 64 MB Let's considerK-based numbers, cont ...

  6. URAL 1009. K-based Numbers

    /*这题貌似就是找规律. f1 = k-1; f2 = k*k - k; f3 = (f1 + f2) * (k-1); //(k-1)表示首位不为0的个数,比如n = 3时, 首位可能是1, 2, ...

  7. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs

    C. Hexadecimal's Numbers 题目连接: http://www.codeforces.com/contest/9/problem/C Description One beautif ...

  8. HDU多校6 - 6831 Fragrant numbers(dfs爆搜+打表)

    题目链接:点击查看 题目大意:给出一个以 " 1145141919 " 无限循环的字符串,现在可以在合适的位置添加 ' + ' , ' * ' 和 ' ( ' , ' ) ' 将其 ...

  9. LeetCode Lexicographical Numbers(dfs)

    问题:给出一个正整数n,要求从 1 到 n 的字典顺序 思路:深度优先搜索.如果当前数为0,则从1到9遍历加上当前数*10,进入下一层深度,否则从0到9遍历.如果当前的数大于n,递归退出. 具体代码参 ...

最新文章

  1. 从ORA-27300,ORA-27301到ORA-00064
  2. [附加题] 结对项目对接的苦痛
  3. [译] Service workers:PWA应用背后的英雄
  4. 软件开发质量控制-CMMI读后疑问
  5. 课时67.标签选择器(掌握)
  6. 容器编排技术 -- Kubernetes kubectl rollout history 命令详解
  7. HBase从入门到精通系列:误删数据如何抢救?
  8. Spring RestController
  9. docker 安装最新mysql
  10. linux打开dwg格式文件怎么打开软件,DWG 文件扩展名: 它是什么以及如何打开它?...
  11. 【Beyond Compare】秘钥到期解决方法
  12. 15分钟快速搭建属于自己的网站
  13. 一个HTTP打趴80%面试者
  14. POJ - 3311 Hie with the Pie
  15. jquery获取元素索引值index()
  16. 李峋的爱心表白代码来了
  17. Scala的下载与安装
  18. 新一届学生必备神器——讯飞腕式录音笔R1
  19. 罗技 连点 脚本_罗技发布无线版的Pro X游戏耳机,拥有20小时续航时间
  20. CRM百科 | CRM是什么?

热门文章

  1. 为uni-cloud(Dcloud国产之辉)声明!
  2. 医疗云计算才是真有料 大数据如何给中国医学史加一副药
  3. geojson转为esrijson
  4. Speedoffice(word)文档中如何添加评论
  5. VB计算两个日期/时间之间的差(DateDiff函数)
  6. python毕业设计作品基于django框架 图片分享平台毕设成品(4)开题报告
  7. MIT JOS LAB3学习笔记
  8. selenium搜狗搜图简单操作(爬取任意关键字的图片)
  9. RE入门之脱壳——手脱UPX壳
  10. 2022年IEEE Fellow名单正式公布,清华教授、阿里云李飞飞等73位华人上榜