QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#702966 | #5547. Short Function | MeatInTheMiddle# | WA | 1ms | 5808kb | C++17 | 2.1kb | 2024-11-02 16:52:45 | 2024-11-02 16:52:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fastio (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
typedef long long ll;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int MAXSIZE = 2000000;
const long long INF = 1e18 + 5;
const double EPSILON = 1e-14;
const ll DIV = 998244353;
const long double pi = 3.14159265358979323846264338327950288419716939937510L;
ll n, k;
ll arr[101011];
ll mula[101011];
ll pinv[101011];
ll POW(ll a, ll r, ll D)
{
ll ret = 1;
while (r)
{
if (r & 1)
{
ret = ret * a % D;
}
r >>= 1;
a = (a * a) % D;
}
return ret;
}
ll opi(ll a)
{
ll t = a;
vector<ll> v;
for (ll i = 2; i * i <= t; i++)
{
if (t % i == 0)
{
while (t % i)
t /= i;
v.push_back(i);
}
}
if (t > 1)
v.push_back(t);
for (auto i : v)
a = a * (i - 1) / i;
return a;
}
ll ans[101011];
int main()
{
fastio;
cin >> n >> k;
mula[0] = 1;
pinv[0] = 1;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
mula[i] = mula[i - 1] * arr[i] % DIV;
pinv[i] = pinv[i - 1] * POW(arr[i], DIV - 2, DIV) % DIV;
}
if (k == 0)
{
for (int i = 1; i <= n; i++)
cout << arr[i] << " ";
return 0;
}
ll k2 = POW(2, k, DIV);
ll kn = k2 % n;
ll pi = opi(DIV - 1);
for (int i = 1; i <= n; i++)
{
ans[i] = POW(mula[n], (POW(2, k, DIV - 1) / n), DIV) % DIV;
if (ans[i] == 0)
ans[i] = 1;
if (kn)
{
if (i + kn - 1 > n)
{
ans[i] = ans[i] * mula[n] % DIV * pinv[i - 1] % DIV * mula[(i + kn - 1 - n)] % DIV;
}
else
{
ans[i] = ans[i] * mula[i + kn - 1] % DIV * pinv[i - 1] % DIV;
}
}
}
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3796kb
input:
5 2 1 2 3 4 5
output:
24 120 60 40 30
result:
ok 5 number(s): "24 120 60 40 30"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
8 3 12 5 16 14 10 6 9 2
output:
14515200 14515200 14515200 14515200 14515200 14515200 14515200 14515200
result:
ok 8 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
6 10 3 7 8 2 9 5
output:
56347321 169041963 833775940 811788154 844769833 639990479
result:
ok 6 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 5808kb
input:
2 100 1 2
output:
917380677 917380677
result:
ok 2 number(s): "917380677 917380677"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 3584kb
input:
119 1000000000 179906895 883175111 831258723 617910763 41850684 952649819 667608052 992898634 871657688 261948841 858714230 452797779 698675390 39373823 268148685 762575950 789163136 676908074 134428624 583625412 549545785 415007638 564283552 596519552 575204092 884934270 632550339 21505752 66058955...
output:
550063354 402831729 217560313 619719195 923093885 597770905 772423998 552789294 911190434 268226723 616257649 520298085 523476541 989749586 922253724 474433635 9796369 530647486 596324257 545642450 590937715 442904782 316421495 591660074 101798462 641141024 862667641 296983036 434339072 34798065 387...
result:
wrong answer 1st numbers differ - expected: '375116230', found: '550063354'