forked from vijay532/CompetitiveSources
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankFactor3and5.cpp
More file actions
50 lines (48 loc) · 800 Bytes
/
HackerrankFactor3and5.cpp
File metadata and controls
50 lines (48 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//g++ 5.4.0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll expo(ll n, ll k)
{
if(k==0)
{
return 1;
}
else if(k==1)
{
return n;
}
ll res=expo(n,k/2);
if(k%2)
{
return res*res*n;
}
else
{
return res*res;
}
}
int main()
{
ll l,r,i,j;
cin>>l>>r;
vector<ll>v;
for(i=0;i<20;i++)
{
for(j=0;j<15;j++)
{
v.push_back(expo(3,i)*expo+(5,j));
}
}
ll count=0;
for(i=0;i<v.size();i++)
{
if(l<=v[i] && v[i]<=r)
{
count++;
}
}
cout<<count<<endl;
}
/*
Compilation time: 1.43 sec, absolute running time: 0.07 sec, cpu time: 0.01 sec, memory peak: 3 Mb, absolute service time: 1,51 sec*/