QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68643#691. One RootptchWA 3ms2244kbC991.7kb2022-12-18 01:31:302022-12-18 01:31:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-18 01:31:33]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:2244kb
  • [2022-12-18 01:31:30]
  • 提交

answer

#include <stdio.h>
#include <math.h>
#pragma warning(disable: 4996)
#include <time.h>
inline int max(int a, int b) {
    return a > b ? a : b;
}

int n = 0;
int m = 0;
int p = 0;
int q = 0;

double f(double x) {
    return pow(x, n) + x * (double)p;
}

double fprime(double x) {
    return (double)n * pow(x, (double)n - 1) + (double)p;
}

int main()
{
    scanf("%d %d", &n, &m);
    long long ans = 0;
    if (n % 2 == 1) { // 홀수차수
        ans += (m + 1) * (2 * m + 1);
        for (int i = 1; i <= m; i++) {
            p = -i;
            double root = pow((double)i / n, 1 / ((double)n - 1));
            double crit = f(root);
            //printf("%lf\n", root);
            //printf("%lf\n", crit);
            //printf("%d\n", ans);
            //ans += 2 * max(m - ceil(-crit+1e-8) + 1, 0);
            //printf("%d\n", 2 * max(m - ceil(-crit+1e-8) + 1, 0));
            for (int j = max((int)(-crit-2), 0); j <= m; j++) {
                if (j > -crit) {
                    ans += 2 * (m - j + 1);
                    break;
                }
            }
        }
    }
    else if (n == 2) {
        for (int i = -m; i <= m; i++) {
            if (abs(2 * i) <= m && i * i <= m) {
                ans += 1;
            }
        }
    }
    else {
        ans += 1;
        for (int i = 1; i <= m; i++) {
            p = -i;
            double root = pow((double)i / n, 1 / ((double)n - 1));
            double crit = f(root);
            //printf("%lf\n", crit);
            if (fabs(crit - (int)(crit)) < 1e-6 && fabs(crit) <= m) {
                ans += 2;
            }

        }
    }
    printf("%lld\n", ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 1996kb

input:

2 4

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: 0
Accepted
time: 1ms
memory: 2244kb

input:

3 5

output:

96

result:

ok 1 number(s): "96"

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 1924kb

input:

2 1000000

output:

467169

result:

wrong answer 1st numbers differ - expected: '2001', found: '467169'