QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#68643 | #691. One Root | ptch | WA | 3ms | 2244kb | C99 | 1.7kb | 2022-12-18 01:31:30 | 2022-12-18 01:31:33 |
Judging History
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);
}
詳細信息
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'