Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int INF=2147483647;
- int inf=-2147483648;
- int mod=1000000007;
- #define read(x) cin >> x;
- #define fo(i,n) for(i=0;i<n;i++)
- #define one(x) cout<<(x)<<endl;
- #define two(a,b) cout<<(a)<<" "<<(b)<<endl;
- #define three(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;
- #define four(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl;
- bool isPower(double a, double b)
- {
- return trunc(log(a) / log(b)==(log(a) / log(b)));
- }
- int main()
- {
- double t,q;ll b,l,m,i,count=1,s=0,f=0;
- cin >> b >> q >> l >> m;
- for (i=0;i<m;i++)
- {
- cin >> t;// if (isPower(t/b,q)==1) s++;
- if ((isPower(abs(t/b),abs(q))==1) && (abs(t)<=abs(l))) { s++;
- if (b*pow(q,log(abs(t/b))/ log (abs(q)))!=t) s--; }
- //cout << s << endl;
- if (t==b) f=1;
- }
- if (abs(q)==1)
- {
- if ((f==1) || (b>l)) cout << 0; else cout << "inf";
- return 0;
- }
- // cout << endl;
- /*while (abs(b)<=l)
- {
- cout << b << " " << count << endl;
- b*=q; if (abs(b)<=l) count++;
- }*/
- int qq= trunc(abs(l/b));
- while (isPower(q,qq)==0)
- qq--;
- // cout << qq << endl;
- cout << trunc(log(qq)/log(q))-s+1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement