 # QM8B editorial

Practice

Contest

Author: Chandan Boruah

Tester: Chandan Boruah

Editorialist: Chandan Boruah

EASY

### PREREQUISITES:

Simple Math, Brute Force.

### PROBLEM:

Given natural numbers from 1 to n, find the average of each 2 contiguous numbers ending up with another list of natural numbers. Find the average of 2 contigous numbers ending up with another list. Continue doing this till 1 number is left, print that number.

### QUICK EXPLANATION:

Use a linked list to store the new list and continue building new list everytime until 1 number is left.

### EXPLANATION:

Find average of 1 and 2 and store in a temporary linked list. Find average of 3 and 4 and store in that same linked list. Do this till the number n is reached. Update the original linked list to this new one and work on it to update the temporary linked list, until one number is left.

### AUTHOR’S SOLUTION IN C#:

``````using System;
using System.Collections.Generic;
class some
{
public static void Main()
{
while((n--)>0)
{
List<int>ll=new List<int>();
while(ll.Count>1)
{
List<int>temp=new List<int>();
for(int i=0;i<ll.Count-1;i+=2)
{