Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- #define inf 2e18
- int MOD=1000000007;//998244353;
- const int nn=1000050;
- bool prime[nn]; //array to store precalculated primes till 10^6
- void cal_primes(){memset(prime,true,sizeof(prime)); for(int i=2;i<=sqrt(nn);++i){ if(prime[i]==true){ for(int j=i*i;j<=nn;j+=i){prime[j]=false;}}}}
- void solve(int t)
- {
- int testcases=t;
- while(t--)
- {
- // cout<<"Case #"<<(testcases-t)<<": "<<endl;
- }
- }
- main()
- {
- auto start=chrono::system_clock::now();
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- freopen("error.txt","w",stderr);
- #endif
- ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- int t=1;
- cin>>t;
- solve(t);
- }
- auto end=chrono::system_clock::now();
- chrono::duration<double> elapsed=end-start;
- cout<<endl<<"Time taken: "<<elapsed.count()<<" sec";
- return 0;
- }
- //////////////////////////////////////////////////////////////////////
- //not necessary, additional header files
- #pragma GCC optimize("Ofast")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
- #pragma GCC optimize("unroll-loops")
- #pragma comment(linker, "/stack:200000000")
- //standard for loops
- #define loop(i,n) for(int i=0;i<n;i++)
- #define loopn(i,a,b) for(int i=a;i<=b;i++)
- #define rloop(i,n) for(int i=n-1;i>=0;i--)
- //faster gcd,lcm
- template<class T> T gcd(T a,T b){if(!a||!b)return a|b; unsigned shift=__builtin_ctz(a|b); a>>=__builtin_ctz(a); do{b>>=__builtin_ctz(b); if(a>b)swap(a,b);b-=a;}while(b); return a<<shift;}
- template<class T> T lcm(T a,T b){ unsigned val=max(a,b)/gcd(a,b);val*=min(a,b);return val;}
- //check if a number is a power of 2 or not, return true if it is a power of 2
- bool pow2(int x){if(x&&(!(x&(x-1)))) return true; else return false;}
Add Comment
Please, Sign In to add comment