The old driver's strange Noip analog t2-huangyueying

Source: Internet
Author: User

2. huangyueying
(Huangyueying.cpp/c/pas)
"Problem description"
XPP studies the philosophy of astronomy every day, and there are some thoughts that we cannot understand in life.
After a dull academic day, XPP opened the http://web.sanguosha.com, ready to use his beloved huangyueying
abuse. Entered the eight-person status bureau, as a master, xpp decisively elected huangyueying, with huangyueying pick 7 people.
Why does xpp like huangyueying this warlord? Because Ji Zhi is a very good skill.
Ji Zhi-You can touch a card immediately whenever you use a non-delayed class bag (before it settles).
It can be seen that the ability of this skill if used well then the hand is not finished. So xpp 7 people all easy to kill.
Although Xpp's collection of wisdom can always touch the bag, but he thought of such a problem: Because Huangyueying is a rich
Intelligent person, so xpp also want a wise question, specifically, he on the cards on the number of interest,
So he wanted to know how many times each number appeared on the card.
Of course, it's too easy to count the numbers on a card. So xpp to expand the range.
XPP is considering a problem: from a number A to another number B, each number from 0 to 9
How many times has it occurred.
XPP IQ is too strong to think of such low-end problems, and then you will have to do this problem.
Input
The input file name is huangyueying.in.
A total of two integers per row, respectively, a, B.
Output
The output file name is Huangyueying.out.
Outputs a total of 10 integers representing the number of times from 0 to 9, respectively.
"Input and Output sample"
Huangyueying.in Huangyueying.out
24 69 4 4 10 14 15 15 15 5 5 5
"Data Range"
For 30% of data, a≤b≤1000000.
For 100% of data, a≤b≤10^12.

————————————————

A very water digital DP, but I never got it out.

The original statistics when there is no statistical prefix 0, simple calculation of each number, feel to go leading 0 too troublesome, and then can not be adjusted, and then see the problem found in fact is not so troublesome ... And then it's over.

"The old driver's data is very pit"

We're counting 4997, we're adding 000-

1#include <iostream>2#include <string.h>3#include <cstdlib>4#include <cstdio>5#include <algorithm>6#include <cstring>7#include <vector>8#include <ctime>9 #defineIvorysiTen #defineMo 10007 One #defineSiji (i,x,y) for (int i= (x); i<= (y); i++) A #defineGongzi (j,x,y) for (int j= (x); j>= (y); j--) - #defineXiaosiji (i,x,y) for (int i= (x);i< (y); i++) - #defineSigongzi (j,x,y) for (int j= (x);j> (y); j--) the #defineIvory (i,x) for (int i=head[x];i;i=edge[i].next) - #definePII pair<int,int> - #defineFi first - #defineSe Second + #defineINF 10000000 - using namespacestd; +typedefLong Longll; All dp[ the][ the][ the];//DP (I,J,K) I-digit, J-Start, number of K atll num[ A]={//Why do I have to hit this watch? -     0, -     Ten, -      -, -      +, -     10000, in     100000, -     1000000, to     10000000, +     100000000, - 1000000000LL, the 10000000000LL, * 100000000000LL $ };Panax Notoginseng voidinit () { -Siji (I,0,9) { thedp[1][i][i]=1; +     } ASiji (I,2, A) { theSiji (J,0,9) { +Siji (k,0,9) { -Siji (H,0,9) { $dp[i][j][k]+=dp[i-1][h][k]; $                 } -             } -dp[i][j][j]+=num[i-1]; the         } -     }WuyiSiji (I,1, A) { theSiji (J,1,9) { -Siji (k,0,9) { Wudp[i][j][k]+=dp[i][j-1][k]; -             } About         } $     } - } - ll A, B; -ll ansa[ the],ansb[ the]; A voidQuery (LL C,LL *arr) { +     if(c==-1)return ; thell tmp=C; -     intlen=0, x[ the]; $      while(TMP) { thex[++len]=tmp%Ten; theTmp/=Ten; the     } theGongzi (I,len,2) { -         if(x[i]!=0) { inSiji (k,0,9){ thearr[k]+=dp[i-1][9][k]; the             } About             if(I==len) Siji (k,1, I-2) arr[0]-=Num[k]; the             /* the if we're doing 000-999, the we're going to get rid of 000-009 two times 0 + Get rid of 010-099 once 0 - This is going to come together. 000-099 once 0 (100 x 0) the Engage 000-009 once 0 (10 of 0)Bayi             */ the             if(I!=len) arr[0]+=num[i-1]; the         } -Xiaosiji (P,1, X[i]) { -Siji (k,0,9) { thearr[k]+=dp[i-1][9][k]; the             } thearr[p]+=num[i-1]; the         } -arr[x[i]]+=c%num[i-1]+1;//Plus this bit of back count the     } theSiji (I,0, x[1]) ++Arr[i]; the }94 intMain () { the #ifdef Ivorysi theFreopen ("huangyueying.in","R", stdin); theFreopen ("Huangyueying.out","W", stdout);98 #else  AboutFreopen ("f1.in","R", stdin); - #endif101scanf"%i64d%i64d",&a,&b);102 init ();103Query (A-1, Ansa);104 query (B,ANSB); theSiji (I,0,9) {106printf"%i64d%c", Ansb[i]-ansa[i],"\ n"[i==9]);107     }108     return 0;109}

999 (get rid of prefix 0), plus 1000-1999, plus 2000-2999, plus 3000-3999, plus 998 4, then we'll get another one ... First bit 4 we can throw it away.

Correctness, write a violent, and you'll know.

The old driver's strange Noip simulation t2-huangyueying

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.