I also check the test case that MRH gave me and this also ok now
But I am getting WA again and again.
I will be mad.............
What's wrong with this code.
Can any one explain why i am getting WA again and again though all the test case passed.
I will be ever greatful to him.
Code: Select all
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
int main()
{
/*freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);*/
long long test, num, i, sq, a, b, sum;
queue< long long > q1, q2;
scanf("%lld", &test);
while( test -- )
{
scanf("%lld", &num);
if( num == 0 )
{
printf("0\n");
continue;
}
sq = sqrt( num );
q1.push( num );
q2.push( 1 );
for( i = 2; i <= sq; i ++ )
{
if( i != num / i )
{
q2.push( i );
}
q1.push( num / i );
}
sum = q1.front();
a = q1.front();
/*printf("%ld\n", q1.front());*/
q1.pop();
while( !q1.empty() )
{
/*printf("%ld\n", q1.front());*/
sum += q1.front();
/*printf("sum %ld\n", sum);*/
b = q1.front();
q1.pop();
if( !q2.empty() )
{
/*printf("%ld\n", q2.front());*/
sum += q2.front() * ( a - b );
q2.pop();
}
a = b;
}
while( !q2.empty() )
{
sum += q2.front() * ( a - q2.front() );
q2.pop();
}
printf("%lld\n", sum);
}
return 0;
}
please help me.
Thnx everybody.
alamgir