2597 - Uri Online Judge - C ++

0

I'm doing a C ++ program to solve the 2597 math exercise of the ONLINE JUDGE platform below the problem description below.

IstarteddoingtheprograminC++,butrealizethattheinputistoolarge,ItriedtomakeaDPtopreprocesseverythingbefore,butIcannotcreateavectorofsize10^9!!Followtheprogramforyouguystotakealook**

#include<bits/stdc++.h>usingnamespacestd;typedeflonglongintbigint;bigintcontaDiv(bigintdividendo){bigintdiv=0;bigintk=1;bigintm=1;bigintdivisor=1;while(divisor<=sqrt(dividendo)){if(dividendo%divisor==0){//cout<<"(div/div)"<<(dividendo/divisor)<<endl;

            if((dividendo/divisor)==divisor)
            {
                div+=1;// cout<<"one"<<endl;
            }
            else
            {
                div+=2; //cout<<"two"<<endl;
            }

        }

        ++divisor;
}
return div;
}

int main(void) {

ios_base::sync_with_stdio(0);
cin.tie(0);

bigint c,n,vl;
cin>>c;


while(c--) {

    cin>>n;

    int ans = 0;

    for(int i=1;i<=n;++i) {
//          cout<<"DIV de "<<i<<" = "<<contaDiv(i)<<endl;
        if(contaDiv(i)%2==0) {
            ++ans;
        }
    }

    cout<<ans<<endl;
}

return 0;
}

** If someone can help me ... how to solve this problem !! At the moment this code is receiving Time Limit Exceed !! **

    
asked by anonymous 05.08.2018 / 17:17

1 answer

4

Your problem is a number factorization problem. The problem of factorization is a problem considered difficult. But considering that N

05.08.2018 / 20:14