UVA Online Judge solution 516 – Prime Land – Solution in C++ – Volume 5

UVA Online Judge Solution 516 – Prime Land  | Volume 5
UVA Problem Link – https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=7&page=show_problem&problem=457

Problem Name:516 – Prime Land solution
Problem Number : UVA – 516 – Prime Land solution
Online Judge : UVA Online Judge Solution
Volume: 5
Solution Language : C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 516 – Prime Land Code in CPP:

   #include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{

int
sum,temp1,temp2;
char
x[32767];
int
a,b,c,flag,time1;
while
(gets(x)!=0)
{

if
(x[0]==48&&strlen(x)==1) break;
int
ansmath[2000]={0},anstemp[2000]={0};
sum=1;temp1=0;flag=0;time1=-1;
for
(a=0;a<strlen(x);a++)
{

if
(x[a]>=48&&x[a]<=57)
{
temp1=temp1*10+x[a]-48;}
else

{

if
(flag==0)
{
temp2=temp1;flag=1;}
else

{

c=temp2;
for
(b=1;b<temp1;b++)
{

temp2=temp2*c;
}

sum=sum*temp2;
flag=0;
}

temp1=0;
}
}

c=temp2;
for
(b=1;b<temp1;b++)
temp2=temp2*c;
sum=sum*temp2;
sum=sum-1;
for
(a=2;a<=sum;a++)
{

int
time=0;
if
(sum%a==0)
{

if
(sum%a==0)
time1++;
while
(sum%a==0)
{


sum=sum/a;
time++;
}

ansmath[time1]=a;
anstemp[time1]=time;
}
}

for
(a=time1;a>=0;a--)
{

printf("%d %d",ansmath[a],anstemp[a]);
if
(a != 0)
printf(" ");
}

printf("n");
}

return
0;
}

Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA code in C, UVA code in C++, UVA solution in C, UVA solution, UVA OJ problems solution, UVA 516 – Prime Land  solution, UVA online judge codes, UVA problem 516 – Prime Land solution, UVA Solution in C, UVA 516 – Prime Land  solution in C++, UVA 516 – Prime Land   solution in java

By Maniruzzaman Akash

Maniruzzaman Akash is a freelance web developer with most popular Laravel PHP frameork and Vue JS

Leave a Reply

Your email address will not be published. Required fields are marked *