The topic is probably to ask for a number of n different numbers to construct a two-fork sort tree of several forms.
and another classic topic n nodes two the number of different forms of a fork tree a recursive solution, in fact, the solution of these two problems are Cattleya number.
- Dp[n] Indicates the number of scenarios with N
- The transfer is the enumeration of the number of the root, and then into the left and right two sub-trees, the number of the two sub-tree is similar to the problem
The other is the topic must first find [1,1e10] perfect power, a total of 102,230, the input interval [a,b],b-a>=1e6, that is, the maximum number of perfect power is probably within the a=1,b=1000001 range, 1110 x Perfect power.
1#include <cstdio>2#include <cstring>3#include <Set>4#include <algorithm>5 using namespacestd;6 Long LongPowLong LongXinty) {7 Long Longres=1;8 for(intI=0; i<y; ++i) res*=x;9 returnRes;Ten } One Long Longpownum[111111]; A intPN; - intGETCNT (Long LongALong Longb) { - return(Upper_bound (POWNUM,POWNUM+PN,B)-pownum)-(Lower_bound (pownum,pownum+pn,a)-pownum); the } - Long Longd[1111]; - intMain () { - for(Long LongI=2; i*i<=10000000000L; ++i) { + for(intj=2; ; ++j) { - if(Pow (I,J) >10000000000L) Break; +pownum[pn++]=Pow (i,j); A } at } -Sort (pownum,pownum+PN); -Pn=unique (POWNUM,POWNUM+PN)-Pownum; -d[0]=d[1]=1; - for(intI=2; i<1111; ++i) { - for(intj=1; j<=i; ++j) { ind[i]+=d[j-1]*d[i-j]; -d[i]%=100000007; to } + } -d[0]=0; the Long Longb; * intT; $scanf"%d",&t);Panax Notoginseng for(intCse=1; cse<=t; ++CSE) { -scanf"%lld%lld",&a,&b); theprintf"Case %d:%lld\n", cse,d[getcnt (A, b)]); + } A return 0; the}
Lightoj1170-counting Perfect BST (Cattleya number)