#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;
#define INF (1<<29)
#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define FILL(a,v) memset(a,v,sizeof(a))
#define PB push_back
#define FOR(i,n) for(int i = 0;i<n;i++)
#define PI acos(-1.0)
#define EPS 1e-9
#define MP(a,b) make_pair(a,b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define LL long long
#define MX 100010
#define MOD 1000000007
int main()
{
LL s[MX],d[MX],a,b,k,g,h,t,sqt;
d[1]=1;
s[1]=1;
for(LL i=2;i<MX;i++)
{
d[i]=2;
s[i]=1+i;
sqt=sqrt(i);
for(LL j=2;j<=sqt;j++)
if(i%j==0)
{
d[i]+=2;
s[i]+=j+i/j;
}
if(sqt*sqt==i)
{
d[i]--;
s[i]-=sqt;
}
}
cin>>t;
while(t--)
{
cin>>a>>b>>k;
LL div=a/k;
if(div*k!=a)
a=(div+1)*k;
g=0;
h=0;
while(a<=b)
{
g+=d[a];
h+=s[a];
a+=k;
}
cout<<g<<" "<<h<<endl;
}
return 0;
}
No comments:
Post a Comment