Link:
#include <stdio.h>int main(){ puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/45334857");}
Exercises
The enumeration is followed by several 0 , and then every time (current request k A rear guide 0 ) to figure out the first one than L Big. < Span class= "Mrow" id= "mathjax-span-14" > 10 k Span style= "Display:inline-block; width:0px; Height:2.279em; " > Multiples, and the first one than L Big. 5 x Span class= "Msubsup" id= "mathjax-span-25" style= "PADDING-LEFT:0.22EM;" >10 k The multiple.
Then compare all these numbers.
Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define INF 0x3f3f3f3fusing namespace STD;Long LongAns,a,b,x;voidDfsLong LongDIV) {Long LongC= (A-1)/div+1) *div,c=0;if(C>B)return;Long LongD= (A-1)/(5*DIV) +1)*(5*DIV), d=0;if(d>b) D=inf; for(Long LongT=c/div; T T/=Ten) c+=2; for(Long LongT=d/div; T T/=Ten) d+=2; d--;if(C<=d) {if(X>C) {x=c; Ans=c; } }Else{if(x>d) {X=d; Ans=d; }} DFS (div*Ten);}intMain () {intI,j,k,g; for(scanf("%d", &g); g--;) {Cin>>A>>B; X=inf,dfs (1);cout<<ans<<endl; }return 0;}
Pricing simulation for "BZOJ4029" "HEOI2015"