コード例 #1
0
ファイル: SDSQUARE.cpp プロジェクト: caioaao/cp-solutions
void preprocess(){
	nums.push_back(0);
	ll sqr = 1, i = 1;
	while(sqr <= max_n){
		if(test(sqr) && sqr%i == 0) nums.push_back(sqr);
		i++; sqr = i*i;
	}
}
コード例 #2
0
ll cal() {
    vec.push_back(0);
    vec.push_back(1);
    ll add = 2;
    ll a = 2;
    for (int i = 2; i < 1000001; ++i) {
        vec.push_back(vec[i - 1] + a);
        i++;
        a += add;
        vec.push_back(vec[i - 1] + a);
        a += add;
        add++;
    }
}
int main ()
{
	ll mid;

	ll i,j,k,x,ans=0,depend,l,n,ind;
	
	cin>>n>>m>>depend;
	fr(i,n)
	{
		cin>>x;
		man.push_back(x);
	}
コード例 #4
0
int deal(){
    weight.clear();
    cin >> buf;
    int depth = 0;
    ll tmp;
    for (string::iterator ii = buf.begin(); ii != buf.end(); ii++){
        switch (*ii){
            case '[':
                {
                    depth++;
                }break;
            case ']':
                {
                    depth--;
                }break;
            case ',':break;
            default:
                {
                    tmp = 0;
                    while ('0' <= *ii && *ii <= '9') tmp = tmp * 10 + *ii - '0', ii++;
                    ii--;
                    weight.push_back(tmp << depth);
                }
        }
    }
    sort(weight.begin(), weight.end());
    int len = weight.size();
    int best = 0, cur = 1;
    weight.push_back(-1);
    for (int i = 0; i < len; i++){
        if (weight[i + 1] != weight[i]){
            best = max(best, cur);
            cur = 1;
        }
        else cur++;
    }
    return len - best;
}
コード例 #5
0
void init()
{
    int i=0 , j;

    LL pnum=0 , p=1;

    sll st;
    sll::iterator it;

    for(i=0; i<plen; i++)
    {
        pnum = prm[i];

        for(j=2; j<=40; j++)
        {
           //pnum = power(prm[i] , j);

           p=1;

           for(int k=1; k<=j; k++)
           {
               p*=pnum;

               if(p > mxhigh) break;
           }

           if(p < mxhigh)
           {
               st.insert(p);
           }
        }
    }

    //cerr << st.size();

    for(it=st.begin() ; it!=st.end() ; ++it)
    {
        v.push_back(*it);
    }

    //for(i=0; i<100; i++) cout << v[i] << " ";
    //cout << v.size();
    //cout << v[v.size()-1];
    vlen = v.size();
}