0% found this document useful (0 votes)
77 views3 pages

Fredo and Array Update

The document describes two programming tasks: the first involves updating an array of integers to a minimum value such that the new array's sum exceeds the original sum, while the second task requires finding the number of common factors between two integers. Each task includes input and output formats, constraints, and sample inputs and outputs for clarity. Both tasks are designed to test problem-solving and algorithmic skills within specified time and memory limits.

Uploaded by

Rahul D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views3 pages

Fredo and Array Update

The document describes two programming tasks: the first involves updating an array of integers to a minimum value such that the new array's sum exceeds the original sum, while the second task requires finding the number of common factors between two integers. Each task includes input and output formats, constraints, and sample inputs and outputs for clarity. Both tasks are designed to test problem-solving and algorithmic skills within specified time and memory limits.

Uploaded by

Rahul D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Fredo and Array Update

Max. score: 100


Fredo is assigned a new task today. He is given an array A containing N integers. His
task is to update all elements of array to some minimum value x , that
is, A[i]=x ; 1≤i≤N such that sum of this new array is strictly greater than the sum of the
initial array. Note that x should be as minimum as possible such that sum of the new
array is greater than the sum of the initial array.

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 and Common factors


Max. score: 100

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

You might also like