Bishops problem spoj link-https://www.spoj.com/problems/BISHOPS/

what is wrong with my code
#include <iostream.h>
using namespace std;

int main()
{
long long int n;
while(cin>>n)
{

if(n==0)
{
	cout<<0;

}
else if(n==1)
{
	cout<<1;

}
else
{
	cout<<2*(n-1);

}

}

return 0;
}

One thing you need to correct is changing line after printing answer for each testcase

1 Like

the constrains…
[1 <= N <= 10^100]
Can’t just use long long int for this.

1 Like

the constraints are very big we can’t use long long int for this but you can use BigInteger class of java

ok,thanks but should i use for c++, i dont know java

You’ll have to implement it using arrays in c++. google it.