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 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.