Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars
a,b=map(int,input().split())
t,g='',1
while g<a:
g,p=g+1,0
if a%g+b%g<1:
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
print(t)
#Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars
a,b=map(int,input().split())
t,g='',1
while g<a:
g,p=g+1,0
if a%g+b%g<1:
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
print(t)
It'sIt's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars
a,b=map(int,input().split())
t,g='',1
while g<a:
g,p=g+1,0
if a%g+b%g<1:
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
Python 3, (削除) 255 (削除ここまで)(削除) 250 (削除ここまで)(削除) 237 (削除ここまで)(削除) 226 (削除ここまで)(削除) 188 (削除ここまで)(削除) 180 (削除ここまで)(削除) 150 (削除ここまで)(削除) 142 (削除ここまで)(削除) 137 (削除ここまで) 136 chars
a,b=map(int,input().split())
t,g='',1
while g<a:
g,p=g+1,0
if a%g+b%g<1:
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) 137(削除) 137 (削除ここまで) 136 chars
a,b=map(int,input().split())
t,g='',21
while g<a:
g,p=g+1,0
if a%g+b%g<1:
p=0
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
g+=1
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) 137 chars
a,b=map(int,input().split())
t,g='',2
while g<a:
if a%g+b%g<1:
p=0
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
g+=1
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) (削除) 137 (削除ここまで) 136 chars
a,b=map(int,input().split())
t,g='',1
while g<a:
g,p=g+1,0
if a%g+b%g<1:
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) 142(削除) 142 (削除ここまで) 137 chars
a,b=map(int,input().split())
t,g='',2
while g<a:
if a%g+b%g<1:
p=0
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
else:g+=1
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) 142 chars
a,b=map(int,input().split())
t,g='',2
while g<a:
if a%g+b%g<1:
p=0
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
else:g+=1
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.
#Python 3, (削除) 255 (削除ここまで) (削除) 250 (削除ここまで) (削除) 237 (削除ここまで) (削除) 226 (削除ここまで) (削除) 188 (削除ここまで) (削除) 180 (削除ここまで) (削除) 150 (削除ここまで) (削除) 142 (削除ここまで) 137 chars
a,b=map(int,input().split())
t,g='',2
while g<a:
if a%g+b%g<1:
p=0
while a%g+b%g<1:a/=g;b/=g;p+=1
t+='%d^%d '%(g,p)
g+=1
print(t)
It's amazing how much I could shorten this by just skipping stuff (like, you know, finding the gcd)! Also I could reduce 10 more chars by making this a function that expects 2 ints, like some other answers, instead of reading from stdin.