UVA 12043 - Divisors Solution

Solution in c++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh

#include<bits/stdc++.h>
using namespace std;
#define M 100009
long long i,j,sd[M],d[M];
void div()
{
    for(i=1; i<=100000; i++)
    {
        for(j=i; j<=100000; j=j+i)
        {
            sd[j]+=i;
            d[j]++;
        }
    }
}
main()
{
    div();
    long long  t,a,b,c;
    cin>>t;
    while(t--)
    {
       long long ssd=0,dd=0;
        cin>>a>>b>>c;
        for(i=a; i<=b; i++)
        {
            if(i%c==0)
            {
                ssd+=sd[i];
                dd+=d[i];
            }
        }
        cout<<dd<<" "<<ssd<<endl;
    }
}

1 comment:

  1. According to Stanford Medical, It's indeed the ONLY reason women in this country live 10 years longer and weigh 19 kilos less than we do.

    (By the way, it has totally NOTHING to do with genetics or some secret exercise and really, EVERYTHING related to "HOW" they are eating.)

    BTW, I said "HOW", not "what"...

    Tap on this link to discover if this easy questionnaire can help you discover your true weight loss possibility

    ReplyDelete

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.