Blue Bridge Cup 2018- provincial tournament -C / C ++ - A group of four questions

Topic
Title: first few lucky number

X travel to the planet visitors are sent to an integer, as a tourist numbers.
x king star has a knack, he only likes numbers 3, 5 and 7.
King provisions, if the number of visitors contains only factor: 3,5,7, you can get a prize.

Let's look first 10 lucky number:
3,579,152,125,273,545
thus lucky number is 11: 49

Xiao Ming received a lucky number 59084709587505, he went to accept the award, when people asked him to say exactly which is the first of several lucky number, otherwise not receive prizes.

Xiao Ming to help you calculate, 59,084,709,587,505 are a few lucky number.

Is required to submit an integer, please do not fill out any extra content.

Code

 1 #include<iostream>
 2 #include<cmath>
 3 #include<stdio.h>
 4 using namespace std;
 5 typedef  long long ll;
 6 ll a[20000];
 7 const ll N=59084709587505;
 8 int main(){
 9 
10     ll i=1;
11     int i_3=0,i_5=0,i_7=0;
12     a[0]=1;
13     for (; A [I- . 1 ] <N; I ++) { // ensure a [i] can be calculated for the current minimum value of all   
14          a [i] = min (min (A [i_3 will be used] * . 3 , A [i_5 will be used] * . 5 ), A [i_7 will be used] * . 7 );
 15          COUT << (A [I] == N) << "  " << A [I] << "  " << I << endl;
 16          // anti Deriving a [i] with who 
. 17          IF (a [i] / a [i_3 will be used] == . 3 ) i_3 will be used ++ ; 
 18 is          IF (a [i] / a [i_5 will be used] == . 5 ) ++ i_5 will be used ;
 . 19          IF (A [I] / A [i_7 will be used] == . 7 ) i_7 will be used ++ ;
 20 is         printf("3:%d 5:%d 7:%d\n",i_3,i_5,i_7);
21     } 
22     cout<<i-1<<endl;
23     
24     
25 } 

 

Guess you like

Origin www.cnblogs.com/memocean/p/12292344.html