Header Ad

HackerEarth Special Sum problem solution

In this HackerEarth Special Sum problem-solution Special Sum of the number N is defined as follows:

def foo(n):

{

  ret = 0

  for i = 1 to n:
  {

     if gcd(n,i) is 1:

             ret += 1
   }
  return ret
}

def SpecialSum(N):

{

ret=0

for i = 1 to N:

{

      if i divides N:

         ret += foo(i)
 }

 return ret
}

we have given a N print SpecialSum(N).


HackerEarth Special Sum problem solution


HackerEarth Special Sum problem solution.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<cassert>
#include<sstream>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) for(i=0;i<b;i++)
#define rep1(i,b) for(i=1;i<=b;i++)
#define pdn(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define pn printf("\n")
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define MOD 1000000007
LL mpow(LL a, LL n)
{LL ret=1;LL b=a;while(n) {if(n&1)
ret=(ret*b)%MOD;b=(b*b)%MOD;n>>=1;}
return (LL)ret;}
int main()
{
int t;
sd(t);
while(t--)
{
LL n;
cin >> n;
cout << n << endl;
}
return 0;
}

Post a Comment

0 Comments