Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

GMQ - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

DIFFICULTY:

EASY

PREREQUISITES:

Factorization

PROBLEM:

Given an array, we have to give the sum of factors from L to R

QUICK EXPLANATION:

Store the factorized sum of each element while taking input.
Store the cumulative sum and return $a[r]-a[l-1]$ for each query.

EXPLANATION:

This is a straight away question.
You just need to factorize an element and store all the factors.

for i in (1..n)
    fact[i] = fact[i-1] + factorize(a[i])
for each query
        print fact[r]-fact[l-1]


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>