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

k+1,k+4,k+9,k+16,…
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

∑i=12kgcd(Ai,Ai+1)
Denote this sum by S. Zanka wants you to print the number S for each k.

Input
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.
Output
For each test case, output a single line containing the sum S for the given k.

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

Sample Input
1
1
Sample output
6
Explanation
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 :

Related :

close
error: Content is protected !!