首页 > 试题广场 >

单组_spj判断浮点误差

[编程题]单组_spj判断浮点误差
  • 热度指数:5174 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
给定一个圆的半径 r ,请你求出该圆的面积。
保证半径 r 是整数。
如果你的答案和标准答案的误差不超过 10^{-3} ,即可通过本题。

输入描述:
第一行有一个整数 n\ (\ 1 \leq n \leq 10^3\ )


输出描述:
输出一个数字,代表圆的面积。
示例1

输入

123

输出

47529.155256
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = 0;
        if(in.hasNextInt()){
            r = in.nextInt();
            System.out.println(Math.PI*r*r);
        }
        in.close();

    }
}

发表于 2025-04-07 11:54:22 回复(0)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        //???????????????????
    double s = 3.14159265358979323846264338327950288419716939937510*r*r;
        System.out.println(String.format("%.6f", s));
    }
}
发表于 2024-09-27 17:52:45 回复(0)
        int r = in.nextInt();
        System.out.println(String.format("%.6f",r*r*Math.PI));

发表于 2025-04-19 11:11:49 回复(0)
#include <iostream>
#include <cmath>
using namespace std;
// #define _USE_MATH_DEFINES

int main() {
    int n=0;
    double pi=M_PI;
    cin>>n;
    double ans=pi*n*n;
    printf("%f",ans);
    return 0;
}

发表于 2025-04-18 22:10:32 回复(0)
import math
r = int(input())
pi = math.pi
area  = pi * pow(r,2)
print(area)
发表于 2025-04-17 11:01:11 回复(0)
import math
r = int(input())
print(f"{math.pi*r*r:0.6f}")
发表于 2025-03-20 10:16:58 回复(0)
#include <stdio.h>
#include <math.h>
int main() {
    int r;
    scanf("%d", &r);
    printf("%f",3.14159265358979323846*r*r);
    return 0;
}
发表于 2025-03-17 19:58:23 回复(0)
真会考这种吗
发表于 2025-03-11 17:25:03 回复(0)
此题考查基础,属于基础题
#include <stdio.h>

int main() {
    int  r;
    scanf("%d",&r);
    double  s;
    s=3.1415926*r*r;
    printf("%lf",s);
    return 0;
}
发表于 2025-02-25 20:07:23 回复(0)
题目说误差不超过10^-3,需要判断到6位么?不懂。
发表于 2025-02-21 22:27:54 回复(0)
#include <iostream>
using namespace std;

int main() {
    int r;
    float pi = 3.14159265;
    cin>>r;
    float s = pi*r*r;
    printf("%f",s);
}
发表于 2025-02-12 16:51:57 回复(0)
import math
print(f"{math.pi * int(input()) ** 2:.6f}")

发表于 2024-12-04 12:47:22 回复(0)
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        float r=in.nextFloat();
        System.out.printf("%.6f\n",Math.PI*Math.pow(r,2));
    }
}
发表于 2024-10-30 16:59:01 回复(0)
 


发表于 2024-09-12 10:06:20 回复(0)
c++怎么做?
发表于 2024-09-11 16:55:04 回复(0)

import math
n=int(input())
s=(math.pi)*n**2
print("{:.6f}".format(s))

发表于 2024-08-29 21:21:20 回复(0)
#include <asm-generic/errno.h>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main() {
    int a, b;
    while (cin >> a) { // 注意 while 处理多个 case
        double pi=3.1415926;
        cout<< std::fixed << std::setprecision(6) << pi*pow(a, 2)<< endl;
    }
}
发表于 2024-08-21 11:07:43 回复(1)