1010 contains only the number of factor 2 3 5 Base time limit:1 seconds space limit:131072 KB score: Difficulty:2-level algorithm problem The collection focuses on removing the factor that concerns K only contains 2 3 5. The first 10 numbers that meet the criteria are: 2,3,4,5,6,8,9,10,12,15. All such k make up a sequence s, and now give a number n, to find the smallest number of >= given in S. For example: n = the minimum number of >= 13 in 13,s is 15, so output 15. Input
Line 1th: A number t that represents the number of numbers that are later used as input tests. (1 <= T <= 10000) 2-t + 1 lines: 1 numbers per line n (1 <= n <= 10^18)
Output
A total of T-lines, 1 digits per line, and the smallest of the output >= n contains only the number of factors 2 3 5.
Input example
518133577
Output example
28153680
1#include <iostream>2#include <algorithm>3 using namespacestd;4typedefLong Longll;5 Constll n=1e18+ +;6 Constll maxn=1e6+Ten;7 intT;8 ll A[MAXN];9 intD;Ten voidInit () One { AD=0; - for(LL i=1; i<n;i*=2) - for(LL j=1; j*i<n;j*=3) the for(LL k=1; i*j*k<n;k*=5) -a[d++]=i*j*K; -a[0]=-1; -Sort (a,a+d); + } - intMain () + { AIos::sync_with_stdio (false); at init (); -Cin>>T; - while(t--) - { - ll tmp; -Cin>>tmp; inll Pos=lower_bound (a,a+d,tmp)-A; -cout<<a[pos]<<Endl; to } + return 0; -}
View Code
51nod 1010 contains only the number of factors 2 3 5 (table + sort + two)