Holi and Division Function
Practice
3.8 (12 votes)
Easy
Math
Number theory
Number theory
Problem
57% Success 5102 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Monk is very busy with a problem and he has to leave for the celebration of Holika Dahan. He asks you to help him with the problem so that he can enjoy with his friends.
Let us define the division function F(n) as:
If Decimal part of n is >=0.5 we take ceil of n else we take floor of n.
Eg. F(4.51)=5, F(4.49)=4.
Given an array A of size N . Compute the all pair division function.
ans=0;
For(i=0;i<N;i++)
{
For(j=0;j<N;j++)
{
ans=ans+F(A[i]/A[j])
}
}
return ans;
Input Format
First line contains an integer T denoting the number of test cases.
Each test case contains two lines:
First line contains an integer N.
Next line contains N space separated integers denoting array A.
Output Format:
For each test case, print the value returned from all pair division function.
Input Constraints:
\(1 \le T \le 10 \)
\(1 \le N \le 10^5 \)
\(1 \le A[i] \le 10^5 \)
Submissions
Please login to view your submissions
Similar Problems
Points:30
19 votes
Tags:
AlgorithmsEuler's totient functionGreatest common divisorMathNumber TheorySieve
Points:30
58 votes
Tags:
ApprovedEasyMathNumber theory
Points:30
10 votes
Tags:
AlgorithmsMathNumber TheoryNumber theory
Editorial