怀疑人生的入门题,求助

P2433 【深基1-2】小学数学 N 合一

TLE_Forever @ 2020-04-18 18:50:12

#include<iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
const double pai = 3.141593;
int main() {
    int T;
    cin >> T;
    if (T == 1) {
        cout << "I love Luogu!";
    }
    else if (T == 2) {
        cout << 2 + 4 << " " << 10 - 2 - 4;
    }
    else if (T == 3) {
        cout << 3 << endl << 12 << endl << 2;
    }
    else if (T == 4) {
        double b = 500.000000 / 3.000000;
        cout << setiosflags(ios::fixed) << setprecision(3) << b;
    }
    else if (T == 5) {
        cout << (260 + 220) / (12 + 20);
    }
    else if (T == 6) {
        cout << sqrt(pow(6, 2) + pow(9, 2));
    }
    else if (T == 7) {
        cout << 100 + 10 << endl;
        cout << 110 - 20 << endl;
        cout << 90 - 90 << endl;
    }
    else if (T == 8) {
        cout << double(1.0*pai * 10.0) << endl << double(1.0*pai * 25.0) << endl << double(1.0*double(4 / 3) * pai * 125.0) << endl;
    }
    else if (T == 9) {
        cout << 2 * (2 * (2 * (1 + 1) + 1) + 1) << endl;
    }
    else if (T == 10) {
        cout << 9;
    }
    else if (T == 11) {
        cout << 1.0 * 100 / 3;
    }
    else if (T == 12) {
        cout << int('M' - 'A') + 1 << endl;
        cout << char('A' + 17);
    }
    else if (T == 13) {
        cout << (int)(pow(double(double(4 / 3) * pai * double(4 * 4 * 4 + 10 * 10 * 10)), double(1 / 3)));
    }
    else if (T == 14) {
        cout << 50;
    }
    return 0;
}

请问T8和T13为什么过不了?

话说这是小学数学题吗?这是信息学入门题吗?都快怀疑人生了QAQ


by luosw @ 2020-04-18 18:51:59

@Kenny_Plus 您好,得是longdouble


by TLE_Forever @ 2020-04-18 18:54:31

发现公式写错了,改了一下,T8对了

但是T13还是不对……


by 囧仙 @ 2020-04-18 18:55:47

(别信这是小学数学题。它起码有初中-的难度(


by TLE_Forever @ 2020-04-18 18:56:38

但是T13怎么拯救一下……

题集就差这一个了


by 囧仙 @ 2020-04-18 19:00:54

@Kenny_Plus 这种纯数学题,只能用公式吧(

若一个球体的半径为r,则它的体积为:

r^3\times \dfrac{4}{3}

另外,\rm C++里面的\rm pow函数可以直接开三次方根,也就是\texttt{pow(x,1.0/3.0)},表示x^{\frac{1}{3}},也就是\sqrt[3]{x}


by 老子是北瓜 @ 2020-04-18 19:06:43

@Kenny_Plus 你需要看题解


by HsKr @ 2020-04-18 19:13:14

第二篇题解好(


by hkhkkk @ 2020-04-18 19:13:28

emmmm


by Lylighte @ 2020-04-18 19:16:18

@HsKr 真好

自愧不如(


by hkhkkk @ 2020-04-18 19:16:51

@Kenny_Plus 你这个程序,double(1 / 3)=0啊, 你要改成1.0/3


| 下一页