Codeforces|Leetcode|Codechef free solutions
Open in Telegram
Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.
Show more4 317
Subscribers
No data24 hours
-137 days
-5230 days
Posts Archive
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int test;
cin >> test;
while (test--)
{
int n, k, g;
cin >> n >> k >> g;
if (k * g - (((g + 1) / 2) - 1) * n < 0)
{
cout << k * g << endl;
continue;
}
cout << k * g - ((((k * g - (((g + 1) / 2) - 1) * n + g - 1) / g) * g)) << endl;
}
return 0;
}
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define ll long long int
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--){
int i,n,x;
int maximum=0,f=0;
cin>>n;
vector<int>v(101,0);
for(i=0;i<n;i++){
cin>>x;
maximum=max(maximum,x);
v[x]++;
}
for(i=1;i<=maximum;i++){
if(v[i-1]<v[i]){
cout<<"NO"<<endl;
f=1;
break;
}
}
if(f==0)cout<<"YES"<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n; // array size
// Max size of tree
int tree[2 * N];
// function to build the tree
void build( int arr[])
{
// insert leaf nodes in tree
for (int i=0; i<n; i++)
tree[n+i] = arr[i];
// build the tree by calculating parents
for (int i = n - 1; i > 0; --i)
tree[i] = tree[i<<1] + tree[i<<1 | 1];
}
// function to update a tree node
void updateTreeNode(int p, int value)
{
// set value at position p
tree[p+n] = value;
p = p+n;
// move upward and update parents
for (int i=p; i > 1; i >>= 1)
tree[i>>1] = tree[i] + tree[i^1];
}
// function to get sum on interval [l, r)
int query(int l, int r)
{
int res = 0;
// loop to find the sum in the range
for (l += n, r += n; l < r; l >>= 1, r >>= 1)
{
if (l&1)
res += tree[l++];
if (r&1)
res += tree[--r];
}
return res;
}
//========================================Functions=================================
void solve ()
{
int l,r ;int res ;
int n,m;cin >> n >>m;
for(int i = 0 ;i<n;i++)
{
int s,t;cin >> s >>t;
}
int multi = 1;
for (l += n, r += n; l < r; l >>= 1, r >>= 1)
{
if (l&1)
res += tree[l++];
if (r&1)
res += tree[--r];
}
int cnt = 0 ;
int segtree = 0 ;
multi = 6*multi ;
for (l += n, r += n; l < r; l >>= 1, r >>= 1)
{
if (l&1)
res += tree[l++];
if (r&1)
res += tree[--r];
}
cout << multi << endl;
cout << multi - 2 << endl;
cout << 0 << endl;
for (l += n, r += n; l < r; l >>= 1, r >>= 1)
{
if (l&1)
res += tree[l++];
if (r&1)
res += tree[--r];
}
cout << multi - 2 << endl;
for (l += n, r += n; l < r; l >>= 1, r >>= 1)
{
if (l&1)
res += tree[l++];
if (r&1)
res += tree[--r];
}
cout << multi*6 << endl;
cout << 2 << endl;
}
int main() {
ios::sync_with_stdio(false);
int t;cin>>t;
{
while(t--)
{
solve() ;
}
}
return 0 ;
}
No channel provides free code every time
Only @contestsolution provides free code🥳🥳🥳🥳
A and B uploaded for free
Join @contestsolution🥳🥳🥳🥳
Don't buy solutions guys it's free here
Just join @contestsolution
#include <iostream>
#include <string>
using namespace std;
void solve() {
string strL, strR;
cin >> strL >> strR;
int lenR = strR.size();
if (strR.size() > strL.size())
cout << strR[0] - '0' + 9 * (lenR - 1) << endl;
else {
for (int i = 0; i < lenR; i++) {
if (strR[i] != strL[i]) {
cout << strR[i] - strL[i] + 9 * (lenR - i - 1) << endl;
return;
}
}
cout << 0 << endl;
}
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> v[i];
int prdc = 1, sum = 0;
for (int i = 0; i < n; i++)
{
prdc = prdc * v[i];
sum += v[i];
}
if (sum < 0)
{
sum=-sum;
int r = (abs(sum)/ 2) + sum % 2;
if (r % 2 == 1)
prdc = -prdc;
if (prdc == -1)
cout << r + 1 << endl;
else
cout << r << endl;
}
else
{
if (prdc == -1)
cout << 1 << endl;
else
cout <<"0"<<endl;
}
}
return 0;
}
