Random Knapsack SOLUTIONS RANDKNAP

Random Knapsack SOLUTIONS OCTOBER CHALLENGE 2020

You are given N=240 integers, randomly generated in [0;998244353).
 
You need to answer Q queries, in each query, you are given one integer X, 0≤X<998244353. And you need to find the subset of given integers with sum X, modulo 998244353.
 
For each test case, it is guaranteed that at least one such subset exists.
 
Input:
The first line contains one integer N=240.
The second line contains N integers, A1,A2,…,AN (0≤Ai<998244353).
The third line contains one integer Q.
The next line contains Q integers X1,X2,…,XQ (0≤Xi<998244353).
Output:
For each query, assume that you’ve chosen indices 1≤i1<i2<…<ik. Then, denote Y=2i1−1+2i2−1+…+2ik−1. You have to print four integers: Ymod260,(⌊Y260⌋)mod260,(⌊Y2120⌋)mod260,(⌊Y2180⌋)mod260.
 
If there are several possible solutions, you can print any.
 
Constraints
1≤Q≤300000.
Subtasks
10 points : 1≤Q≤300
10 points : 1≤Q≤3000
10 points : 1≤Q≤30000
70 points : 1≤Q≤300000
Sample:
There are no samples for this problem.
 
LOGIC WILL BE UPLOADED SOON STAY TUNE AND 
PLEASE SHARE IT WITH YOUR FRIENDS TOO
 

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment

error: Content is protected !!
Please Click on 1 or 2 Ads to help us run this site.