数学求解

按顺序使用全部数字,同步返回首个精确解

POST/ordered-digit-solver
公开访问

支持 +、-、*、/、整数次幂、阶乘和取负。每个中间数约分后的分子绝对值与分母均小于 2^128;整数指数绝对值最多 12;阶乘参数为 0–12 的整数;全表达式最多 2 个一元运算,一元连续嵌套深度最多 2。排除除零、0^0 和零的负次幂。固定遍历顺序,找到首个解立即返回。no_solution 表示上述有限规则范围内确认无解;limit_reached 表示搜索预算耗尽。 访问类别:匿名 API,可携带 Token 使用独立额度

请求体

application/json
digits必填
string · 按原始顺序逐个使用全部数字,每个数字独立参与运算 · 最短:1 字符 · 最长:10 字符 · 格式:^[0-9]+$
target必填
string · 精确目标值,支持整数、有限小数及分数,例如 325、0.1、1/3 · 最短:1 字符 · 最长:80 字符 · 格式:^-?(?:\d+(?:\.\d+)?|\d+\/[1-9]\d*)$

响应

200 found、规则范围内确认无解,或达到搜索限制

application/json

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "found",
        "no_solution",
        "limit_reached"
      ]
    },
    "expression": {
      "type": [
        "string",
        "null"
      ],
      "description": "found 时返回使用 ^ 表示乘方、! 表示阶乘的完整括号表达式"
    },
    "value": {
      "type": [
        "string",
        "null"
      ],
      "description": "found 时返回约分后的精确整数或分数"
    },
    "rulesVersion": {
      "type": "string"
    },
    "limits": {
      "type": "object",
      "properties": {
        "maxDigits": {
          "type": "integer"
        },
        "maxUnaryOperators": {
          "type": "integer"
        },
        "maxUnaryDepth": {
          "type": "integer"
        },
        "maxFactorialArgument": {
          "type": "integer"
        },
        "maxAbsoluteExponent": {
          "type": "integer"
        },
        "maxValueBits": {
          "type": "integer"
        },
        "maxStates": {
          "type": "integer"
        },
        "maxWork": {
          "type": "integer"
        }
      },
      "required": [
        "maxDigits",
        "maxUnaryOperators",
        "maxUnaryDepth",
        "maxFactorialArgument",
        "maxAbsoluteExponent",
        "maxValueBits",
        "maxStates",
        "maxWork"
      ]
    },
    "terminationReason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "max_work",
        "max_states",
        null
      ]
    },
    "stats": {
      "type": "object",
      "properties": {
        "work": {
          "type": "integer"
        },
        "states": {
          "type": "integer"
        }
      },
      "required": [
        "work",
        "states"
      ]
    }
  },
  "required": [
    "status",
    "expression",
    "value",
    "rulesVersion",
    "limits",
    "terminationReason",
    "stats"
  ]
}
400 请求校验或执行失败

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
401 凭据无效、停用、过期或缺少所需 Token

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
403 需要管理员 Token

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
413 请求体过大

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
415 请求内容类型无效

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
429 请求过于频繁,Retry-After 为建议等待秒数;匿名额度及认证保护在各 Cloudflare 地点近似计数,Token 业务额度使用 D1 原子计数

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
500 内部执行失败

application/json

{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "enum": [
                  "body",
                  "query",
                  "path",
                  "header"
                ]
              },
              "field": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "location",
              "field",
              "code",
              "message"
            ]
          }
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}

在线调试

必填
必填
调用示例
curl -X POST 'https://evax.top/ordered-digit-solver' \
  -H 'Content-Type: application/json' \
  --data-raw '{"digits":"350234","target":"325"}'

响应

等待请求