B-number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6444    Accepted Submission(s):
3739

Problem Description
A wqb-number, or B-number for short, is a non-negative
integer whose decimal form contains the sub- string "13" and can be divided by
13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your
task is to calculate how many wqb-numbers from 1 to n for a given integer
n.
 
Input
Process till EOF. In each line, there is one positive
integer n(1 <= n <= 1000000000).
 
Output
Print each answer in a single line.
 
Sample Input
13
100
200
1000
 
Sample Output
1
1
2
2
 
Author
wqb0039
 
Source
 
 
 

题意:找出1~n范围内含有13并且能被13整除的数字的个数

思路:http://blog.csdn.net/libin56842/article/details/10026063

#include<cstdio>
#include<iostream>
#include<cstring> using namespace std;
int dit[],f[][][]; int dfs(int pos,int mod,int have,int lim)
{
int num,ans,mod_x,have_x;
if(pos<=) return mod== && have==;
if(!lim && f[pos][mod][have]!=-) return f[pos][mod][have];
num=lim?dit[pos]:;ans=;
for(int i=;i<=num;i++)
{
mod_x=(mod*+i)%; have_x=have;
if(have== && i==) have_x=;
if(have== && i!=) have_x=;
if(have== && i==) have_x=;
ans+=dfs(pos-,mod_x,have_x,lim&&i==num);
}
if(!lim) f[pos][mod][have]=ans;
return ans;
} int main()
{
int n,len;
while(~scanf("%d",&n))
{
memset(dit,,sizeof dit);
memset(f,-,sizeof f);len=;
while(n)
{
dit[++len]=n%;
n/=;
}dit[len+]=;
printf("%d\n",dfs(len,,,));
}
return ;
}
 

最新文章

  1. 【转】 jquery遍历json数组方法
  2. Delphi 10.1 Berlin 官方未列之修正
  3. iOS--雪花掉落特效
  4. 第一天&hellip;&hellip;
  5. Fast Intro To Java Programming (1)
  6. Effective Java2读书笔记-创建和销毁对象(三)
  7. Navicat远程连接阿里云服务器的mysql
  8. Winform 实现跨线程以及Timer
  9. 一、PTA实验作业
  10. Matplotlib学习---matplotlib的一些基本用法
  11. Ubuntu下sublime-text3安装步骤
  12. 解决 login.live.com onedrive.live.com 等微软国外网站打不开问题
  13. [Python爬虫] 之三十一:Selenium +phantomjs 利用 pyquery抓取消费主张信息
  14. v-if和v-show的区别以及callback回调函数的体会
  15. 【EXCEL】SUMIF(条件を指定して数値を合計する)
  16. C#如何把日期转成YYYYMMDDHHMMSSFFF的精确到毫秒的格式?
  17. 关于\r和\n的一些问题总结
  18. AngularJs之HelloWorld
  19. STM32之VCP1/VCAP2引脚的处理
  20. POJ 1017 Packets(积累)

热门文章

  1. (转)分布式文件存储FastDFS(六)FastDFS多节点配置
  2. jmeter解决中文乱码问题
  3. 黑苹果开启retina,大分辨率的方法
  4. Typescript编译设置
  5. Git学习总结一(下载、初始化、添加文件)
  6. html 报告页面 v1.2 批量数据生成表格
  7. python第十二周:MySql
  8. 第三节:Web爬虫之BeautifulSoup解析库
  9. Excel 2010/2013/2016在鼠标右键新建xls或xlsx文件后,打开报错“无法打开文件”“文件格式或文件扩展名无效”
  10. py文件控制台执行时,报错:引入的模块不存在