Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- // #include <iostream>
- // #include <cstdio>
- // #include <cstdlib>
- // #include <algorithm>
- // #include <cmath>
- // #include <vector>
- // #include <set>
- // #include <map>
- // #include <queue>
- // #include <stack>
- // #include <ctime>
- // #include <cassert>
- // #include <complex>
- // #include <string>
- // #include <cstring>
- // #include <bitset>
- using namespace std;
- // #pragma GCC optimize("Ofast,no-stack-protector")
- // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- // #pragma GCC optimize("unroll-loops")
- #define ll long long int
- #define ui unsigned int
- #define vi vector< int >
- #define vll vector< ll >
- #define sc scanf
- #define pf printf
- #define cspf(i) pf("Case #%d: ", i)
- #define spc pf(" ")
- #define line pf("\n")
- #define ff first
- #define ss second
- #define mp make_pair
- #define pb push_back
- #define ppb pop_back
- #define tp(v,j) get<j>(v)
- #define Log(b,x) (log(x)/log(b))
- #define FOR(i,x,y) for(int i = int(x); i < int(y); i++)
- #define ROF(i,x,y) for(int i = int(x)-1; i >= int(y); i--)
- #define clr(arr,x) memset(arr, x, sizeof arr)
- #define vout(v,sz) for(int w=0;w<sz;w++){if(w) spc; cout<<v[w];}
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define unq(v) sort(all(v)),(v).resize(unique(all(v))-v.begin())
- #define fastIO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
- #define sc1(x) sc("%d",&x);
- #define sc2(x,y) sc("%d %d", &x, &y)
- #define sc3(x,y,z) sc("%d %d %d", &x, &y, &z)
- #define scl1(x) sc("%lld",&x);
- #define scl2(x,y) sc("%lld %lld", &x, &y)
- #define scf1(x) sc("%lf",&x);
- #define scf2(x,y) sc("%lf %lf", &x, &y)
- #define pf1(x) pf("%d",x);
- #define pf2(x,y) pf("%d %d", x, y)
- #define pfl1(x) pf("%lld",x);
- #define pfl2(x,y) pf("%lld %lld", x, y)
- #define MOD 4294967296LL
- #define MaxN 100000000LL
- #define inf 0x3f3f3f3f
- #define PI acos(-1.0) // 3.1415926535897932
- #define eps 1e-9
- #ifdef ERFANUL007
- #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
- template < typename Arg1 >
- void __f(const char* name, Arg1&& arg1){
- cout << name << " = " << arg1 << std::endl;
- }
- template < typename Arg1, typename... Args>
- void __f(const char* names, Arg1&& arg1, Args&&... args){
- const char* comma = strchr(names, ',');
- cout.write(names, comma - names) << " = " << arg1 <<" | ";
- __f(comma+1, args...);
- }
- #else
- #define debug(...)
- #endif
- int N;
- vector< ui > prime;
- vector< ui > ans;
- bitset< MaxN+1 > isPrime;
- void precalc(){
- isPrime.set();
- ll i, j;
- ui x;
- for(i=4; i <= MaxN; i += 2) isPrime[i] = 0;
- prime.pb(2);
- ans.pb(2);
- for(i=3; i <= MaxN; i+=2){
- if(isPrime[i]){
- prime.pb(i);
- x = ans.back() * i;
- ans.pb(x);
- for(j=i*i; j <= MaxN; j += (i*2)) isPrime[j] = 0;
- }
- }
- N = prime.size()-1;
- debug(N);
- }
- int main()
- {
- #ifdef ERFANUL007
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- precalc();
- int t, ca=0, lo, hi, mid, inx, n, i, occ;
- ui res;
- scanf("%d", &t);
- while(t--){
- scanf("%d", &n);
- res = 1;
- for(i=0; prime[i] * prime[i] <= n; i++){
- occ = Log(prime[i], n) + eps;
- // debug(prime[i], occ);
- while(--occ){
- res *= prime[i];
- }
- }
- // debug(res);
- lo = 0, hi = N;
- while(lo <= hi){
- mid = (lo + hi)/2;
- if(prime[mid] > n) hi = mid-1;
- else{
- lo = mid+1;
- inx = mid;
- }
- }
- res *= ans[inx];
- printf("Case %d: %u\n", ++ca, res);
- }
- #ifdef ERFANUL007
- fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement