TASK DEFINITION: This task is to find the number of 'For' loops present in the given cpp program.
PROBLEM: int f(int t)
{
double v=sqrt(t)+1;
for(int i=2; i<v; i++)
if(t%i==0) return 0;
return 1;
}
int sum=0;
void fun(int n,int i)
{
if(n==1)
sum++;
while(i<=n)
{
if(n%i==0)
fun(n/i,i);
i++;
}
return ;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int a;
scanf("%d",&a);
if(f(a)>0)
{
printf("1
");
continue;
}
int i=2,K=1;
while(i<=a/2)
{
if(a%i==0)
{
sum=0;
fun(a/i,i);
K+=sum;
}
i++;
}
printf("%d
",K);
}
}

SOLUTION: 2

PROBLEM:

int main()
{
int n,i;
int a,num(int,int);

cin>>n;
for (i=0;i<n;i++)
{
cin>>a;
cout<<num(2,a)+1<<endl;
}
return 0;
}

int num(int m,int n)
{
int i,count=0;
int su(int);
for (i=m;i<=(int)sqrt(n);i++)
if (n%i==0)
{
count++;
if (su(n/i)!=0)
count+=num(i,n/i);
}
return count;
}

int su(int n)
{
int i;
for (i=2;i<n;i++)
if (n%i==0)
{
return 1;
break;
}
if (i==n)
return 0;
}

SOLUTION: 3

PROBLEM:
/*
????
??
?????????????
f[i,j]????i????j?????????
??????????
i?j????N?????O(sqrt(n))???
?????
?????O(n^(3/2))
?????O(n)
*/
int main()
{
int f[200][200] = {0};
int div[40000] = {0};
int divth[200] = {0};
int kase = 0;
cin >> kase;
for (; kase > 0; kase --)
{
int n = 0;
cin >> n;
memset(f,0,sizeof(f));
memset(div,0,sizeof(div));
memset(divth,0,sizeof(divth));
int m = 0;
for (int i = 1; i <= n; i ++)
if (n % i == 0)
{
div[i] = ++m;
divth[m] = i;
}
f[1][1] = 1;
for (int i = 2; i <= m; i++)
for (int j = 2; j <= i; j++)
for (int k = j; k > 1; k--)
if (divth[i] % divth[k] == 0)
{
int ii = divth[i] / divth[k];
int jj = k;
if (div[ii] < jj) jj = div[ii];
f[i][j] += f[div[ii]][jj];
}
cout << f[m][m] << endl;
}
return 0;
}

SOLUTION:
5