Transmission Door
The factor of K contains only 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)
Section 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
5
1
8
13
35
77
Output example
2
8
15
36
80
Problem Solving Ideas:
is to first put all of the 2 3 5 factor of the number dozen a table in an array, and then two to find the first >= array of numbers, the output is OK.
On the code:
#include <iostream>#include <cstring>#include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>using namespace STD;typedef Long LongLL;ConstLL INF =1e18+ -;/// not too small.Const intMAXN = -* -* -; LL A[MAXN];intCNT =0;voidInit () {cnt =0; for(LL i=1; i<inf; i*=2)///(note i,j,k is LL's) for(LL j=1; j*i<inf; j*=3) for(LL k=1; i*j*k<inf; k*=5) a[cnt++] = i*j*k;}intMain () {Init (); Sort (A, a+cnt);intTCin>>T; while(t--) {LL n;scanf("%lld", &n);printf("%lld\n", A[lower_bound (A +1, a+cnt+1, N)-a]); }return 0;}
51NOD 1010 contains only the number of factors 2 3 5 (binary + preprocessing)