using
System;
using
System.Collections.Generic;
public
class
GFG
{
static
int
[] divisors =
new
int
[100];
static
int
[] BIT =
new
int
[100];
public
class
Query
{
public
int
type, l, r;
public
Query(
int
type,
int
l,
int
r)
{
this
.type = type;
this
.l = l;
this
.r = r;
}
}
static
void
CalcDivisors()
{
for
(
int
i = 1; i < 100; i++)
{
for
(
int
j = i; j < 100; j += i)
{
divisors[j]++;
}
}
}
static
void
Update(
int
x,
int
val,
int
n)
{
for
(
int
i = x; i <= n; i += i & -i)
{
BIT[i] += val;
}
}
static
int
Sum(
int
x)
{
int
s = 0;
for
(
int
i = x; i > 0; i -= i & -i)
{
s += BIT[i];
}
return
s;
}
static
void
AnswerQueries(
int
[] arr, Query[] que,
int
n,
int
q)
{
SortedSet<
int
> s =
new
SortedSet<
int
>();
for
(
int
i = 1; i < n; i++)
{
if
(arr[i] > 2)
s.Add(i);
Update(i, arr[i], n);
}
for
(
int
i = 0; i < q; i++)
{
if
(que[i].type == 1)
{
while
(
true
)
{
var
it = s.GetEnumerator();
int
idx = 0;
while
(it.MoveNext())
{
idx = it.Current;
if
(idx >= que[i].l
&& idx <= que[i].r)
break
;
}
if
(idx > que[i].r)
break
;
que[i].l = idx;
Update(idx,
divisors[arr[idx]] - arr[idx],
n);
arr[idx] = divisors[arr[idx]];
if
(arr[idx] <= 2)
s.Remove(idx);
que[i].l++;
}
}
else
{
Console.WriteLine(Sum(que[i].r)
- Sum(que[i].l - 1));
}
}
}
public
static
void
Main(
string
[] args)
{
CalcDivisors();
int
q = 4;
int
[] arr = { 0, 6, 4, 1, 10, 3, 2, 4 };
int
n = arr.Length;
Query[] que =
new
Query[q + 1];
que[0] =
new
Query(2, 1, 7);
que[1] =
new
Query(2, 4, 5);
que[2] =
new
Query(1, 3, 5);
que[3] =
new
Query(2, 4, 4);
AnswerQueries(arr, que, n, q);
}
}