how to perform operations like % and / on numbers of about 20 digits i.e >2^64 …

unsigned long long doesnt work beyond 2^64

this may help…

code:-

```
p=int(input()) #multi line
q=int(input()) #input
print (p/q)
arr=input().split() #single line input
print (int(arr[0])/int(arr[1]))
```

input:-

```
10
2
10 2
```

output:-

```
2.0
2.0
```

in python all inputs are in the form of strings…so we need to typecast to int!!!

translate this code into python…

```
#include<iostream.h>
main()
{ int t;
unsigned long long x,n;
cin>>t;
while(t--)
{
cin>>x>>n;
cout<<x+(x/(n-1))-(x%n)<<"\n";
}
return 0;
}
```

problem link…

hey yr code is giving runtime error (nzec)

@calam2pm

ur converted code in python

```
import sys
test=int(raw_input())
while test!=0:
x,n = map(int,sys.stdin.readline().split())
temp=x+(x/(n-1))-(x%n)
print temp
test=test-1
```

Remember u take input as a string in python

I havent checked ur logic!!

Hope this helps…

#include<iostream.h>

main()

{ int t;

```
unsigned long long x,n,noc;
cin>>t;
while(t--)
{
cin>>x>>n;
noc=x;
while(noc>=n)
{
x++;
noc=noc-n+1;
}
cout<<x<<"\n";
}
return 0;
```

}

plzz translate this as well…

see this code…LINK!!!

this may be giving the correct ans…but it seems it will exceed the time limit!!!

hey i have optimized my code … but it still is not submitted…

new code .:

```
#include<iostream.h>
main()
{ int t;
unsigned long long x,n,noc;
cin>>t;
while(t--)
{
cin>>x>>n;
noc=x;
while(noc>=n)
{
x=x+noc/n;
noc=noc/n+noc%n;
}
cout<<x<<"\n";
}
return 0;
}
```

t=int(input())

while(t>0):

t=t-1

arr=input().split()

x=int(arr[0])

n=int(arr[1])

noc=x

while(noc>=n):

x=x+int(int(noc)/int(n));

noc=int(int(noc)/int(n))+int(noc)%n;

print(int(x))

this is the code in python…but it gives WA!!!

check if u r using new line …

hey … then whats wrong wid spoj people …

any sugestions frm yr side…

hey tell me one thing more …

u were using int datatype even for very long calculations …

is it feasable in python… :o

in python int can store very large values…see this code…it stores 200!(200 factorial)…link!!!

u can use python…

yup it is using a newline!!!

i think u need to rethink on your algo…start from scratch…look at it from another perspective…may be that may help…