An Interesting Sequence ISS SOLUTION

An Interesting Sequence ISS Codechef

Zanka finds fun in everyday simple things. One fine day he got interested in a very trivial sequence. Given a natural number k, he considers the sequence Ai=k+i2 so that the terms are

Now to make things more interesting, he considers the gcd of consecutive terms in the sequence, then takes the sum of the first 2k values. More formally, he wants to compute

Denote this sum by S. Zanka wants you to print the number S for each k.

The first line contains an integer T, the number of test cases. Descriptions of test cases follow.
The only line of each test case contains a single integer k.
For each test case, output a single line containing the sum S for the given k.

Subtask #1 (30 points): t≤103,k≤103
Subtask #2 (70 points): Original Constraints

Sample Input
Sample output
The first 2k+1 terms of the sequence A are 2,5,10.

So the answer is gcd(2,5)+gcd(5,10)=1+5=6

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS


Related :

Related :