Submission #6812051


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

int p, x[3005], y[3005], inv[3005];

int main() {
	scanf("%d", &p);
	for (int i = 1; i < p; i++)
		for (int j = 1; j < p; j++)
			if (i * j % p == 1)
				inv[i] = j;
	x[0] = 1;
	for (int i = 0; i < p; i++) {
		for (int j = p; j; j--)
			x[j] = (x[j - 1] + x[j] * (p - i)) % p;
		x[0] = x[0] * (p - i) % p;
	}
	for (int i = 0; i < p; i++) {
		int mul;
		scanf("%d", &mul);
		for (int j = 0; j < p; j++)
			if (i != j)
				mul = mul * inv[(p + i - j) % p] % p;
		int la = x[p];
		for (int j = p - 1; j >= 0; j--) {
			y[j] = (y[j] + la * mul) % p;
			la = (x[j] + la * i) % p;
		}
	}
	for (int i = 0; i < p; i++)
		printf("%d%c", y[i], " \n"[i == p - 1]);
}

Submission Info

Submission Time
Task F - Polynomial Construction
User nhho
Language C++14 (GCC 5.4.1)
Score 600
Code Size 737 Byte
Status AC
Exec Time 235 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &p);
                 ^
./Main.cpp:21:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &mul);
                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 43
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 226 ms 256 KB
b08 AC 235 ms 256 KB
b09 AC 235 ms 256 KB
b10 AC 235 ms 256 KB
b11 AC 226 ms 256 KB
b12 AC 226 ms 256 KB
b13 AC 231 ms 256 KB
b14 AC 231 ms 256 KB
b15 AC 228 ms 256 KB
b16 AC 234 ms 256 KB
b17 AC 231 ms 256 KB
b18 AC 231 ms 256 KB
b19 AC 231 ms 256 KB
b20 AC 232 ms 256 KB
b21 AC 234 ms 256 KB
b22 AC 235 ms 256 KB
b23 AC 235 ms 256 KB
b24 AC 235 ms 256 KB
b25 AC 235 ms 256 KB
b26 AC 231 ms 256 KB
b27 AC 232 ms 384 KB
b28 AC 227 ms 256 KB
b29 AC 227 ms 256 KB
b30 AC 226 ms 256 KB
b31 AC 226 ms 256 KB
b32 AC 226 ms 256 KB
b33 AC 1 ms 256 KB
b34 AC 1 ms 256 KB
b35 AC 226 ms 256 KB
b36 AC 229 ms 256 KB
b37 AC 73 ms 256 KB
b38 AC 129 ms 256 KB
b39 AC 1 ms 256 KB
b40 AC 103 ms 256 KB
b41 AC 3 ms 256 KB
b42 AC 33 ms 256 KB
b43 AC 144 ms 256 KB