int main(){
    for(LL i=2;i<1000000;++i){
        if(!sieve[i]){
            for(LL j=i*i;j<1000000;j+=i)sieve[j]=1;
            ptt.PB(i);
        }
    }
    LL N;
    while(~RI(N) && N){
        bool flag=0;
        if(N<0)flag=1,N=abs(N);
        ans.clear();
        for(LL p:ptt){
            int c=0;
            while(N%p==0)N/=p,++c;
            if(c)ans.PB(c);
        }
        LL AA=ans[0];
        if(N!=1)puts("1");
        else {
            REPP(i,1,SZ(ans))AA=__gcd(AA,ans[i]);
            if(flag)AA/=__gcd(AA,1ll<<32);
            printf("%lld\n",AA);
        }
    }
}
Beispiel #2
0
void solve() {
    int n;
    long d;

    cin >> n >> d;

    VL sol;
    long tmp;
    REP(i, n) {
        cin >> tmp;
        sol.PB(tmp);
    }
Beispiel #3
0
 REP(i, N) {
     LL sum = ar[i].first.second;
     VL foo;
     for (int j = 0; j < K && !pq.empty(); j++) {
         LL bar = pq.top();
         pq.pop();
         sum += bar;
         foo.EB(bar);
     }
     ans[ar[i].second] = sum;
     FORE(e, foo) pq.push(e);
     pq.push(ar[i].first.second);
 }
Beispiel #4
0
	L Dijkstra(int s, int t) {
		fill(found.begin(), found.end(), false);
		fill(dist.begin(), dist.end(), INF);
		fill(width.begin(), width.end(), 0);
		dist[s] = 0;
		width[s] = INF;
		while (s != -1) {
			int best = -1;
			found[s] = true;
			for (int k = 0; k < N; k++) {
				if (found[k]) continue;
				Relax(s, k, cap[s][k] - flow[s][k], cost[s][k], 1);
				Relax(s, k, flow[k][s], -cost[k][s], -1);
				if (best == -1 || dist[k] < dist[best]) best = k;
			}
			s = best;
		}
		for (int k = 0; k < N; k++)
			pi[k] = min(pi[k] + dist[k], INF);
		return width[t];
	}
Beispiel #5
0
    void polynomial_inverse(int deg, VL & a, VL & b, VL & tmp) {
        if(deg == 1) {
            b[0] = power(a[0], mod_v - 2);
        } else {
            polynomial_inverse((deg + 1) >> 1, a, b, tmp);

            int p = 1;
            while(p < deg << 1) p <<= 1;
            copy(a.begin(), a.begin() + deg, tmp.begin());
            fill(tmp.begin() + deg, tmp.begin() + p, 0);
            transform(p, tmp, eps);
            transform(p, b, eps);
            for(int i = 0; i != p; ++i) {
                b[i] = (2 - tmp[i] * b[i] % mod_v) * b[i] % mod_v;
                if(b[i] < 0) b[i] += mod_v;
            }
            transform(p, b, inv_eps);
            long long inv = power(p, mod_v - 2);
            for(int i = 0; i != p; ++i)
                b[i] = b[i] * inv % mod_v;
            fill(b.begin() + deg, b.begin() + p, 0);
        }
    }
int main() 
{
#if DEBUG
    freopen("E:\\", "r" ,stdin);
    freopen("E:\\", "w", stdout);
#endif

    VL v;
    VIT iter;
    __int64 x, sum;
    int nTests;
    char cmd[10];
    
    while (~scanf("%d", &nTests)) {
        v.clear();
        for (int i = 0; i < nTests; ++i) {
            scanf("%s", cmd);
            if ( cmd[0] == 'a' ) {
                scanf("%I64d", &x);
                iter = lower_bound( v.begin(), v.end(), x );
                if ( !v.size() )
                    iter = v.begin();
                v.insert( iter, x );
            } else if ( cmd[0] == 'd' ) {
                scanf("%I64d", &x);
                iter = lower_bound( v.begin(), v.end(), x );
                if ( !v.size() )
                    iter = v.begin();
                v.erase( iter );
            } else if ( cmd[0] == 's' ) {
                sum = 0;
                for (iter = v.begin() + 2; iter < v.end(); iter += 5)
                    sum += *iter;
                printf("%I64d\n", sum);
            }
        }
    }// End of while

    return 0;
}