[Offer收割]编程练习赛7 register

Ended

Participants:506

Verdict:Time Limit Exceeded
Score:10 / 100
Submitted:2016-08-28 13:00:29

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <functional>
using namespace std;
#define MOD 1000000007
typedef long long ll;
void dfs(vector<int> &a, ll target, int cur, ll& ret){
    if (target <= 0) return;
    if (cur == a.size() - 1){
        int count = 0;
        while (target){
            ++count;
            target /= 10;
        }
        if (a[cur] == count)
            ret = (ret + 1) % MOD;
        return;
    }
    
    ll curNum = 1;
    for (int j = 1; j < a[cur]; ++j)
        curNum = curNum * 10;
    int top = curNum * 10 - 1;
    while (curNum <= top)
    {
        if (target - curNum <= 0) break;
        dfs(a, target - curNum, cur + 1, ret);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX