Solution of What’s Next spoj problem ACPC10A
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a[3],n,i,d,r;
while(1)
{
for( i=0;i<3;i++)
{
cin>>a[i];
}
if(a[0]==0&&a[1]==0&&a[2]==0)
break;
else
{ d=a[1]-a[0];
r=a[2]-a[1];
if(d==r)
{
n=a[0]+3*d;
cout<<" AP "<<n<<endl;
}
else
{
n=a[0]*pow((a[1]/a[0]),3);
cout<<" GP "<<n<<endl;
}
}
}
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a[3],n,i,d,r;
while(1)
{
for( i=0;i<3;i++)
{
cin>>a[i];
}
if(a[0]==0&&a[1]==0&&a[2]==0)
break;
else
{ d=a[1]-a[0];
r=a[2]-a[1];
if(d==r)
{
n=a[0]+3*d;
cout<<" AP "<<n<<endl;
}
else
{
n=a[0]*pow((a[1]/a[0]),3);
cout<<" GP "<<n<<endl;
}
}
}
return 0;
}
No comments:
Post a Comment