[Làm Quen OJ]. Bài 5. Hàm sqrt và cbrt

View as PDF

Submit solution


Points: 1.00 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Problem source:
28Tech
Problem type
Allowed languages
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Cho số nguyên dương N, nhiệm vụ của bạn là tính căn bậc 2 và căn bậc 3 của N.


Đầu vào

Dòng duy nhất chứa số nguyên dương N


Ràng buộc

1<=N<=10^9


Đầu ra

Dòng 1 in ra căn bậc 2 của N với 2 số sau dấu phẩy

Dòng 2 in ra căn bậc 3 của N với 3 số sau dấu phẩy


Ví dụ

Input 01
65
Output 01
8.06
4.021

Comments

Please read the guidelines before commenting.



  • 0
    nonamexxx  commented on Jan. 9, 2026, 12:35 p.m.

    import java.util.Scanner;

    public class Bai1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double x = Math.sqrt(n);
        double y = Math.cbrt(n);
        System.out.printf("%.2f\n%.3f\n", x, y);
    }
    

    }


  • 1
    L8_DuongThanhKhiem  commented on Nov. 20, 2025, 2:46 p.m.

    FULL AC:

    #include <bits/stdc++.h>
    using namespace std;
    int n;
    int main(){
        cin >> n;
        double x = sqrt(n);
        double y = cbrt(n);
        cout << fixed << setprecision(2) << x << endl;
        cout << fixed << setprecision(3) << y;
        return 0;
    }
    

  • -9
    Nah_I_am_Nam  commented on May 11, 2024, 2:24 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -11
    Itachi  commented on April 30, 2024, 7:44 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.