0
I’m doing a show in C++ to solve the 2597 platform math exercise URI ONLINE JUDGE follows below the description of the problem.
I started doing the program in C++, but realize that the input is too big, I tried to do a DP to pre-process everything before, but I can’t create a vector of size 10 9 !! Follow the program so you can take a look **
#include <bits/stdc++.h>
using namespace std;
typedef long long int bigint;
bigint contaDiv(bigint dividendo) {
bigint div = 0;
bigint k = 1;
bigint m = 1;
bigint divisor = 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 anyone can give me a help... how to solve this problem !! At the moment this code is receiving Time Limit Exceed !! **
Good.... I solved !! Look friend, maybe right this thought... but I don’t think it will yet.. The Ri is rejecting sequential operations... even though it’s only 3402 in the worst case... Imagine that for each input C, I enter as many as possible as 10 9 ? I would have to go from 1 to 10 9 every time, and it would cost a lot. And it wouldn’t pass either. I managed to solve by finding a logic behind this problem.. It has a funny numbers growth property..
– Victor OCV
@Victorocv You don’t have to go through until 10 9 and that’s exactly what I said in my reply.
– Victor Stafusa