Fredo and Array Update
Fredo and Array Update
Input Format:
First line of input consists of an integer N denoting the number of elements in the
array A.
Second line consists of N space separated integers denoting the array elements.
Output Format:
The only line of output consists of the value of x.
Input Constraints:
1≤N≤105
1≤A[i]≤1000
SAMPLE INPUT
5
1 2 3 4 5
SAMPLE OUTPUT
Explanation
Initial sum of array =1+2+3+4+5=15
When we update all elements to 4, sum of array =4+4+4+4+4=20 which is greater
than 15.
Note that if we had updated the array elements to 3, sum=15 which is not greater
than 15. So, 4 is the minimum value to which array elements need to be updated.
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB
Marking Scheme:Score is assigned if any testcase passes.
Allowed Languages:C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8,
JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl,
PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic
N = int(input())
Sum = 0
SumA = 0
if N >=1 and N <= 10**5:
A = list(map(int, input().split()))
for i in range(N):
if A[i] >= 1 and A[i] <= 1000:
Sum += A[i]
for i in range(Sum):
SumA = i * N
if SumA > Sum:
print(i)
break
Little Shino loves maths. Today her teacher gave her two integers. Shino is now
wondering how many integers can divide both the numbers. She is busy with her
assignments. Help her to solve the problem.
Input:
First line of the input file contains two integers, a and b.
Output:
Print the number of common factors of a and b.
Constraints:
1≤a,b≤1012
SAMPLE INPUT
10 15
SAMPLE OUTPUT
Explanation
The common factors of 10 and 15 are 1 and 5.
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB
Marking Scheme:Score is assigned if any testcase passes.
Allowed Languages:C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8,
JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl,
PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic