DCP-248: Help Pritom Finding Prefix LCM Back to All Problems

Easy Math > Counting


**Pritom** is very good at math. But he get bored while finding out LCM. When the numbers are big he fall asleep some times. His teacher gave him an assignment with a list of numbers that he have to find out **LCM of those numbers starting from index 1 to index k**, called Prefix LCM. So You have to help him to find LCM of any length from an array of numbers . ***Note: LCM is the smallest positive number that is a multiple of two or more numbers.***<br> You may read details of LCM here: https://en.wikipedia.org/wiki/Least_common_multiple Input: ------ The first line of the input contains an integer **n** (**1 ≤ n ≤10**) — the total numbers in array. <br> Next **n** lines contains the sequence of integers n1, n2, ..., nth (**1 ≤ ni ≤ 25**).<br> Next line contain an integer **Q (1≤ Q ≤ n)** - the total number of queries. <br> Next **Q** lines contains a query with **k (1≤ k ≤ n)** where **k** denotes the index of the array. Output: ------- For every query with integer k, you just have to print a single integer, denoting the **LCM of numbers from index 1 to k of the given array**. Sample Input ------------ 3 2 4 5 3 1 2 3 Sample Output ------------- 2 4 20


Problem Setter:

Abdullah Al Rifat

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 1.00
Go 1.00
Java 1.00
JavaScript 1.00
Objective-C 1.00
Perl 1.00
PHP 1.00
Python 1.00
Python3 1.00
Ruby 1.00
VB.Net 1.00

Problem Stats

186/319

Solve/Submission

Ranking

# User Language Timing
01 moshiur_cse15 Cpp14 0.00s
02 Zeronfinity Cpp14 0.00s
03 ssavi Cpp14 0.00s
04 bu_hridoy Cpp14 0.00s
05 trifiasco Cpp14 0.00s
06 asad_IT Cpp14 0.00s
07 Reayz Cpp 0.00s
08 njrafi Cpp14 0.00s
09 seyedssz Cpp14 0.00s
10 alhelal_cse Cpp 0.00s
11 nuhu_iu Cpp 0.00s
12 shamimjucse Cpp14 0.00s
13 sazal_dev Cpp14 0.00s
14 dipta007 Cpp14 0.00s
15 badhansen123 Cpp14 0.00s
16 t0whid Cpp14 0.00s
17 Bruteforceman Cpp14 0.00s
18 DynamicOvi Cpp14 0.00s
19 Jakir_Hossain_Sust Cpp14 0.00s
20 adamantium Cpp 0.00s
21 nahid08 Cpp14 0.00s
22 Jisancse Cpp14 0.00s
23 sakib_ruet_13 Cpp 0.00s
24 shahedjamil108 Cpp14 0.00s
25 dmehrab06 Cpp14 0.00s
26 ksohan Cpp 0.00s
27 mir003 Cpp 0.00s
28 RezwanArefin01 Cpp14 0.00s
29 Nirjhor Cpp14 0.00s
30 drifter Cpp 0.00s
31 Roll_Number_27 Cpp 0.00s
32 aabb Cpp 0.00s
33 AlaminJust Cpp14 0.00s
34 orpib Cpp 0.00s
35 shailyroy Cpp14 0.00s
36 Optimus_primeV2 Cpp14 0.00s
37 farhanshahoriar Cpp14 0.00s
38 loop_breaker Cpp14 0.00s
39 SaikatS Cpp14 0.00s
40 mahbubcseju Cpp14 0.00s
41 MRITuhin Cpp14 0.00s
42 skmonir Cpp14 0.00s
43 Anik_Roy Cpp14 0.00s
44 hrOarr Cpp14 0.00s
45 sumit1993 Cpp14 0.00s
46 umli Cpp 0.00s
47 prodipdatta7 Cpp14 0.00s
48 anik_JU Cpp14 0.00s
49 arafat_hasan Cpp 0.00s
50 lsiddiqsunny Cpp14 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support