output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int Inverse[100010];
int Factorial[100010];
int used[100010], F[100010];
vector<int> Divisors[100010];
int power(int a, int n) {
if (n == 0) return 1;
if (n == 1) return a % 1000000007;
int temp = power(a, n / 2);
temp = (1LL * temp * temp) % 1000000007;
if (n % 2... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int modl = 1e9 + 7;
vector<int> divisor[100010];
long long fact[100010], rfact[100010];
long long pow(long long n, int k) {
if (k == 0) return 1;
long long ret = pow(n, k / 2);
ret = (ret * ret) % modl;
if (k & 1) ret = (ret * n) % modl;
return ret;
}
int C(... | ### Prompt
Please create a solution in CPP to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX = 1e5 + 5;
const long long MAX2 = 11;
const long long MOD = 1000000007;
const long long MOD2 = 1000005329;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc... | ### Prompt
Please formulate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
long long fac[100010], revfac[100010];
long long pow(long long a, int k) {
if (!k) return 1;
long long ans = pow(a, k >> 1);
ans = ans * ans % 1000000007;
if (k & 1) ans = ans * a % 1000000007;
return ans;
}
long long H(int n, int f) {
i... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long MOD = 1e9 + 7;
int n, q, m;
int prime[MAXN], primeN;
int minPrimeCnt[MAXN], divisor[MAXN];
bool isPrime[MAXN];
void getDivisor(int n) {
for (int i = 1; i <= n; i++) isPrime[i] = true;
isPrime[1] = false;
primeN = 0;
divisor[1... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
const int N = 100001;
long long fac[N], facr[N];
int mobius[N];
bool prime[N];
long long inv(long long a) {
long long pow = a, ret = 1, exp = P - 2, bit = 1;
while (exp > 0) {
if (exp & bit) {
ret = (ret * pow) % P;
exp ^=... | ### Prompt
In Cpp, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int prime[N], mu[N], m, bo[N];
void mobius() {
mu[1] = 1;
memset(bo, 0, sizeof(bo));
for (int i = 2; i < N; ++i) {
if (!bo[i]) {
mu[i] = -1;
prime[m++] = i;
}
for (int j = 0; j < m && prime[j] * i < N; ++j) {
bo[i *... | ### Prompt
Construct a CPP code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
const int mo = 1000000007;
const int MAX = 100000;
using namespace std;
int p[100005], ny[100005], Hash[100005];
int ss[100005][30], n, f, q, i, j, ans;
int sumi(int a, int b) {
int ret = 1, c = a;
while (b) {
if (b & 1) ret = (long long)ret * c % mo;
c = (long long)c * c % mo;
... | ### Prompt
Construct a cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
map<pair<int, int>, long long> m;
map<pair<int, int>, long long>::iterator it;
long long fa[100007], ifa[100007];
long long bpow(long long x, long long n) {
long long res = 1;
while (n) {
if (n & 1) res = (res * x) % mod;
x = (x * ... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int n, q, f;
vector<int> pr[100100];
bool pr1[100100];
long long fc[100100];
long long pw(long long x, long long p) {
if (p == 0) return 1;
long long z = pw(x, p / 2);
z *= z;
z %= 1000000007;
if (p % 2 == 0) return z;
z *= x;
z %= ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ... |
#include <bits/stdc++.h>
using namespace std;
long long int f[100001];
long long int invf[100001];
int count_factors[100001];
vector<int> factors[100001];
bool isprime[100001];
long long int power(long long int b, long long int e) {
if (e == 0) {
return 1;
} else if (e == 1) {
return b;
} else {
long ... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
long long fac[110000], ifac[110000];
int p[110000], np, flag[110000];
long long Pow(long long x, long long y) {
if (y == 0) return 1;
long long res = Pow(x, y / 2);
res = res * res % 1000000007;
if (y & 1) res = res * x % 1000000007;
return res;
}
void prepare() {... | ### Prompt
Please create a solution in CPP to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool umax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
int color, vis[100009];
long long dp[100009];
long long F[100009], P[10000... | ### Prompt
Please formulate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long ff[100100], inv_ff[100100];
int q, n, f, prime[100100], sqr[100100], mu[100100], ans;
vector<int> divi[100100];
long long inv_mod(long long x) {
long long ret = 1LL, y = MOD - 2;
while (y) {
if (y & 1) ret = (ret * x) % MOD;
... | ### Prompt
In Cpp, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
int a[101010];
int ft[202020];
int pmod(int a, int b) {
int res = 1;
while (b) {
if (b & 1) res = (1ll * res * a) % mod;
a = (1ll * a * a) % mod;
b >>= 1;
}
return res;
}
int calc(int n, int m) {
if (m < 0) return 0;
return (1ll * ft[n + m - 1] *... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
vector<int> P[N];
const int MOD = 1000000007;
long long d[N], e[N];
long long quick_pow(long long b, long long n) {
long long ret = 1;
while (n != 0) {
if (n % 2 == 1) ret = ret * b % MOD;
b = b * b % MOD;
n /= 2;
}
return ret;
}
lo... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const long long MOD = 1e9 + 7;
long long mpow(long long a, long long x) {
if (x == 0) return 1;
long long t = mpow(a, x >> 1);
if (x % 2 == 0) return t * t % MOD;
return t * t % MOD * a % MOD;
}
long long fac[N], inv[N], mu[N];
int q, n, f... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(2e5 + 123);
const long long mod = (long long)(1e9 + 7);
bool u[maxn];
int pn, p[maxn];
void resheto(int N) {
for (int i = 3; i * i <= N; i += 2)
if (!u[i])
for (int j = i * i; j <= N; j += 2 * i) u[j] = 1;
p[pn++] = 2;
for (int i = 3; ... | ### Prompt
Develop a solution in Cpp to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
const int mod = 1e9 + 7;
int q, n, f;
map<int, int> d[maxn + 1];
int fac[maxn + 1], rev[maxn + 1];
int pow(int a, int p) {
int ans = 1;
while (p) {
if (p & 1) {
ans = (1ll * ans * a) % mod;
}
a = (1ll * a * a) % mod;
p >>= 1;
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int MN = 100111;
const long long MOD = 1000000007;
long long power(long long x, long long k) {
if (k == 0) return 1;
if (k == 1) return x % MOD;
long long mid = power(x, k >> 1);
mid = (mid * mid) % MOD;
if (k & 1)
return mid * x % MOD;
else
return... | ### Prompt
Develop a solution in Cpp to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
const int M = 100005;
long long Fac[M], Ifac[M];
int mu[M], Son[M][67], Sz[M];
int _, n, k;
int main() {
Ifac[0] = Ifac[1] = 1;
for (int i = Fac[0] = 1; i < M; ++i) Fac[i] = i * Fac[i - 1] % 1000000007;
for (int i = 2; i < M; ++i)
Ifac[i] = -1000000007 / i * Ifac[1000000007 % i] % 100... | ### Prompt
Develop a solution in cpp to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
long long N = 100005;
namespace mu {
long long mu[100005], vis[100005], prim[100005], cnt;
inline long long read() {
long long num = 0, f = 1;
char c = getchar();
while (c < 48 || c > 57) {
if (c == '-') f = -1;
c = getchar();
}
while (c >= 48 && c <= 57)
num = (num << 3) ... | ### Prompt
Construct a cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int popcount(T t) {
if (std::numeric_limits<T>::digits <=
std::numeric_limits<unsigned int>::digits) {
return __builtin_popcount(t);
} else {
return __builtin_popcountll(t);
}
}
const long double EPS = 1e-8;
const long double... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, mod = 1e9 + 7;
long long p[maxn];
long long pv[maxn];
int t;
int cnt[maxn];
long long dp[maxn];
int n, m;
long long pow_mod(long long a, long long n) {
if (!n) return 1;
long long ret = pow_mod(a, n / 2);
ret = ret * ret % mod;
if (n & 1) ... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
const double pi(3.14159265358979);
const int mod = 1000000007, N = 200200, MaxN = 200000;
long long d[N] = {1}, re[N] = {0, 1}, red[N] = {1, 1};
int prime[N] = {}, ptot = 0, minp[N] = {}, n, f;
int a[N] = {}, tot = 0;
void init() {
bool v[N] = {};
... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmax(T &x, T y) {
if (x < y) x = y;
}
template <class T>
inline void chkmin(T &x, T y) {
if (x > y) x = y;
}
int q, n, f, inv[100100], fac[100100], p[6];
void Euclid(int a, int b, int &x, int &y) {
if (!a)
x = 0, y = 1;
else {
... | ### Prompt
Please create a solution in cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int limite = 100001;
long long int modulo = 1e9 + 7;
long long int eleva(long long int b, long long int e) {
if (e == 0) return 1;
if (e % 2 == 0) return eleva(b * b % modulo, e / 2);
return b * eleva(b * b % modulo, e / 2) % modulo;
}
long long int inverso(long... | ### Prompt
In Cpp, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v) {
os << "(";
os << v.first << "," << v.second << ")";
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << "[";
long long sz = v.size... | ### Prompt
Create a solution in CPP for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000000 + 7;
const int MAX = 100000 * 2 + 5;
long long fact[MAX], revfact[MAX];
vector<int> primes[MAX];
long long power(long long b, long long p) {
if (!p) return 1;
long long ret = power(b, p >> 1);
ret = ret * ret % MOD;
if (p & 1) ret = ... | ### Prompt
In CPP, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
const int mod = 1e9 + 7, N = 1e5 + 9;
int n, m, prime[N], tot, mu[N];
int fac[N], inv[N];
bool isprime[N];
inline void sieve() {
mu[1] = 1;
for (int i = 2; i < N; i++) {
if (!isprime[i]) prime[++tot] = i, mu[i] = -1;
for (int j = 1; j <= tot; j++) {
int k = prime[j];
if ... | ### Prompt
Generate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
long long fact[MAXN];
long long inv_fact[MAXN];
long long nchoosek(int n, int k) {
long long ans = fact[n] * inv_fact[n - k];
ans %= MOD;
ans = ans * inv_fact[k];
ans %= MOD;
return ans;
}
... | ### Prompt
Please formulate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int mod = (int)(1e9 + 7);
int n, k, q, M, pn, p[200], l_p[100005];
long long res, first[100005], g[100005];
long long mod_pow(long long a, int b) {
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
retur... | ### Prompt
Please create a solution in Cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const long long base = 1e9 + 7;
const int N = 1e5 + 5;
long long gt[N], ndm[N];
int q, m, n;
map<pair<long long, long long>, long long> M;
vector<int> ds[N];
long long pw(long long a, long long b) {
if (b == 1) return a;
if (b == 0) return 1;
long long t = pw(a, b / 2... | ### Prompt
Please formulate a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001000;
const int MOD = 1e9 + 7;
int cnt;
int a[maxn], Count[maxn];
long long Pow[maxn], INV[maxn];
bool check[maxn];
int prime[maxn], mu[maxn], tot;
void Moblus() {
memset(check, false, sizeof(check));
mu[1] = 1, tot = 0;
for (int i = 2; i < maxn; i... | ### Prompt
Create a solution in CPP for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
int mu[100005], isp[100005], n, m, t;
int fact[100005], inv[100005];
vector<int> ft[100005];
int po(int a, int b) {
int c = 1, d = a;
while (b) {
if (b & 1) c = 1LL * c * d % 1000000007;
d = 1LL * d * d % 1000000007;
b >>= 1;
}
return c;
}
int ncr(int a,... | ### Prompt
Develop a solution in Cpp to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
double EPS = 1e-7;
int INF = 1000000000;
int MOD = 1000000007;
int MAXINT = 2147483647;
long long INFLL = 1000000000000000000LL;
long long MAXLL = 9223372036854775807LL;
int mx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
int my[8] = {0, 0, -1, 1, -1, 1, -1, 1};
... | ### Prompt
In Cpp, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long c) {
long long ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % c;
a = (a * a) % c;
b >>= 1;
}
return ans;
}
long long modInv(long long p) { return pow(p, 1000000007 - 2, 1000000007); }
long long F[10000... | ### Prompt
In Cpp, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
long long f[MAXN];
long long jie[MAXN];
bool is[MAXN];
vector<int> dive;
map<pair<int, int>, int> rem;
void init() {
jie[0] = 1;
for (int i = 1; i < MAXN; i++) {
jie[i] = jie[i - 1] * i % MOD;
}
rem.clear();
}
v... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
long long p[200010], fp[200010];
long long dp[200010];
vector<int> fac[200010], pfac[200010];
int cal(int A, int B) {
B--;
A += B;
if (A < 0 || B < 0 || A - B < 0) return 0;
return p[A] * fp[A - B] % 1000000007 * fp[B] % 1000000007;
}
long long quick_sqr(l... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 123;
const long long LINF = (long long)1e18 + 123;
void run();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
run();
return 0;
}
const int N = (int)1e5 + 123;
const long long MOD = (long long)1e9 + 7;
long long power(... | ### Prompt
Please create a solution in cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int add(int a, int b) {
long long x = a + b;
if (x >= 1000000007) x -= 1000000007;
if (x < 0) x += 1000000007;
return x;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long pw(long long a, long long b) {
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long ff[100100], inv_ff[100100];
int q, n, f, prime[100100], sqr[100100], mu[100100], ans;
vector<int> divi[100100];
long long inv_mod(long long x) {
long long ret = 1LL, y = MOD - 2;
while (y) {
if (y & 1) ret = (ret * x) % MOD;
... | ### Prompt
Generate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ... |
#include <bits/stdc++.h>
using namespace std;
long long int m, n, f, h[200000], fakt[200000] = {1};
vector<int> v[200000];
long long int fe(long long int m, long long int n) {
if (!n) return 1;
long long int t = fe(m, n / 2);
t = t * t % 1000000007LL;
if (n & 1) t = t * m % 1000000007LL;
return t;
}
long long... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ... |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 5;
const int Mod = 1e9 + 7;
long long jc[Maxn], inv[Maxn];
int di[Maxn][300];
long long getInv(long long a) {
int b = Mod - 2;
long long ret = 1;
while (b) {
if (b & 1) ret = ret * a % Mod;
a = a * a % Mod;
b >>= 1;
}
return ret;... | ### Prompt
In CPP, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
using namespace std;
int const MOD = 1e9 + 7;
int const MAXN = 1e5 + 7;
int is_prime[MAXN];
int fact[MAXN];
int invfact[MAXN];
int inv(int a, int p) {
int res = 1LL;
int b = p - 2;
int tmp = a;
while (b) {
if (b & 1) res = (res * 1LL * tmp) % p;
tmp = (tmp * 1LL * tmp) % p;
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
return ((a) / gcd((a), (b)) * (b));
}
template <class T>
inline T BigMod(T Base, T power, T M = 1000000007) {
if (power == 0) retur... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <class T>
ostream& prnt(ostream& out, T v) {
out << v.size() << '\n';
for (auto e : v) out << e << ' ';
return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
return prnt(out, v);
}
template <cla... | ### Prompt
Please formulate a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
int const MOD = 1e9 + 7;
int const MAXN = 1e5 + 7;
bool is_prime[MAXN];
int fact[MAXN];
int invfact[MAXN];
int inv(int a, int p) {
int res = 1LL;
int b = p - 2;
int tmp = a;
while (b) {
if (b & 1) res = (res * 1LL * tmp) % p;
tmp = (tmp * 1LL * tmp) % p;
... | ### Prompt
Generate a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ... |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const long long MOD = 1e9 + 7;
inline long long modulo(long long x) {
if (0 <= x and x < MOD) return x;
return (x > 0) ? x % MOD : (x % MOD) + MOD;
}
pair<long long, long long> gcd_ex(long long a, long long b) {
if (b == 0) return make_pair(1, ... | ### Prompt
Create a solution in Cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
long long temp1, temp2, temp;
char tempc;
int mobius[100007];
int lpf[100007];
void least_prime_factor() {
for (int i = 2; i < 100007; i++)
if (!lpf[i])
for (int j = i; j < 100007; j += i)
if (!lpf[j]) lpf[j] = i;
}
void Mobius(int n) {
for (int i = 1;... | ### Prompt
Create a solution in cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100500, MOD = 1e9 + 7;
struct {
int p, e;
} Fafa[10];
long long expmod(long long b, long long e) {
if (!e) return 1;
return (e % 2 ? b : 1) * expmod(b * b % MOD, e / 2) % MOD;
}
long long F[MAXN], FI[MAXN];
long long CMB(long long n, long long k) {
... | ### Prompt
Create a solution in CPP for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
int F[MAXN], iverF[MAXN];
int prime[30], sz;
int pow2(int n) { return 1 << n; }
int pow(int a, int n) {
int res = 1;
while (n) {
if (n & 1) res = 1ll * res * a % MOD;
a = 1ll * a * a % MOD;
n >>= 1;
}
return res;
}
void ini... | ### Prompt
Create a solution in Cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
long long fact[(int)(1e5 + 5)], fact_inv[(int)(1e5 + 5)];
vector<int> prime[(int)(1e5 + 5)];
int *v;
int n, f;
long long power(long long a, int x) {
long long res = 1;
while (x) {
if (x % 2 == 1) res = (res * a) % (int)(1e9 + 7);
a = (a * a) % (int)(1e9 + 7);
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
long long pow(long long b, int exp) {
if (exp == 0)
return 1;
else if (exp % 2)
return b * pow(b, exp - 1) % 1000000007;
else {
long long half = pow(b, exp / 2);
return half * half % 1000000007;
}
}
long long int fact[100010];
long long int inv[100010];
long long bin(int... | ### Prompt
Develop a solution in cpp to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int ALL = 1e5;
int fac[MAXN], ifac[MAXN];
int is[MAXN], mu[MAXN], p[MAXN], t;
inline int read() {
int x = 0;
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) {
x = x * 10 + ch ... | ### Prompt
Please create a solution in Cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
inline int in() {
int x;
scanf("%d", &x);
return x;
}
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const long double eps = 1e-12;
map<pair<int, int>, int> mp;
int q, fact[N], inv[N];
vector<int> v[N];
int power(int n, int f) {
if (f == 0) return 1;
if (f == 1)... | ### Prompt
Create a solution in cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
typename T::value_type arr_sum(const T &v, int n) {
typename T::value_type sum = 0;
for (int i = (0); i < (n); ++i) sum += v[i];
return sum;
}
struct Sync_stdio {
Sync_stdio() {
cin.tie(NULL);
ios_base::sync_wit... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 120000;
constexpr LL mod = 1000000007;
LL power(LL a, LL r) {
LL res = 1;
for (; r; r >>= 1, a = a * a % mod)
if (r & 1) res = res * a % mod;
return res;
}
LL f[maxn], uf[maxn];
LL c(int m, int n) {
if (m < n) return 0;... | ### Prompt
Please create a solution in CPP to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int nn = 100001;
int main(int argc, char* argv[]) {
int q;
vector<long long> inv(nn);
inv[1] = 1;
for (int i = 2; i < nn; ++i)
inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
vector<long long> f(nn), ivf(nn);
f[... | ### Prompt
Construct a CPP code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1E5 + 50;
const long long p = 1E9 + 7;
int T, n, s, pcnt, vis[N], prim[N >> 1], miu[N];
long long ans, fac[N], inv[N];
long long Pow(long long a, long long b = p - 2) {
long long res = 1;
for (; b; b >>= 1, a = a * a % p)
if (b & 1) res = res * a % p;
... | ### Prompt
Your task is to create a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ... |
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
long long fac[100001];
bool prime[100001];
int largest_p[100001];
int mu[100001];
int divisor_count[100001];
int divisors[100001][65];
long long modpow(long long b, long long e) {
if (e == 0) {
return 1;
} else {
long long x = modpow(b, e / 2);
if (e % 2 == ... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool smin(T &a, const T &b) {
return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool smax(T &a, const T &b) {
return a < b ? a = b, 1 : 0;
}
const long long N = 1e5 + 10, mod = (long long)1e9 + 7;
long long t, n, pick, f[N], rev[N]... | ### Prompt
Please formulate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
struct X {
int dig[256];
X() {
for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
dig['-'] = 1;
}
};
static X fuck;
int s = 1, v = 0, c;
for (; !fuck.dig[c = getchar()];)
;
if (c == '-'... | ### Prompt
Construct a CPP code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long fact[100010];
long long ifact[100010];
long long lpf[200000];
long long prim[100010];
vector<long long> D[100010];
long long mu[100010];
long long power(long long a, long long b) {
if (a == 0) return 0;
if (a == 1) return 1;
if (b... | ### Prompt
Your task is to create a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ... |
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long ff[100100], inv_ff[100100];
int q, n, f, prime[100100], sqr[100100], mu[100100], ans;
vector<int> divi[100100];
long long inv_mod(long long x) {
long long ret = 1LL, y = MOD - 2;
while (y) {
if (y & 1) ret = (ret * x) % MOD;
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int maxn = 1e5 + 10, mod = 1000000007;
vector<int> v[maxn];
int n, s, q;
long long fac[maxn];
long long p[maxn];
long long dp[maxn];
long long C[maxn];
long long tav(long long i, long long j) {
if (j <= 1) return (1 * (j == 0) + i * (j == 1)) % ... | ### Prompt
Please formulate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-12;
const int inf = 2000000000;
int MOD = 1000000007;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
inline bool checkBit(long long int n, long long int i) {
return n & (1LL << i);
}
inline long long int setBit(long long in... | ### Prompt
Generate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ... |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
const int MOD = 1e9 + 7;
int fact[MAX_N], ive_fact[MAX_N];
std::vector<int> ver;
int pow(int a, int x) {
int res = 1;
while (x) {
if (x & 1) res = 1ll * res * a % MOD;
x >>= 1;
a = 1ll * a * a % MOD;
}
return res;
}
int calc(in... | ### Prompt
Your task is to create a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int t;
int n, f;
int fact[N];
int ifact[N];
vector<int> v[N];
int nu[N];
bool pr[N];
void pre() {
fact[0] = 1;
for (int i = 1; i < N; ++i) {
fact[i] = (1LL * fact[i - 1] * i) % mod;
}
ifact[N - 1] = 931791584;
fo... | ### Prompt
Please formulate a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 77, Mod = 1000000007;
int Fact[N], InvFact[N], q, Ca[N], T[N], Num;
vector<int> Div[N];
int Pow(int X, int Y) {
if (Y == 0) {
return (1);
}
int C = Pow(X, Y >> 1);
C = (C * 1ll * C) % Mod;
if (Y & 1) {
C = (C * 1ll * X) % Mod;
}
ret... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAXN = 1e5 + 1;
vector<long long> fact, _fact;
vector<vector<int>> fac;
vector<int> sign;
long long binp(long long a, long long p) {
if (!p) return 1;
if (p & 1) return a * binp(a, p - 1) % MOD;
long long x = binp(a, (p >... | ### Prompt
Please formulate a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
int t, n, f;
long long facto[100000 + 5], mobinverse[100000 + 5];
int mobius[100000 + 5];
vector<int> primes;
bool sieve[100000 + 5];
long long pangkat(long long a, long long b) {
if (b == 0) return 1;
if (b == 1) return a;
long long temp = pangkat(a, b / 2);
return... | ### Prompt
Create a solution in CPP for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
const int size = 100007;
const long long modulo = 1000000007;
const long long oo = 7e18;
const double EPS = 1e-13;
const double PI = acos(-1.0);
long long fact[size], rev_fact[size];
vector<long long> divisors[size];
long long used[size], dp[size];
int query = 0;
long long ... | ### Prompt
Generate a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int> v1[100005 + 1];
long long fact[100005];
long long inverse[100005];
int mark[100005];
long long powmod(long long a) {
long long b = 1000000007LL - 2;
long long c = 1000000007LL;
long long ret = 1LL;
while (b) {
if (b & 1) ret = (ret * a... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const double PI = acos(-1.0);
long long poww(long long a, long long n, long long m) {
long long ans = 1;
long long mul = a;
while (n != 0) {
if (n % 2) {
ans = (ans * mul) % m;
}
mul = (mul * mul)... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
long long int ABS(long long int a) {
if (a < 0) return (-a);
return a;
}
void input() {}
long long int pow(long long int a, long long int b, long long int mod) {
long long int x = 1, y = a;
while (b > 0) {
if (b & 1) {
x = (x * y);
if (x >= mod) x %=... | ### Prompt
Generate a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to ... |
#include <bits/stdc++.h>
using namespace std;
const int size = 111111;
long long mod = 1000000007;
int n, q, f;
long long ans[size];
int a[size], num;
long long jc[size], r[size];
long long mul(long long a, int p) {
if (p == 0) return 1;
if (p == 1) return a;
long long x = mul(a, p / 2);
x = (x * x) % mod;
if... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
if (y == 0) return 1;
long long int d = power(x, y / 2) % 1000000007;
if (y % 2 == 0)
return (d * d) % 1000000007;
else
return (((x * d) % 1000000007) * d) % 1000000007;
}
long long int divmod(long long... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
int pm(int a, int e) {
int r = 1;
while (e) {
if (e & 1) r = (1LL * r * a) % 1000000007;
e >>= 1;
a = (1LL * a * a) % 1000000007;
}
return r;
}
int f[100005], fi[100005];
int c(int n, int k) {
if (k < 0 || k > n) return 0;
return 1LL * f[n] * fi[k] %... | ### Prompt
Create a solution in cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 10;
const int Inf = 0x7f7f7f7f;
const long long Inf_ll = 1ll * Inf * Inf;
const int Mod = 1e9 + 7;
const double eps = 1e-7;
void r(int &p) {
char c = getchar();
int x = 0, fh = 0;
while (c < '0' || c > '9') {
fh |= c == '-';
c = getchar(... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
struct node {
int nxt, t;
} A[1166900];
int head[100010], node_cnt;
void add_edge(int x, int y) {
A[node_cnt] = (node){head[x], y};
head[x] = node_cnt++;
}
int pri[100010], pri_cnt, mu[100010];
bool mark[100010];
void sieve() {
int i, j;
mu[1] = 1;
for (i = 2; i... | ### Prompt
Please create a solution in Cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
double PI = 3.141592653589793;
const long long P = 1e9 + 7;
class mint {
public:
static int init_siz;
static vector<mint> inverse, factorial;
static int mintP;
int n;
static mint exp(mint a, long long e) {
mint res = 1;
while (e) {
if (e & 1) res *=... | ### Prompt
Create a solution in cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
long long inv[100005];
long long invFact[100005];
long long fact[100005];
long long numPart(int n, int f) {
n = n - f;
if (n < 0) return 0;
long long ret = fact[n + f - 1] * invFact[n] % 1000000007;
ret = ret * invFact[f - 1] % 1000000007;
return ret;
}
int main()... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const int MXN = (int)1e5 + 7;
int n, k, t;
int m[MXN];
long long fac[MXN], rev[MXN];
long long binpow(long long x, long long y) {
long long res = 1;
while (y) {
if (y & 1) res = (1LL * res * x) % INF;
y >>= 1;
x = (1LL * x * x) ... | ### Prompt
Please formulate a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
vector<int> p;
int a[100010];
int fa[200010], inv[200010], ifa[200010];
int go(int n, int f) {
if (n < f) return 0;
if (f == 1) return 1;
n -= f;
--f;
long long res = fa[n + f];
res = res * ifa[f] % mod;
res = res * ifa[n] % mod;
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
struct X {
int dig[256];
X() {
for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
dig['-'] = 1;
}
};
static X fuck;
int s = 1, v = 0, c;
for (; !fuck.dig[c = getchar()];)
;
if (c == '-'... | ### Prompt
Create a solution in Cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int mod = 1000000007;
int fac[100001], inv[100001], k, f[100001];
vector<int> e[100001];
bool v[100001];
int cnt, p[20001], mu[100001];
inline int ksm(long long base, int expo) {
long long ret = 1;
for (; expo; (base *= base) %= mod, expo >... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any frien... |
#include <bits/stdc++.h>
using namespace std;
int setBit(int n, int pos) { return n = n | (1 << pos); }
int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
bool checkBit(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
const int MAX = 100010;
int mu[MAX], inv[MAX];
vector<int> divs[MAX];
const ... | ### Prompt
Please create a solution in cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 5;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long sq(long long x) { return (x * x) % MOD; }
long long modP(long long a, long long b) {
return (!b ? 1 : ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100007;
const int maxv = 100000;
long long fac[maxn], fac2[maxn];
map<pair<int, int>, int> save;
int cnt;
long long mypow(int base, int n) {
if (n == 0) return 1;
long long t = mypow(base, n / 2);
t = (t * t) % 1000000007;
if (n & 1)
return (t *... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
long long int fact[maxn * 2 + 1];
long long int ifact[maxn * 2 + 1];
int n, f;
long long int fastex(long long int a, long long int b) {
long long int ret = 1;
while (b) {
if (b & 1) {
ret = (ret * a) % 1000000007;
}
a = (a * a)... | ### Prompt
Create a solution in cpp for the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend t... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1, M = 1e9 + 7;
int n, m, q, dp[N], vis[N], vs, fact[N], ifact[N];
vector<int> d[N];
int Pow(int a, int b) {
int res = 1;
while (b != 0) {
if (b & 1) res = ((long long)res * a) % M;
a = ((long long)a * a) % M;
b >>= 1;
}
return res;
}... | ### Prompt
Please formulate a Cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001000;
const int MOD = 1e9 + 7;
int cnt;
int a[maxn], Count[maxn];
long long Pow[maxn], INV[maxn];
bool check[maxn];
int prime[maxn], mu[maxn], tot;
void Moblus() {
memset(check, false, sizeof(check));
mu[1] = 1, tot = 0;
for (int i = 2; i < maxn; i... | ### Prompt
Develop a solution in CPP to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long ff[100100], inv_ff[100100];
int q, n, f, prime[100100], sqr[100100], mu[100100], ans;
vector<int> divi[100100];
long long inv_mod(long long x) {
long long ret = 1LL, y = MOD - 2;
while (y) {
if (y & 1) ret = (ret * x) % MOD;
... | ### Prompt
Please create a solution in Cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
const int mod = 1000000007;
long long binpow(long long a, long long b) {
long long ret = 1;
while (b) {
if (b & 1) ret = (ret * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ret;
}
long long f[N], inv[N];
long long get(int n, int k... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 101000;
const int MOD = 1e9 + 7;
int cnt;
int a[maxn], Count[maxn];
long long Pow[maxn], INV[maxn];
bool check[maxn];
int prime[maxn], mu[maxn], tot;
void Moblus() {
memset(check, false, sizeof(check));
mu[1] = 1, tot = 0;
for (int i = 2; i < maxn; i+... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't w... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 256;
const char nxtl = '\n';
const int mod = (int)1e9 + 7;
const double eps = (double)1e-9;
template <typename T>
inline bool updmin(T &a, const T &b) {
return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool updmax(T &a, const T &b) {
re... | ### Prompt
In Cpp, your task is to solve the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend ... |
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 10;
const int mod = (int)1e9 + 7;
int add(int a, int b) { return (a + b) % mod; }
int mult(long long int a, long long int b) { return (a * b) % mod; }
int bin_pow(long long int a, long long int b) {
int ans = 1;
while (b) {
if (b % 2 == 0) {... | ### Prompt
Please create a solution in cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
using namespace std;
double __begin;
template <typename T1, typename T2, typename T3>
struct triple {
T1 a;
T2 b;
T3 c;
triple(){};
triple(T1 _a, T2 _b, T3 _c) : a(_a), b(_b), c(_c) {}
};
template <typename T1, typename T2, typename T3>
bool ... | ### Prompt
Please create a solution in cpp to the following problem:
Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.