FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Competitive-Programming/ASummationProblem.cpp at master · KevinMathewT/Competitive-Programming · GitHub
KevinMathewT
/
Competitive-Programming
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Competitive-Programming
/
ASummationProblem.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (57 loc) · 1.05 KB
Breadcrumbs
Competitive-Programming
/
ASummationProblem.cpp
Copy path
File metadata and controls
67 lines (57 loc) · 1.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
include
<
bits/stdc++.h
>
using
namespace
std
;
typedef
long
long
ll;
#
define
M
998244353
//
Author - Kevin Mathew
//
Birla Institute of Technology, Mesra
ll n, k;
ll a[
2000010
],
pre
[
2000010
];
ll
power
(ll x, ll a){
ll ans =
1
;
//
cout << a << " ";
//
cout << x << " ";
while
(a >
0
){
if
(a &
1
)
ans = ((ans%M) * (x%M)) % M;
x = ((x%M) * (x%M)) % M;
a /=
2
;
}
//
cout << "-" << ans << "\n";
return
ans;
}
void
te
(){
cin >> n >> k;
for
(ll i=
0
;i<n;i++)
cin >> a[i];
ll s[k];
for
(ll i=
0
;i<k;i++){
if
(i ==
0
)
pre
[
0
] = a[
0
];
else
pre
[i] = a[i] +
pre
[i-
1
];
s[i] =
0
;
}
for
(ll i=
0
;i<n;i++){
ll t =
0
;
for
(ll j=i;j<n;j++){
t = (t + a[j]) % M;
//
cout << t << "-";
for
(ll i=
0
;i<k;i++){
s[i] = (s[i] +
power
(t, i+
1
)) % M;
}
}
//
cout << "\n";
}
for
(ll i=
0
;i<k;i++)
cout << s[i] <<
"
"
;
}
int
main
()
{
freopen
(
"
input.txt
"
,
"
r
"
, stdin);
//
Comment
freopen
(
"
output.txt
"
,
"
w
"
, stdout);
//
this out.
ios::sync_with_stdio
(
false
);
//
Not
cin.
tie
(
NULL
);
//
this.
cout.
tie
(
0
);
//
or this.
te
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL