Loj10164 digital Game 1

Source: Internet
Author: User
Description

Recently, CEN is very popular with digital games. A person is named a number that is equal to or greater than 123,446. Now, you decide to play a game by specifying an integer closed interval [a, B] [a, B] [a, B] And asking how many of them do not fall.


A digital DP template. The enumeration starts from the current status when the memory is searched. For more information, see annotations.

# Include <iostream> # include <cstdio> # include <algorithm> # include <cstring> # include <cmath> # include <cstdlib> # include <queue> # include <stack> # include <vector> using namespace STD; # define maxn 100010 # define INF 10000009 # define mod 10000007 # define ll long # define in (a) a = read () # define rep (I, k, n) for (INT I = K; I <= N; I ++) # define drep (I, k, n) for (INT I = K; I> = N; I --) # define Cl (a) memset (A, 0, sizeof (A) inline Int read () {int x = 0, F = 1; char CH = getchar (); (;! Isdigit (CH); CH = getchar () if (CH = '-') F =-1; for (; isdigit (CH); CH = getchar ()) X = x * 10 + CH-'0'; return x * F;} inline void out (int x) {If (x <0) putchar ('-'), X =-X; If (x> 9) Out (X/10); putchar (X % 10 + '0');} int N, f [12] [12], digit [12]; ll DFS (INT POs, int U, int flag) {// POS indicates the current bit, and u indicates the current state, flag determines whether to cross-border if (Pos = 0) return 1; // If the enumeration is complete, this is a case where ll ans = 0; int end; If (FLAG) end = digit [POS]; // if the number of the current enumeration exceeded, that is, the edge is wiped, then the maximum else end is 9; // if the current edge is not wiped, so long casually enumerate rep (I, U, end) ans + = DFS (pos-1, I, flag & I = end); Return ans;} ll get (int K) {int L = 0; while (k) {digit [++ L] = K % 10; k/= 10;} DFS (L, 0, 1);} int main () {int A, B; while (CIN> A> B) cout <get (B)-Get (A-1) <Endl; return 0 ;}

 

Loj10164 digital Game 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.