HDU 3652 數字DP 解題報告

2021-08-03 09:19:18 字數 1254 閱讀 4103

b-number

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 output1

1 2

2【解題報告】

這是機房模擬acm的a題,然而只有我乙個人做了。。。

關於不能出現13的部分就非常顯然了,重點就在整除上面,因為如果直接判斷的話肯定是沒法轉移的,所以大概思路就是記錄這個數除13的餘數,(dp多加一維,dfs的時候加幾句就可以了)。

**如下:

#include

#include

#include

using namespace std;

int n;

int dp[10][15][2][10],a[10];

int dfs(int

pos,int mod,int t,int pre,int limit)

if(!limit) dp[pos][mod][t][pre]=ans;

return ans;

} int solve(int

x)

int main()

return

0;

}

HDU 3652 數字DP 套路題

題意 統計能被13整除和含有13的數的個數 解法沒法好說的.學了前面兩道直接啪出來了 ps.hdu深夜日常維護,沒法交題,拿網上的 隨便對拍一下,輸出一致 include define rep i,j,k for register int i j i k i using namespace std ...

HDU3652 數字DP 記憶化搜尋

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 1...

數字DP與記憶化搜尋 HDU3652

上題目b number b number problem description a wqb number,or b number for short,is a non negative integer whose decimal form contains the sub string 13 an...