description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
template <std::uint32_t mod>
class modint {
private:
std::uint32_t n;
public:
modint() : n(0){};
modint(std::uint64_t n_) : n(n_ % mod){};
bool operator==(const modint& m) const { return n == m.n; }
bool operator!=(const modint& m) const { return n != m.n; }
... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
inline int safe_mul(const int x, const int y)
__attribute__((warn_unused_result));
int const mod = 1e9 + 7;
inline int safe_mul(const int x, const int y) {
return x * static_cast<int64_t>(y) % mod;
}
inline void ... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll modpow(ll x, ll p, ll mod) {
ll res = 1LL;
for (; p; p >>= 1, (x *= x) %= mod)
if (p & 1) (res *= x) %= mod;
return res;
}
template <ll mod>
struct Mint {
ll x;
Mint(ll ... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
inline long long int modadd(long long int n, long long int m,
long long int p = 1000000007) {
return ((n + m) % p + p) % p;
}
inline long long int modsub(long long int n, long long int m,
long long int p = 1000000007... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 105;
int n, K, m;
int a[N];
long long f[N][N];
long long Powx(long long a, int b) {
long long ans = 1;
while (b != 0) {
if (b % 2) ans = (ans * a) % mod;
a = (a * a) % mod;
b /= 2;
}
return ans;
}
long long c[N][N];... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
const long long md = 1e9 + 7;
const int Inf = 1e9;
const long long Inf64 = 1e18;
const long long MaxN = 200001;
const long long MaxM = 1000001;
const long double eps = 1e-15;
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
using namespace std;
long long gcd(long lo... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int Mod = 1e9 + 7;
struct Matrix {
int n, m, a[146][146];
Matrix(int _n = 0, int _m = 0, int x = 0) {
n = _n, m = _m;
memset(a, 0, sizeof a);
for (int i = 0; i < min(n, m); ++i) a[i][i] = x;
}
Matrix opera... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
#pragma GCC optimize("-Ofast")
#pragma GCC optimization("unroll-loops")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << "\t";
err(++it... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | import java.util.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;
/* spar5h */
public class cf6 implements Runnable {
int x;
long mod = (long)1e9 + 7;
long[][] mat;
long[][] multiply(long[][] a, long[][] b) {
long[][] ret = new long[x + 1][x + 1];
for(int i = 0; i... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int N = 101;
const int mod = 1e9 + 7;
int n, m, sum_0, right_sum_0;
int x[N];
long long a[N], b[N][N], c[N][N];
long long calc(long long x, long long y) {
long long z = 1;
while (y) {
if (y & 1) (z *= x) %= mod;
(x *= x) %= mod, y /= 2;
}
return z;
}
i... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int w = 0, x = 0;
char c = getchar();
while (!isdigit(c)) w |= c == '-', c = getchar();
while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
return w ? -x : x;
}
namespace star {
const int maxn = 105, mod = 1e9 + 7;
int n, m, k, a[maxn];
in... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
struct Matrix {
int sz;
vector<vector<long long> > arr;
Matrix() {}
Matrix(int is) {
sz = is;
arr = vector<vector<long long> >(sz + 1, vector<long long>(sz + 1, 0));
}
void unitize() {
for (int i = 0; i <= sz; i++) {... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static long MOD = 1000000007;
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
final int n = scanner.nextInt();
final int k = scanner.nextIn... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
inline long long int pow(long long int a, long long int b) {
long long int res = 1;
while (b > 0) {
if (b & 1) res = res * a % 1000000007;
b >>= 1;
a = a * a % 1000000007;
}
return res;
}
inline long long int inv(long long int x) { return pow(x, 10000000... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
vector<vector<long long> > mulmat(vector<vector<long long> > &mat1,
vector<vector<long long> > &mat2) {
vector<vector<long long> > ans(mat1.size(),
vector<long long>(mat2[0].size()... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 107, MOD = 1e9 + 7;
int a[MAXN], o = 0, z, x, n, k, dp[MAXN][MAXN] = {};
int fir[MAXN], ans[MAXN];
void add(int &a, const int &b) {
a += b;
if (a >= MOD) a -= MOD;
}
struct matrix {
int f[MAXN][MAXN] = {};
matrix operator*(matrix &b) {
matrix c;... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
long long int a[101][101];
long long int res[101][101], tmp2[101][101];
const int mod = 1e9 + 7;
long long int mypow(long long int x, long long int b) {
long long int res = 1;
while (b) {
if (b & 1) res = res * x % mod;
x = x * x % mod;
b >>= 1;
}
return... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1e9 + 7;
void add(int64_t& a, int64_t b) { a = (a + b) % MOD; }
void mul(int64_t& a, int64_t b) { a = (a * b) % MOD; }
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {
int64_t d = a;
if (b != 0) {
d = extgcd(b, a % b, y, x);
y -... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int N = 105;
const long long P = 1e9 + 7;
inline long long add(long long x, long long y) {
x += y;
return x >= P ? x - P : x;
}
inline long long sub(long long x, long long y) {
x -= y;
return x < 0 ? x + P : x;
}
map<long long, long long> INV;
inline long long... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a[105], n, k, s, t, Lucina;
inline int add(int a, int b) {
a += b;
return a >= mod ? a - mod : a;
}
inline int sub(int a, int b) {
a -= b;
return a < 0 ? a + mod : a;
}
inline int mul(int a, int b) { return (int)((long long)a * b % mod);... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
std::cout << a << ' ';
err(args...);
}
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1 << 30;
const int maxn = 100 + 5;
long long qpow(long long x, long long n) {
l... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const long long N = 105, mod = 1e9 + 7;
struct ab {
long long a[N][N];
ab() { memset(a, 0, sizeof a); }
} ans, xx;
long long a[N], n;
long long p2(long long x) { return x * (x - 1) / 2; }
long long POW(long long x, long long y) {
long long ans = 1;
while (y) {
i... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long pow_mod(long long a, long long p) {
if (p == 0) return 1;
long long ret = pow_mod(a, p / 2);
ret = ret * ret % mod;
if (p % 2 == 1) ret = ret * a % mod;
return ret;
}
long long inv(long long a) { return pow_mod(a, mod - 2); }
str... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
int arr[110];
int src[30][110][110];
int temp[110][110];
int dst[110][110];
int add(int a, int b) { return (a + b) % 1000000007; }
int sub(int a, int b) { return (a - b + 1000000007) % 1000000007; }
int prod(int a, int b) { return 1LL * a * b % 1000000007; }
int power(int a... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
long long int matrix[102][102];
long long int mod = ... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
void add(int &x, int y) {
x += y;
if (x >= 1000000007) x -= 1000000007;
}
inline int read() {
int x = 0;
bool t = false;
char ch = getchar();
while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
if (ch == '-') t = true, ch = getchar();
while (ch <= '9... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
inline int read() {
int res = 0;
bool bo = 0;
char c;
while (((c = getchar()) < '0' || c > '9') && c != '-')
;
if (c == '-')
bo = 1;
else
res = c - 48;
while ((c = getchar()) >= '0' && c <= '9')
res = (res << 3) + (res << 1) + (c - 48);
return bo ? ~res + 1 : res... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
long long dp[10002][103];
long long n;
long long power(long long x, long long k) {
long long result = 1;
while (k) {
if (k & 1) result = (result * x) % 1000000007;
x = (x * x) % 1000000007;
k = k >> 1;
}
return result;
}
class matrix {
public:
long lo... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
using namespace std;
template <class T>
using v2d = vector<vector<T>>;
template <class T>
bool uin(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
return a < b ? (a = b, true) : false... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
inline void inc(int &x, int y) { (x += y) >= mod && (x -= mod); }
inline int mul(int x, int y) { return 1LL * x * y - 1LL * x * y / mod * mod; }
inline int modpower(int x, lon... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | //package Contest553;
import java.io.PrintWriter;
import java.util.Scanner;
public class mainF {
public static Scanner enter = new Scanner(System.in);
public static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) {
long mod=(long)1e9+7;
int n=enter.ne... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
long long mod(long long n) {
if (n < 0) {
if (n + MOD >= 0)
return n + MOD;
else
return (n % MOD + MOD) % MOD;
} else {
if (n < MOD)
return n;
else if (n < (MOD << 1))
return n - MOD;
... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int mod = 1e9 + 7;
int a[200], n, k, c, t;
struct Matrix {
long long m[105][105];
Matrix() { memset(m, 0, sizeof m); };
friend Matrix operator*(const Matrix &a, const Matrix &b) {
Matrix temp;
for (int i = 0; i <= 100; ++i)
... |
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array a of length n, consisting only of the numbers 0 and 1, and the number k. Exactly k times the following happens:
* Two numbers i and... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("section-anchors")
#pragma GCC optimize("profile-reorder-functions")
#pragma GCC optimize("... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int n, m;
int a[55], b[55];
int dp[55][55][55];
const int Mod = 998244353;
int nii[5555];
int ksmii(int a, int b) {
if (!b) {
return 1;
}
int x = ksmii(a, b >> 1);
x = 1LL * x * x % Mod;
if (b & 1) {
x = 1LL * x * a % Mod;
}
return x;
}
int main() {
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxm = 3001;
const int maxn = 2e6;
const long long mod = 998244353;
long long add(long long a, long long b) { return (a + b) % mod; }
long long sub(long long a, long long b) { return ((a - b) % mod + mod) % mod; }
long long mul(long long a, long long b) { return (... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long sum_mod(long long a, long long b) {
a += b;
if (a >= 998244353ll) return a - 998244353ll;
return a;
}
long long mul_mod(long long a, long long b) { return a * b % 998244353ll; }
long long sub_mod(long long a, long long b) {
if (b > a) return a + 998244353l... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
pair<int, int> v[55];
int dp[2][105][55][55], inv[3005];
int liked, disliked;
int exp(int a, int b) {
int r = 1;
while (b) {
if (b & 1) r = ((long long)r * a) % MOD;
b /= 2;
a = ((long long)a * a) % MOD;
}
return r;
}
inline vo... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MAXM = 3010;
const int MOD = 998244353;
int qpow(int a, int b) {
int base = 1;
while (b) {
if (b & 1) base = 1ll * base * a % MOD;
a = 1ll * a * a % MOD;
b >>= 1;
}
return base;
}
int n, m, A[MAXN], W[MAXN], F[MAXM][M... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int n, m, tot, dep;
long long ny(long long x) {
return x == 1 ? 1
: ny(998244353 % x) * (998244353 - 998244353 / x) % 998244353;
}
long long dp[60][60][60], a[55], w[55], f[10];
int main() {
cin >> n >> m;
for (int i = (1); i <= (n); i++) cin >> a[i];
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
const int mod = 998244353;
int like[maxn];
long long dp[maxn * 2][maxn][maxn][2];
int wi[maxn];
int n, m;
long long quick(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... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
os << "[ ";
for (auto v : V) os << v << " ";
return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
return os << "(" << P.first << "," << P.second << ")";
}
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int dp[102][55][55][55][2];
long long w[55];
long long a[55];
long long sa, sb;
long long n, m;
const long long MOD = 998244353;
long long funct(long long x) {
long long answer = 1, current = x;
long long p = MOD - 2;
while (p != 0) {
if (p % 2 != 0) {
answe... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
const int64_t mod = 998244353;
int gcd(int64_t a, int64_t b) {
while (a != 0 && b != 0) {
if (a >= b)
a = a % b;
else
b = b % a;
}
return a + b;
}
struct Fraction {
int64_t numerator;
int64_t devider;
Fraction(int64_t n = 0, int64_t d = 1) : numerator(n), devider... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
const int MOD = 998244353;
const int kN = 50 + 5;
int n, m;
int a[kN], w[kN];
int dp[kN][kN][kN];
const int kM = kN * kN * 20;
int Inv[kM];
int inv(int x) {
return x == 1 ? 1 : (MOD - MOD / x) * 1LL * inv(MOD % x) % MOD;
}
inline void add(int &a, int b) {
a += b;
if (a >= MOD) a -= MOD;
}... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
cin >> first;
IN(rest...);
return;
}
inline void OUT(void) {
cout << "\n";
return;
}
template <typename First, typename... Rest>
void OUT(First firs... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long lh[100005];
long long w[100005];
long long n, M;
long long sumw = 0, suml = 0, sumh = 0;
long long dp[55][55][55];
long long md = 998244353;
long long modInverse(long long a, long long m) {
if (a == 0) return 0;
long long m0 = m;
long long y = 0, x = 1;
if... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
void file(bool opt) {
if (opt && fopen("in.txt", "r")) {
freopen("in.txt", "r", stdin);
}
}
const long long mod = 998244353;
long long dp[2][3000 + 5][3000 + 5];
long long sum[2];
long long a[200000 + 5];
long long inv[6000 + 5];
bool check[200000 + 5];
long long po... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int put(int a, int p) {
int ans = 1;
while (p) {
if (p & 1) ans = 1LL * ans * a % 998244353;
a = 1LL * a * a % 998244353;
p /= 2;
}
return ans;
}
int invmod(int x) { return put(x, 998244353 - 2); }
void add(int& a, int b) {
a += b;
if (a >= 998244353... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, mod = 998244353, M = 3e3 + 5;
int n, m;
long long a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];
int ksm(int x, int y) {
int ans = 1;
while (y) {
if (y & 1) ans = 1LL * ans * x % mod;
x = 1LL * x * x % mod;
y >>= 1;
}
return an... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long read() {
int f = 1;
long long res = 0;
char ch;
do {
ch = getchar();
if (ch == '-') f = -f;
} while (ch < '0' || ch > '9');
do {
res = res * 10 + ch - '0';
ch = getchar();
} while (ch >= '0' && ch <= '9');
return f == 1 ? res : -res... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int mxn = 262144, md = 998244353;
int rd() {
int x = 0, flg = 1;
char c = getchar();
for (; (c < 48 || c > 57) && c != '-'; c = getchar())
;
if (c == '-') flg = -1, c = getchar();
for (; c > 47 && c < 58; x = x * 10 + c - 48, c = getchar())
;
retur... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long INF = INT_MAX;
const long long MOD = 998244353;
long long extgcd(long long a, long long b, long long &x, long long &y) {
long long g = a;
x = 1;
y = 0;
if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
return g;
}
long long invMod(long long... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int Mod = 998244353;
int n, m, a[55], w[55], f[55][105][55], g[55][105][55], x, sa, sb;
int power(int b, int e) {
if (!e) return 1;
int tmp = power(b, e >> 1);
tmp = 1ll * tmp * tmp % Mod;
if (e & 1) tmp = 1ll * tmp * b % Mod;
return tmp;
}
int main() {
ci... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long b[55], a[55];
long long dp[55][55][55];
long long inv[200000];
int main() {
inv[1] = 1;
for (int i = 2; i <= 199999; i++)
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 50;
int isgood[N], w[N];
int n, m;
long long power(long long a, long long b) {
long long x = 1, y = a;
while (b > 0) {
if (b & 1) {
x = (x * y);
if (x > MOD) x %= MOD;
}
y = y * y;
if (y > MOD) y %= MO... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long w0, w1;
long long a[200005], b[200005];
long long dp[3005][3005];
long long fpow(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;... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int N, M;
int a[55], w[55];
long long qpow(long long x, int n) {
long long res = 1;
while (n) {
if (n & 1) res = res * x % int(998244353);
x = x * x % int(998244353);
n /= 2;
}
return res;
}
long long inv(long long x) { return qpow(x, int(998244353) - 2)... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long a[55], w[55], dp[55][55][55];
long long fast(long long x, long long b, long long res = 1) {
while (b) {
if (b & 1) res = res * x % 998244353;
x = x * x % 998244353;
b >>= 1;
}
return res;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
template <typename T>
struct modular {
constexpr modular() : val(0) {}
constexpr modular(const modular<T>& _m) : val(_m.val) {}
template <typename U>
constexpr modular(const U& _r = U()) {
val = -MOD <= _r && _r < MOD ? _r : _r % MOD;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | import fileinput
def D(a):print(a)
def S(s,I):return int(s.split(" ")[I])
def inv(a):return pow(a,MOD-2,MOD)
def main():
global MOD
MOD=998244353
z=0
N=0
M=0
A=0
W=0
for l in fileinput.input():
z+=1
if(z<2):
N=S(l,0)
M=S(l,1)
continue
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int add(int _a, int _b) {
_a = (_a + 998244353) % 998244353;
_b = (_b + 998244353) % 998244353;
return (_a + _b) % 998244353;
}
int mul(int _a, int _b) {
_a = (_a + 998244353) % 998244353;
_b = (_b + 998244353) % 998244353;
return ((long long int)((long long int... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
int n, m;
int a[200009];
long long w[200009];
long long sump = 0;
long long sumn = 0;
long long dp1[3009][3009];
long long dp2[3009][3009];
long long getinv(long long x) {
x %= MOD;
long long kit = MOD - 2;
long long res = 1;
while (kit > ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 59;
const long long mod = 998244353;
int add[maxn];
long long w[maxn];
long long dp[52][52][52];
long long val[52][52][52];
bool vis[52][52][52];
long long Pow(long long a, long long b) {
long long res = 1;
a %= mod;
while (b) {
if (b & 1) res = r... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int read() {
int x = 0, flag = 1;
char ch = getchar();
while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
if (ch == '-') flag = -1, ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return x * flag;
}
const int MOD = ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long dp[1010000];
long long mpow(long long x, long long n) {
long long ans = 1;
while (n) {
if (n & 1) ans = ans * x % 998244353;
x = x * x % 998244353;
n >>= 1;
}
return ans;
}
long long inv(long long x) { return mpow(x, 998244353 - 2); }
int n, m;... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 5;
const long long mod = 998244353;
int n, m;
long long qpow(long long a, long long b) {
long long ans = 1;
while (b) {
if (b & 1) ans *= a, ans %= mod;
a *= a;
a %= mod;
b >>= 1;
}
return ans;
}
long long inv(long long a) { ret... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 2e5 + 100;
long long dp[52][52][52];
bool vis[52][52][52];
long long val[52][52][52];
int a[maxn], w[maxn];
long long qmod(long long a, long long b) {
long long ans = 1;
while (b) {
if (b & 1) ans = ans * a % mod;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const long long MOD = 998244353;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
int _;
using namespace std;
long long powermod(long long n, long long k, long long MOD) {
l... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long Mod = 998244353;
long long qpw(long long a, long long b) {
long long ans = 1;
a = (a % Mod + Mod) % Mod;
while (b) {
if (b & 1) ans = ans * a % Mod;
a = a * a % Mod;
b >>= 1;
}
return ans;
}
long long w[55], a[55], W0, W1;
long long dp[... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 52 + 5;
const int mod = 998244353;
long long qp(long long a, long long n) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
template <class T>
inline bool scan(T &ret) {
char... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long i, i0, n, m, a[55], w[55], dp[55][55][55][55], dic[3055],
ddic[3055][3055];
long long inv(long long b) {
return b == 1 ? 1 : (mod - mod / b) * inv(mod % b) % mod;
}
int main() {
for (i = 1; i <= 3050; i++) dic[i] = inv(i);
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const long long mod = 998244353;
int n, m;
int sum[2];
int a[MAXN], w[MAXN];
int memo[MAXN * 2][MAXN][MAXN][MAXN][2];
long long fastPow(long long x, long long p) {
long long answer = 1, current = x;
while (p != 0) {
if (p % 2 != 0) {
answe... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int dp[2555][105][55];
long long a[55], wi[55], cur, sp, sn, su, mo;
long long expo(long long base, long long exponent, long long mod = 998244353) {
long long ans = 1;
while (exponent != 0) {
if ((exponent & 1) == 1) {
ans = ans * base;
ans = ans % mod;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
std::cout << a << ' ';
err(args...);
}
using namespace std;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;
const int maxq = 3000 + 5;
long long qpow... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7, M = 3e3 + 7, mod = 998244353;
int f[M * 2], d[M][M], n, m, i, j, k, a[N], b[N], s[2], s0, s1, b0, b1;
long long pow_mod(long long x, long long n) {
x = (x % mod + mod) % mod;
long long res = 1;
while (n) {
if (n & 1) res = res * x % mod;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long dp[52][52][52];
long long inv[3010], sum0, sum1, sum;
long long a[55], b[55], n, m;
long long qpow(long long x, long long y) {
long long ans = 1;
for (; y; y >>= 1) {
if (y & 1) ans = (ans * x) % mod;
x = (x * x) % mod;... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long fpw(long long n, long long p) {
if (p == 0) return 1LL;
long long tmp = fpw(n, p / 2);
tmp *= tmp;
tmp %= 998244353;
if (p % 2 == 1) {
tmp *= n;
tmp %= 998244353;
}
return tmp;
}
long long inv(long long k) { return fpw(k, 998244353 - 2); }
lo... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
inline long long Msum(long long x) { return x; }
template <typename... Rest>
inline long long Msum(long long x, Rest... rest) {
return (x + Msum(rest...)) % MOD;
}
inline long long Mprod(long long x) { return x; }
template <typename... Rest>
inl... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int mod = 998244353;
long long qpow(long long a, long long b) {
long long ans = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) ans = ans * a % mod;
a = a * a % mod;
}
return ans;
}
long long gcd(long long a, ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m;
int a[55], b[55];
int sigG, sigA, sigB;
long long dp[55][55][55];
long long fp[1000005];
const long long mod = 998244353;
long long qp(long long a, long long b) {
if (b == 0) {
return 1;
}
long long ans = qp(a, b / 2);
if (b % 2) {
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int n, m, A, B, S, sl, fh, a[200010], w[200010], inv[3010 << 1], f[3010][3010],
g[3010][3010];
int rd() {
sl = 0;
fh = 1;
char ch = getchar();
while (ch < '0' || '9' < ch) {
if (ch == '-') fh = -1;
ch = getchar();
}
while ('0' <= ch && ch <= '9') sl ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 55;
long long ans;
long long dp[N][N * 2][N];
long long rev[N * 2];
int n, m, tot, one, zero;
int l[N], w[N];
long long Pow(int x, int y) {
long long ret = 1ll, mt = 1ll * x;
while (y) {
if (y & 1) ret = (ret * mt) % MOD;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 10000;
const int mod = 998244353;
long long a[maxn], w[maxn], inv[maxn], dp[100][100][100], A, B, m, n;
void add(long long& x, long long y) { x = (x + y) % mod; }
long long mul(long long x, long long y) { return (x * y) % mod; }
void mul2(long long& x, long... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch - '0' < 0 || ch - '0' > 9) {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch - '0' >= 0 && ch - '0' <= 9) {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int n, m, A, B... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int NN = 200020, MM = 3030;
const int mod = 998244353;
int power(int a, int b, int m = mod, int ans = 1) {
for (; b; b >>= 1, a = 1LL * a * a % m)
if (b & 1) ans = 1LL * ans * a % m;
return ans;
}
unordered_map<int, int> mp;
int inv(int a) {
if (a < 1) retur... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
int64_t powmo(int64_t a, int64_t b) {
int64_t r = 1;
for (; b; b >>= 1) {
if (b & 1) r = r * a % MOD;
a = a * a % MOD;
}
return r;
}
int64_t mdiv(int64_t a, int64_t b) { return a * powmo(b, MOD - 2) % MOD; }
bitset<300005> like... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch - '0' < 0 || ch - '0' > 9) {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch - '0' >= 0 && ch - '0' <= 9) {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int n, m;
int ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int64_t mod = 998244353;
int64_t mod1 = 1e9 + 5;
int64_t power(int64_t a, int64_t b) {
if (b == 0)
return 1;
else if (b % 2 == 0)
return power(((((a) % mod) * ((a) % mod)) % mod), b / 2) % mod;
else
return (((a) % mod) *
(power(((((a) % mod) * ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 998244353;
long long n, m, cnt[2], sum[2], a[55], p[55];
long long dp[55][55][55], val[55][55][55], vis[55][55][55];
long long qpow(long long a, long long b) {
long long ans = 1;
while (b) {
if (b & 1) ans = ans * a % mod;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int N = 55;
const long long mod = 998244353;
long long fpow(long long x, long long y) {
x %= mod;
long long ret = 1;
while (y) {
if (y & 1) ret = (long long)ret * x % mod;
y >>= 1;
x = (long long)x * x % mod;
}
return ret;
}
int n, m;
int a[N];
i... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
vector<long long> a, b;
int cur = 0;
long long su = 0;
long long gpos = 0;
long long gneg = 0;
long long mod = 998244353;
long long fpow(long long a, long long b, long long md) {
long long res = 1;
a = (a % md);
while (b > 0) {
if (b % 2 == 1) {
res = (res *... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long pow_mod(long long a, long long p) {
if (p == 0) return 1;
long long ret = pow_mod(a, p / 2);
ret = ret * ret % mod;
if (p % 2 == 1) ret = ret * a % mod;
return ret;
}
long long _inv(long long a) { return pow_mod(a, mod - ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int rw = 998244353;
int n, m;
int a[52], w[52], sum1, sum2;
int dp[52][52][52];
int ni[100005];
int ksm(int x, int y) {
int ans = 1;
while (y) {
if (y & 1) ans = 1LL * x * ans % rw;
x = 1LL * x * x % rw;
y >>= 1;
}
return ans;
}
int solve(int r) {
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
namespace FastIO {
const int L = (1 << 20);
char buf[L], *S, *T;
inline char getchar() {
if (S == T) {
T = (S = buf) + fread(buf, 1, L, stdin);
if (S == T) return EOF;
}
return *S++;
}
inline int read() {
int s = 0, f = 1;
char t = getchar();
while ('0' ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long a[55], w[55], dp[55][55][55];
long long fast(long long x, long long b, long long res = 1) {
while (b) {
if (b & 1) res = res * x % 998244353;
x = x * x % 998244353;
b >>= 1;
}
return res;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
long long r... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 200005, M = 3003;
int n, m, a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];
inline long long qp(long long a, long long b) {
if (b < 0) return b;
if (b == 0) return 1;
long long rt = 1;
while (b) {
if (b & 1) rt *... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... |
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Andy Phan
*/
public class p1173e {
static int MOD = 998244353;
static int n;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.