Polycarp has nn coins, the value of the i-th coin is aiai . It is guaranteed that all the values are integer powers of 22 (i.e. ai=2dai=2d for some non-negative integer number dd ). Polycarp wants to know answers on qq queries. The jj -th query is de…
Coins and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp has nn coins, the value of the ii-th coin is aiai. It is guaranteed that all the values are integer powers of 22 …
Polycarp has n coins, the value of the i-th coin is ai. It is guaranteed that all the values are integer powers of 2 (i.e. ai=2d for some non-negative integer number d). Polycarp wants to know answers on q queries. The j-th query is described as inte…
题目链接 题目大意:给你n个物品,第iii个物品价值aia_iai,询问q次,问你能不能凑出价值为qiq_iqi的物品. 小贪心吧.从大到小找,能拿就拿就行了. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; LL gcd(LL a,LL b){retur…
D. Coins and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp has nn coins, the value of the ii-th coin is aiai. It is guaranteed that all the values are integer powers of …