4 条题解

  • 0
    @ 2022-8-2 19:18:42

    cmath库实现

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        double n;
        cin >> n;
        printf("%.2lf",pow(n,1.0/3));
        return 0;
    }
    

    二分查找

    #include <bits/stdc++.h>
    using namespace std;
    int main() 
    {
        double n;
        cin >> n;
        double l = -10000, r = 10000;
        while (r - l >= 1e-8) {
            double mid = (r + l) / 2;
            if (mid * mid * mid >= n) r = mid;
            else l = mid;
        }
        printf("%.2lf", l);
    }
    
    • 0
      @ 2022-7-9 16:17:19
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	double n,b;
      	cin>>n;
      	b=pow(n,1.0/3);
      	printf("%.2lf",b);
      
      • -1
        @ 2023-7-16 18:18:08

        枚举

        #include <iostream>
        using namespace std;
        int n;
        int main(){
            cin>>n;
            for (double i=1;i<=500;i=i+0.0001){
                if((n-i*i*i)<0.0001){
                    printf("%.2f",i);
                    break;
                }
            }
            return 0;
        }
        

        c++

        • -1
          @ 2023-4-1 8:41:08

          蒟蒻的第\texttt{\large\color{#12a1e8}本\color{#50ce50}蒟蒻\color{#12a1e8}的第\color{#c291e8}七\color{#12a1e8}篇\color{#92a1e8}题\color{#92a9d8}解}

          手动开3次方{\large\color{#92a1e8}手动开3次方}

          难度:入门\texttt{\small\color{#e51211}难度:入门}

          last update:2023/4/1


          pow()可以求一个数的多次方(通用于c++和python),是常用函数,然后输出的时候取两位即可


          Python{\large\color{#52a1e8}Python:}

          a=int(input())
          result=float(pow(a,1/3))
          #round(result,2)
          print('%.2f'%result)
          

          C++{\large\color{#52a1e8}C++:}

          #include <bits/stdc++.h>
          using namespace std;
          int main()
          {
           float n,y;
           scanf("%f",&n);
           y=(float)pow (n,1.0/3);
           printf("%.2f\n",y);
           return 0;
          }
          
          • 1

          【苏州NOI】d044: 手动开3次方

          信息

          ID
          51
          时间
          1000ms
          内存
          128MiB
          难度
          2
          标签
          递交数
          311
          已通过
          195
          上传者