fork download
  1. # -*- coding: utf-8 -*-
  2. from cmath import *
  3. def comp_root(x, p):
  4. if not isinstance( p, int ) or p <= 0 :
  5. raise ValueError("comp_root: only positive int accepted as power!")
  6. return [ rect( pow(abs(x),1/p), (phase(x)+2*pi*n)/p )
  7. for n in range(p)
  8. ]
  9.  
  10. for square in comp_root(27,3):
  11. for triangle in comp_root(24/square, 3):
  12. for circle in comp_root(96/square/triangle, 2):
  13. answer = circle + square * triangle
  14. print("□ = {0:.3f} △ = {1:.3f} ○ = {2:.3f} ? = {3:.3f}".format(square, triangle, circle, answer) )
  15.  
Success #stdin #stdout 0.02s 10048KB
stdin
Standard input is empty
stdout
□ = 3.000+0.000j △ = 2.000+0.000j ○ = 4.000+0.000j ? = 10.000+0.000j
□ = 3.000+0.000j △ = 2.000+0.000j ○ = -4.000+0.000j ? = 2.000+0.000j
□ = 3.000+0.000j △ = -1.000+1.732j ○ = 2.000-3.464j ? = -1.000+1.732j
□ = 3.000+0.000j △ = -1.000+1.732j ○ = -2.000+3.464j ? = -5.000+8.660j
□ = 3.000+0.000j △ = -1.000-1.732j ○ = 2.000+3.464j ? = -1.000-1.732j
□ = 3.000+0.000j △ = -1.000-1.732j ○ = -2.000-3.464j ? = -5.000-8.660j
□ = -1.500+2.598j △ = 1.532-1.286j ○ = 3.064-2.571j ? = 4.106+3.338j
□ = -1.500+2.598j △ = 1.532-1.286j ○ = -3.064+2.571j ? = -2.022+8.480j
□ = -1.500+2.598j △ = 0.347+1.970j ○ = 0.695+3.939j ? = -4.944+1.887j
□ = -1.500+2.598j △ = 0.347+1.970j ○ = -0.695-3.939j ? = -6.333-5.991j
□ = -1.500+2.598j △ = -1.879-0.684j ○ = 3.759+1.368j ? = 8.355-2.489j
□ = -1.500+2.598j △ = -1.879-0.684j ○ = -3.759-1.368j ? = 0.837-5.225j
□ = -1.500-2.598j △ = 1.532+1.286j ○ = 3.064+2.571j ? = 4.106-3.338j
□ = -1.500-2.598j △ = 1.532+1.286j ○ = -3.064-2.571j ? = -2.022-8.480j
□ = -1.500-2.598j △ = -1.879+0.684j ○ = 3.759-1.368j ? = 8.355+2.489j
□ = -1.500-2.598j △ = -1.879+0.684j ○ = -3.759+1.368j ? = 0.837+5.225j
□ = -1.500-2.598j △ = 0.347-1.970j ○ = 0.695-3.939j ? = -4.944-1.887j
□ = -1.500-2.598j △ = 0.347-1.970j ○ = -0.695+3.939j ? = -6.333+5.991j