不是哥们,6,8,11,13哪里错了啊

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

Mihawk1124 @ 2024-09-30 15:38:34

#include <stdio.h>
#include <math.h>
#define PI 3.141593

int main()
{
    int num;
    scanf("%d", &num);
    switch(num)
    {
        case 1: printf("I love Luogu!\n"); break;
        case 2: printf("%d %d\n", 6, 4); break;
        case 3: printf("%d\n%d\n%d\n", 3, 12, 2); break;
        case 4: printf("%.3lf\n", 166.667); break;
        case 5: printf("%d\n", 15); break;
        case 6: printf("%d\n", (int)sqrt(117)); break;
        case 7: printf("%d\n%d\n%d\n", 110, 90, 0); break;
        case 8: printf("%lf\n%lf\n%lf\n", PI*10, PI*5*5, 4.0/3*PI*5*5*5); break;
        case 9: printf("%d\n", 22); break;
        case 10: printf("%d\n", 9); break;
        case 11: printf("%d\n", 33); break;
        case 12: printf("%d\n%c\n", 13, 'R'); break;
        case 13: printf("%d\n", floor(pow(PI*1064*4/3, 1/3))); break;
        case 14: printf("%d", 50); break;
    }
    return 0;
}

by luojingjie @ 2024-09-30 15:56:30

问题出在输出的精度上


by Marc206721 @ 2024-10-21 21:08:29

@luojingjie 请问为什么我这样写也得不了满分?```c

include <stdio.h>

include <math.h>

define PI 3.141593

double v(int l) { return 4.0 / 3.0 PI pow(l, 3); }

int main() { int answer; scanf("%d", &answer);

switch (answer) {
    case 1:
        printf("I love Luogu!\n");
        break;
    case 2:
        printf("%d %d\n", 6, 4);
        break;
    case 3:
        printf("%d\n%d\n%d\n", 3, 12, 2);
        break;
    case 4:
        {
            double v = 500;
            printf("%.3lf\n", v / 3);
        }
        break;
    case 5:
        printf("%d\n", 15);
        break;
    case 6:
        printf("%lf\n", sqrt(6.0 * 6.0 + 9.0 * 9.0));
        break;
    case 7:
        {
            static int n = 100;
            printf("%d\n", n + 10);
            printf("%d\n", n -10);
            printf("%d\n", 0);
        }
        break;
    case 8:
        {
            double c = 2*PI*5;
            double s = PI * pow(5,2);
            double v3 = 4.0/3.0* PI * pow(5,3);
            printf("%lf\n%lf\n%lf\n",c,s,v3);
        }
        break;
    case 9:
        printf("%d\n", 22);
        break;
    case 10:
        printf("%d\n", 9);
        break;
    case 11:
        {
            double time = 100.0/3.0;
            printf("%lf\n",time);
        }
        break;
    case 12:
        printf("%d\n%c\n", 13, 'R');
        break;
    case 13:
        {
            double va = v(4) + v(10);
            double len = pow(va, 1.0 / 3.0);
            printf("%.0f\n", len);
        }
        break;
    case 14:
        printf("%d\n", 50);
        break;

}

return 0;

}


|