import sys
from collections import deque
mod = 998244353
def main():
n, k = map(int, sys.stdin.readline().split())
g = [[] for _ in range(n + 1)]
for _ in range(n - 1):
u, v = map(int, sys.stdin.readline().split())
g[u].append(v)
g[v].append(u)
ans = 0
for c in range(1, n + 1):
q = deque()
q.append(c)
d = [-1] * (n + 1)
d[c] = 0
parent = [-1] * (n + 1)
while q:
u = q.popleft()
for v in g[u]:
if d[v] == -1:
d[v] = d[u] + 1
parent[v] = u
q.append(v)
children = {}
for u in range(1, n + 1):
if u == c or d[u] == -1:
continue
p = u
while parent[p] != c and parent[p] != -1:
p = parent[p]
if parent[p] == c:
children.setdefault(p, []).append(u)
max_d = max(d)
for l in range(1, max_d + 1):
cnt = []
for child, nodes in children.items():
cnt_i = 0
for u in nodes:
if d[u] == l:
cnt_i += 1
if cnt_i > 0:
cnt.append(cnt_i)
m = len(cnt)
if m < k:
continue
dp = [0] * (k + 1)
dp[0] = 1
for c_i in cnt:
for x in range(min(k, len(cnt)), 0, -1):
dp[x] = (dp[x] + dp[x - 1] * c_i) % mod
ans = (ans + dp[k]) % mod
print(ans)
if __name__ == "__main__":
main()
Newtree
Rubrik โ
๐1
import sys
MOD=998244353
def mult(a, b, K):
res = [0] * K
for i in range(K):
ai = a[i]
if ai:
for j in range(K):
res[(i + j) % K] = (res[(i + j) % K] + ai * b[j]) % MOD
return res
def power(a, e, K):
res = [0] * K
res[0] = 1
while e:
if e & 1:
res = mult(res, a, K)
a = mult(a, a, K)
e >>= 1
return res
def main():
input = sys.stdin.read
data = list(map(int, input().split()))
ptr = 0
N = data[ptr]
P = data[ptr + 1]
K = data[ptr + 2]
ptr += 3
M = data[ptr]
ptr += 1
L = data[ptr:ptr + M]
ptr += M
C = [P // K + (1 if j > 0 and j <= P % K else 0) for j in range(K)]
LC = [0] * K
for x in L:
LC[x % K] += 1
Cn = [(C[j] - LC[j]) % MOD for j in range(K)]
T = power(C, N, K)[0]
B = power(Cn, N, K)[0]
print((T - B) % MOD)
main()
Lucky Charm
Rubrik โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: McAfee
Batch eligible: 2025 and 2026 grads
1) Software Engineering Intern
Apply: https://careers.mcafee.com/global/en/job/MCAFGLOBALJR0031354ENGLOBALEXTERNAL/Software-Engineering-Intern
2) Graduate Technical Intern
Apply: https://careers.mcafee.com/global/en/job/JR0031351/Graduate-Technical-Intern
3) Graduate Technical Intern
Apply: https://careers.mcafee.com/global/en/job/JR0031352/Graduate-Technical-Intern
Batch eligible: 2025 and 2026 grads
1) Software Engineering Intern
Apply: https://careers.mcafee.com/global/en/job/MCAFGLOBALJR0031354ENGLOBALEXTERNAL/Software-Engineering-Intern
2) Graduate Technical Intern
Apply: https://careers.mcafee.com/global/en/job/JR0031351/Graduate-Technical-Intern
3) Graduate Technical Intern
Apply: https://careers.mcafee.com/global/en/job/JR0031352/Graduate-Technical-Intern
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Drona Pay is hiring for Data Engineering - Intern (Remote)
Experience : 0 - 1 year's
Expected Stipend : 5-6 LPA
Apply here : https://wellfound.com/jobs/3129311-data-engineering-intern
Experience : 0 - 1 year's
Expected Stipend : 5-6 LPA
Apply here : https://wellfound.com/jobs/3129311-data-engineering-intern
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Meesho is hiring Senior Business Associate
MBA grads ( Tier l )
2023/2024 passouts
Apply Here : https://forms.gle/X6XwQ7sUq8eKeeCL8
MBA grads ( Tier l )
2023/2024 passouts
Apply Here : https://forms.gle/X6XwQ7sUq8eKeeCL8
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Mokkup.ai is hiring Product Manager
For 2022, 2023, 2024 grads
Location: Remote
https://www.linkedin.com/jobs/view/4036407648
For 2022, 2023, 2024 grads
Location: Remote
https://www.linkedin.com/jobs/view/4036407648
Linkedin
Mokkup.ai hiring Product Manager in India | LinkedIn
Posted 7:37:10 AM. Product Manager | Remote | Immediate Joining
Hiring for our product: https://mokkup.ai/
WithโฆSee this and similar jobs on LinkedIn.
Hiring for our product: https://mokkup.ai/
WithโฆSee this and similar jobs on LinkedIn.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
MindTickle is hiring Front-end Engineer
For 2021, 2022, 2023 grads
Location: Bangalore
https://jobs.lever.co/mindtickle/011afcfc-09da-48f6-8acc-d49a13791327/apply?source=LinkedIn
For 2021, 2022, 2023 grads
Location: Bangalore
https://jobs.lever.co/mindtickle/011afcfc-09da-48f6-8acc-d49a13791327/apply?source=LinkedIn
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Zoom is hiring for Web DevOps Engineer
Experience: 0 - 1 year's
Expected Salary: 15-30 LPA
Apply here: https://zoom.wd5.myworkdayjobs.com/Zoom/job/Bangalore-IND/Web-DevOps-Engineer_R14714-1?source=linkedin
๐Baxter is hiring for Eng I, Software (0-2 years)
Experience: 0 - 1 year's
Expected Salary: 6-12 LPA
Apply here: https://jobs.baxter.com/en/job/-/-/152/71393509744?source=rd_linkedin_jobposting
Experience: 0 - 1 year's
Expected Salary: 15-30 LPA
Apply here: https://zoom.wd5.myworkdayjobs.com/Zoom/job/Bangalore-IND/Web-DevOps-Engineer_R14714-1?source=linkedin
๐Baxter is hiring for Eng I, Software (0-2 years)
Experience: 0 - 1 year's
Expected Salary: 6-12 LPA
Apply here: https://jobs.baxter.com/en/job/-/-/152/71393509744?source=rd_linkedin_jobposting
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Check out this job at GrowthXยฎ: https://www.linkedin.com/jobs/view/4042232766
Linkedin
GrowthXยฎ hiring Backend Developer Intern (Remote) in Bengaluru, Karnataka, India | LinkedIn
Posted 4:54:13 PM. About GrowthXGrowthX is a membership club for leaders & founders. Our members are from GoogleโฆSee this and similar jobs on LinkedIn.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
๐ We're Hiring a QA Intern! | Nancy Pairda
๐ We're Hiring a QA Intern! ๐
Looking for an exciting opportunity to kickstart your career in Quality Assurance?
Roxiler is looking for a talented QA Intern specializing in Automation Testing and Selenium to join our team!
What weโre looking for:
- Strongโฆ
Looking for an exciting opportunity to kickstart your career in Quality Assurance?
Roxiler is looking for a talented QA Intern specializing in Automation Testing and Selenium to join our team!
What weโre looking for:
- Strongโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Check out this job at HoloHire: https://www.linkedin.com/jobs/view/4051629407
Linkedin
HoloHire hiring Product Management Intern (Remote) in Greater Kolkata Area | LinkedIn
Posted 9:21:45 AM. Are you passionate about developing innovative products and driving user satisfaction? We areโฆSee this and similar jobs on LinkedIn.
def solution(p, q, r):
factorial_q = math.factorial(q)
result = pow(p, factorial_q, r)
return result
Uber โ
#define ll long long
#define N 110
#define MOD 1000000007
int solution(string p, string q, string r) {
int n = p.size();
int m = q.size();
int k = r.size();
// 1-indexing
p = "*" + p;
q = "*" + q;
r = "*" + r;
ll dp[N][N][N] = {}; // Initialize the dp array to zero
dp[0][0][0] = 1; // Base case
// Fill the dp table
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
for (int len = 0; len < k; len++) {
if (dp[i][j][len]) {
// Check the next characters from string p
for (int ni = i + 1; ni <= n; ni++) {
if (p[ni] == r[len + 1]) {
dp[ni][j][len + 1] = (dp[ni][j][len + 1] + dp[i][j][len]) % MOD;
}
}
// Check the next characters from string q
for (int nj = j + 1; nj <= m; nj++) {
if (q[nj] == r[len + 1]) {
dp[i][nj][len + 1] = (dp[i][nj][len + 1] + dp[i][j][len]) % MOD;
}
}
}
}
}
}
// Calculate the final answer
ll ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
ans = (ans + dp[i][j][k]) % MOD;
}
}
return ans; // Return the calculated result
}
Uber โ
#define N 110
#define MOD 1000000007
int solution(string p, string q, string r) {
int n = p.size();
int m = q.size();
int k = r.size();
// 1-indexing
p = "*" + p;
q = "*" + q;
r = "*" + r;
ll dp[N][N][N] = {}; // Initialize the dp array to zero
dp[0][0][0] = 1; // Base case
// Fill the dp table
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
for (int len = 0; len < k; len++) {
if (dp[i][j][len]) {
// Check the next characters from string p
for (int ni = i + 1; ni <= n; ni++) {
if (p[ni] == r[len + 1]) {
dp[ni][j][len + 1] = (dp[ni][j][len + 1] + dp[i][j][len]) % MOD;
}
}
// Check the next characters from string q
for (int nj = j + 1; nj <= m; nj++) {
if (q[nj] == r[len + 1]) {
dp[i][nj][len + 1] = (dp[i][nj][len + 1] + dp[i][j][len]) % MOD;
}
}
}
}
}
}
// Calculate the final answer
ll ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
ans = (ans + dp[i][j][k]) % MOD;
}
}
return ans; // Return the calculated result
}
Uber โ
๐1