problem_id stringlengths 6 6 | language stringclasses 2
values | original_status stringclasses 3
values | original_src stringlengths 19 243k | changed_src stringlengths 19 243k | change stringclasses 3
values | i1 int64 0 8.44k | i2 int64 0 8.44k | j1 int64 0 8.44k | j2 int64 0 8.44k | error stringclasses 270
values | stderr stringlengths 0 226k |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02875 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int, int>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
template <class T> void chmax(T &a, T b) {
if (a < b)
a = b;
}
template <class T> void chmin(T &a, T b) {
if (a > b)
a = b;
}
constexpr int INF = 1000000000000000000;
constexpr int mod = 998244353;
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
bool prime(int a) {
if (a == 1)
return false;
for (int i = 2; i * i <= a; i++) {
if (a % i == 0)
return false;
}
return true;
}
vector<int> kaijo;
void init_fact(int n) {
kaijo.resize(n + 1);
kaijo[0] = 1;
for (int i = 1; i <= n; i++) {
kaijo[i] = kaijo[i - 1] * i;
kaijo[i] %= mod;
}
}
int modpow(int a, int b) {
if (b == 0)
return 1;
if (b % 2)
return modpow(a, b - 1) * a % mod;
int memo = modpow(a, b / 2);
return memo * memo % mod;
}
int comb(int a, int b) {
// if(!kaijo[0])init_fact(2000010);
return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod *
modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
x = modpow(x, mod - 2);
return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy,
double dx, double dy) {
double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
return tc * td < 0 && ta * tb < 0;
}
signed main() {
int n;
cin >> n;
init_fact(20000010);
int Comb = comb(n, n / 2);
int ans = modpow(3, n);
int beki[2000002];
beki[0] = 1;
for (int i = 1; i <= n + 1; i++) {
beki[i] = beki[i - 1] * 2 % mod;
}
for (int i = n / 2 + 1; i <= n; i++) {
ans -= comb(n, i) * beki[n - i + 1] % mod;
ans += mod;
ans %= mod;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int, int>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
template <class T> void chmax(T &a, T b) {
if (a < b)
a = b;
}
template <class T> void chmin(T &a, T b) {
if (a > b)
a = b;
}
constexpr int INF = 1000000000000000000;
constexpr int mod = 998244353;
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
bool prime(int a) {
if (a == 1)
return false;
for (int i = 2; i * i <= a; i++) {
if (a % i == 0)
return false;
}
return true;
}
vector<int> kaijo;
void init_fact(int n) {
kaijo.resize(n + 1);
kaijo[0] = 1;
for (int i = 1; i <= n; i++) {
kaijo[i] = kaijo[i - 1] * i;
kaijo[i] %= mod;
}
}
int modpow(int a, int b) {
if (b == 0)
return 1;
if (b % 2)
return modpow(a, b - 1) * a % mod;
int memo = modpow(a, b / 2);
return memo * memo % mod;
}
int comb(int a, int b) {
// if(!kaijo[0])init_fact(2000010);
return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod *
modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
x = modpow(x, mod - 2);
return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy,
double dx, double dy) {
double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
return tc * td < 0 && ta * tb < 0;
}
signed main() {
int n;
cin >> n;
init_fact(20000010);
int Comb = comb(n, n / 2);
int ans = modpow(3, n);
int beki[20000002];
beki[0] = 1;
for (int i = 1; i <= n + 1; i++) {
beki[i] = beki[i - 1] * 2 % mod;
}
for (int i = n / 2 + 1; i <= n; i++) {
ans -= comb(n, i) * beki[n - i + 1] % mod;
ans += mod;
ans %= mod;
}
cout << ans << endl;
return 0;
} | replace | 77 | 78 | 77 | 78 | -11 | |
p02875 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i)
#define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i)
#define per(i, N) for (int i = (N)-1; i >= 0; --i)
#define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP \
cin.tie(0); \
ios::sync_with_stdio(false);
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; }
template <int MOD> struct Fp {
ll val;
constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
if (val < 0)
v += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept {
return is >> x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
const int MOD = 998244353;
// const int MOD = 1e6 + 3;
// const int MOD = 1e9 + 7;
const int N_MAX = 2e5 + 5;
// mint:mod演算のための型
using mint = Fp<MOD>;
// 型変換
#define MINT (mint)
// mod MOD上での階乗
mint fact[N_MAX];
mint finv[N_MAX];
void init() {
fact[0] = fact[1] = MINT 1;
for (int i = 2; i < N_MAX; i++) {
fact[i] = fact[i - 1] * i;
}
finv[N_MAX - 1] = MINT 1 / fact[N_MAX - 1];
for (int i = N_MAX - 1; i > 0; --i) {
finv[i - 1] = finv[i] * i;
}
}
// mod MOD上での逆元
inline mint inv(mint n) { return MINT 1 / n; }
// 二項係数の計算(mod MOD上)
inline mint COM(int n, int k) {
if (n < k)
return 0;
if (k < 0)
return 0;
return fact[n] * finv[k] * finv[n - k];
}
// 順列計算
inline mint PER(int n, int k) {
if (n < k)
return 0;
if (k < 0)
return 0;
return fact[n] * finv[n - k];
}
int main(void) {
SPEEDUP
cout << setprecision(15);
init();
int N;
cin >> N;
mint ans = modpow(MINT 3, N);
repp(k, N / 2 + 1, N + 1) {
ans -= MINT 2 * COM(N, k) * modpow(MINT 2, N - k);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i)
#define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i)
#define per(i, N) for (int i = (N)-1; i >= 0; --i)
#define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP \
cin.tie(0); \
ios::sync_with_stdio(false);
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; }
template <int MOD> struct Fp {
ll val;
constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
if (val < 0)
v += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept {
return is >> x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
const int MOD = 998244353;
// const int MOD = 1e6 + 3;
// const int MOD = 1e9 + 7;
const int N_MAX = 1e7 + 5;
// mint:mod演算のための型
using mint = Fp<MOD>;
// 型変換
#define MINT (mint)
// mod MOD上での階乗
mint fact[N_MAX];
mint finv[N_MAX];
void init() {
fact[0] = fact[1] = MINT 1;
for (int i = 2; i < N_MAX; i++) {
fact[i] = fact[i - 1] * i;
}
finv[N_MAX - 1] = MINT 1 / fact[N_MAX - 1];
for (int i = N_MAX - 1; i > 0; --i) {
finv[i - 1] = finv[i] * i;
}
}
// mod MOD上での逆元
inline mint inv(mint n) { return MINT 1 / n; }
// 二項係数の計算(mod MOD上)
inline mint COM(int n, int k) {
if (n < k)
return 0;
if (k < 0)
return 0;
return fact[n] * finv[k] * finv[n - k];
}
// 順列計算
inline mint PER(int n, int k) {
if (n < k)
return 0;
if (k < 0)
return 0;
return fact[n] * finv[n - k];
}
int main(void) {
SPEEDUP
cout << setprecision(15);
init();
int N;
cin >> N;
mint ans = modpow(MINT 3, N);
repp(k, N / 2 + 1, N + 1) {
ans -= MINT 2 * COM(N, k) * modpow(MINT 2, N - k);
}
cout << ans << endl;
return 0;
}
| replace | 101 | 102 | 101 | 102 | 0 | |
p02875 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define pii pair<ll, ll>
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
using namespace std;
#define MAXN 1000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2;
vector<ll> g[300500], f;
ll fac[MAXN], invfac[MAXN];
ll binpow(ll x, ll y) {
if (y == 0) {
return 1;
}
ll tmp = binpow(x, y / 2);
tmp = tmp * tmp % MOD;
if (y % 2) {
return x * tmp % MOD;
}
return tmp;
}
ll inv(ll x) { return binpow(x, MOD - 2); }
ll C(ll n, ll m) {
if (n < m) {
return 0;
}
return fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}
void precalc_facs() {
fac[0] = invfac[0] = 1;
for (int i = 1; i < MAXN; i++) {
fac[i] = fac[i - 1] * i % MOD;
invfac[i] = inv(fac[i]);
}
}
ll a[MAXN], pa[MAXN], p3[2 * MAXN], p2[2 * MAXN], sp[MAXN], spp[MAXN];
int main() {
precalc_facs();
cin >> n;
n /= 2;
p3[0] = 1;
p2[0] = 1;
for (int i = 0; i <= 2 * n; i++) {
p3[i + 1] = p3[i] * 3 % MOD;
p2[i + 1] = p2[i] * 2 % MOD;
}
for (int i = 0; i <= n; i++) {
sp[i] = p2[n - i] * C(n, i) % MOD;
spp[i + 1] = (spp[i] + sp[i]) % MOD;
}
for (int i = 0; i <= n; i++) {
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
ll sum = sp[i] * (p3[n] - (spp[n - i + 1] - spp[0])) % MOD;
ans = (ans + sum) % MOD;
// cout << ans << endl;
}
cout << (p3[n * 2] - ans * 2 + MOD * 2) % MOD << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define pii pair<ll, ll>
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
using namespace std;
#define MAXN 10000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2;
vector<ll> g[300500], f;
ll fac[MAXN], invfac[MAXN];
ll binpow(ll x, ll y) {
if (y == 0) {
return 1;
}
ll tmp = binpow(x, y / 2);
tmp = tmp * tmp % MOD;
if (y % 2) {
return x * tmp % MOD;
}
return tmp;
}
ll inv(ll x) { return binpow(x, MOD - 2); }
ll C(ll n, ll m) {
if (n < m) {
return 0;
}
return fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}
void precalc_facs() {
fac[0] = invfac[0] = 1;
for (int i = 1; i < MAXN; i++) {
fac[i] = fac[i - 1] * i % MOD;
invfac[i] = inv(fac[i]);
}
}
ll a[MAXN], pa[MAXN], p3[2 * MAXN], p2[2 * MAXN], sp[MAXN], spp[MAXN];
int main() {
precalc_facs();
cin >> n;
n /= 2;
p3[0] = 1;
p2[0] = 1;
for (int i = 0; i <= 2 * n; i++) {
p3[i + 1] = p3[i] * 3 % MOD;
p2[i + 1] = p2[i] * 2 % MOD;
}
for (int i = 0; i <= n; i++) {
sp[i] = p2[n - i] * C(n, i) % MOD;
spp[i + 1] = (spp[i] + sp[i]) % MOD;
}
for (int i = 0; i <= n; i++) {
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
ll sum = sp[i] * (p3[n] - (spp[n - i + 1] - spp[0])) % MOD;
ans = (ans + sum) % MOD;
// cout << ans << endl;
}
cout << (p3[n * 2] - ans * 2 + MOD * 2) % MOD << endl;
return 0;
} | replace | 21 | 22 | 21 | 22 | 0 | |
p02875 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
template <class T, class U> void ckmin(T &a, U b) {
if (a > b)
a = b;
}
template <class T, class U> void ckmax(T &a, U b) {
if (a < b)
a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a)-1; i >= (b); i--)
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 998244353
#define MAXN 5000013
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
int N;
ll ans;
ll fact[MAXN], ifact[MAXN], pw2[MAXN];
ll expo(ll a, ll e) {
if (e == 0)
return 1;
if (e & 1) {
return expo(a * a % INF, e >> 1) * a % INF;
}
return expo(a * a % INF, e >> 1);
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(4);
cin >> N;
fact[0] = 1;
FOR(i, 1, N + 10) { fact[i] = fact[i - 1] * i % INF; }
ifact[N + 9] = expo(fact[N + 9], INF - 2);
FORD(i, N + 9, 0) { ifact[i] = ifact[i + 1] * (i + 1) % INF; }
pw2[0] = 1;
FOR(i, 1, N + 10) {
pw2[i] = pw2[i - 1] + pw2[i - 1];
if (pw2[i] >= INF)
pw2[i] -= INF;
}
N /= 2;
ans = 1;
FOR(i, 0, 2 * N) {
ans *= 3;
ans %= INF;
}
FOR(i, N + 1, 2 * N + 1) {
ans -= 2 * fact[2 * N] * ifact[2 * N - i] % INF * ifact[i] % INF *
pw2[2 * N - i];
ans %= INF;
}
if (ans < 0)
ans += INF;
cout << ans << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
template <class T, class U> void ckmin(T &a, U b) {
if (a > b)
a = b;
}
template <class T, class U> void ckmax(T &a, U b) {
if (a < b)
a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a)-1; i >= (b); i--)
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 998244353
#define MAXN 10000013
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
int N;
ll ans;
ll fact[MAXN], ifact[MAXN], pw2[MAXN];
ll expo(ll a, ll e) {
if (e == 0)
return 1;
if (e & 1) {
return expo(a * a % INF, e >> 1) * a % INF;
}
return expo(a * a % INF, e >> 1);
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(4);
cin >> N;
fact[0] = 1;
FOR(i, 1, N + 10) { fact[i] = fact[i - 1] * i % INF; }
ifact[N + 9] = expo(fact[N + 9], INF - 2);
FORD(i, N + 9, 0) { ifact[i] = ifact[i + 1] * (i + 1) % INF; }
pw2[0] = 1;
FOR(i, 1, N + 10) {
pw2[i] = pw2[i - 1] + pw2[i - 1];
if (pw2[i] >= INF)
pw2[i] -= INF;
}
N /= 2;
ans = 1;
FOR(i, 0, 2 * N) {
ans *= 3;
ans %= INF;
}
FOR(i, N + 1, 2 * N + 1) {
ans -= 2 * fact[2 * N] * ifact[2 * N - i] % INF * ifact[i] % INF *
pw2[2 * N - i];
ans %= INF;
}
if (ans < 0)
ans += INF;
cout << ans << '\n';
return 0;
}
| replace | 24 | 25 | 24 | 25 | -11 | |
p02875 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rep1(i, n) for (int i = 1; i <= int(n); i++)
#define repR(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define rep1R(i, n) for (int i = int(n); i >= 1; i--)
#define loop(i, a, B) for (int i = a; i B; i++)
#define loopR(i, a, B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) \
cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", \
my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char *) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const &x, U const &...y) {
const char *o = "({[", *e = "]})";
for (int i = 0; *s != '\0'; cerr << *s++) {
if (count(o, o + 3, *s))
i++;
if (count(e, e + 3, *s))
i--;
if (!i && *s == ',')
break;
}
cerr << " = " << x;
if (*s == ',')
cerr << ", ", s++;
my_dmp(s, y...);
}
#else
#define dump(...)
#endif
using ll = long long;
using ld = long double;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T>>;
template <class T, class = typename T::iterator,
class = typename enable_if<!is_same<T, string>::value>::type>
ostream &operator<<(ostream &os, T const &v) {
os << "{";
for (auto const &x : v)
os << " " << x;
return os << " }";
}
template <class T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &x : v)
is >> x;
return is;
}
template <class T, class S>
ostream &operator<<(ostream &os, pair<T, S> const &p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template <class T, class S> istream &operator>>(istream &is, pair<T, S> &p) {
return is >> p.first >> p.second;
}
struct my_Init {
my_Init() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
} my_init;
template <class T, size_t d, class = typename enable_if<(d == 0)>::type>
constexpr auto make_v(T const &x = {}) {
return x;
}
template <class T, size_t d, class... U,
class = typename enable_if<(d > 0)>::type>
constexpr auto make_v(size_t n, U... x) {
auto val = make_v<T, d - 1>(x...);
return vector<decltype(val)>(n, move(val));
}
template <class T> void quit(T const &x) {
cout << x << endl;
exit(0);
}
template <class T> constexpr bool chmin(T &x, T const &y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <class T> constexpr bool chmax(T &x, T const &y) {
if (x < y) {
x = y;
return true;
}
return false;
}
template <class It> constexpr auto sumof(It b, It e) {
return accumulate(b, e, typename iterator_traits<It>::value_type{});
}
const ll INF = (1LL << 62) - 1; // ~ 4.6e18
////////////////////////////////
//
using ll = long long;
template <int M> // m : prime
class modint {
ll x;
struct Table {
static const int Size = 1e6 + 10;
static_assert(Size <= M, "");
ll fac[Size], finv[Size], inv[Size];
Table() {
fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
for (int i = 2; i < Size; i++) {
fac[i] = fac[i - 1] * i % M;
inv[i] = M - inv[M % i] * (M / i) % M;
finv[i] = finv[i - 1] * inv[i] % M;
}
}
};
static const Table tab;
public:
static modint fact(int n) {
assert(0 <= n && n < Table::Size);
return tab.fac[n];
}
static modint finv(int n) {
assert(0 <= n && n < Table::Size);
return tab.finv[n];
}
static modint C(int n, int k) {
if (n < 0 || k < 0 || n < k)
return 0;
return fact(n) * finv(k) * finv(n - k);
}
static modint P(int n, int k) {
assert(n >= 0 && k >= 0 && n >= k);
return fact(n) * finv(n - k);
}
public:
modint(ll x = 0) : x((x %= M) < 0 ? x + M : x) {}
ll val() const { return x; }
bool operator==(modint rhs) const { return x == rhs.x; }
bool operator!=(modint rhs) const { return x != rhs.x; }
modint operator+() const { return *this; }
modint operator-() const { return {M - x}; }
modint &operator+=(modint rhs) {
if ((x += rhs.x) >= M)
x -= M;
return *this;
}
modint &operator-=(modint rhs) {
if ((x += M - rhs.x) >= M)
x -= M;
return *this;
}
modint &operator*=(modint rhs) {
(x *= rhs.x) %= M;
return *this;
}
modint operator+(modint rhs) const { return modint(*this) += rhs; }
modint operator-(modint rhs) const { return modint(*this) -= rhs; }
modint operator*(modint rhs) const { return modint(*this) *= rhs; }
modint &operator/=(modint rhs) { return *this *= rhs.inv(); }
modint operator/(modint rhs) const { return *this * rhs.inv(); }
modint pow(ll n) const {
if (n < 0)
return inv().pow(-n);
modint v = *this, r = 1;
for (; n > 0; n >>= 1, v *= v)
if (n & 1)
r *= v;
return r;
}
modint inv() const {
assert(x != 0);
ll t = 1, v = x, q, r;
while (v >= Table::Size) {
q = M / v;
r = M % v;
if (r * 2 < v) {
t *= -q;
t %= M;
v = r;
} else {
t *= q + 1;
t %= M;
v -= r;
}
}
return t * tab.inv[v] % M;
}
};
template <int M> typename modint<M>::Table const modint<M>::tab;
template <int M> ostream &operator<<(ostream &os, modint<M> rhs) {
return os << rhs.val();
}
template <int M> istream &operator>>(istream &is, modint<M> &rhs) {
ll x;
is >> x;
rhs = x;
return is;
}
constexpr int MOD = 998244353;
using mint = modint<MOD>;
//
int32_t main() {
int n;
cin >> n;
mint ans = mint(3).pow(n);
loop(k, n / 2 + 1, <= n) ans -= mint::C(n, k) * mint(2).pow(n - k + 1);
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rep1(i, n) for (int i = 1; i <= int(n); i++)
#define repR(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define rep1R(i, n) for (int i = int(n); i >= 1; i--)
#define loop(i, a, B) for (int i = a; i B; i++)
#define loopR(i, a, B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) \
cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", \
my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char *) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const &x, U const &...y) {
const char *o = "({[", *e = "]})";
for (int i = 0; *s != '\0'; cerr << *s++) {
if (count(o, o + 3, *s))
i++;
if (count(e, e + 3, *s))
i--;
if (!i && *s == ',')
break;
}
cerr << " = " << x;
if (*s == ',')
cerr << ", ", s++;
my_dmp(s, y...);
}
#else
#define dump(...)
#endif
using ll = long long;
using ld = long double;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T>>;
template <class T, class = typename T::iterator,
class = typename enable_if<!is_same<T, string>::value>::type>
ostream &operator<<(ostream &os, T const &v) {
os << "{";
for (auto const &x : v)
os << " " << x;
return os << " }";
}
template <class T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &x : v)
is >> x;
return is;
}
template <class T, class S>
ostream &operator<<(ostream &os, pair<T, S> const &p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template <class T, class S> istream &operator>>(istream &is, pair<T, S> &p) {
return is >> p.first >> p.second;
}
struct my_Init {
my_Init() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
} my_init;
template <class T, size_t d, class = typename enable_if<(d == 0)>::type>
constexpr auto make_v(T const &x = {}) {
return x;
}
template <class T, size_t d, class... U,
class = typename enable_if<(d > 0)>::type>
constexpr auto make_v(size_t n, U... x) {
auto val = make_v<T, d - 1>(x...);
return vector<decltype(val)>(n, move(val));
}
template <class T> void quit(T const &x) {
cout << x << endl;
exit(0);
}
template <class T> constexpr bool chmin(T &x, T const &y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <class T> constexpr bool chmax(T &x, T const &y) {
if (x < y) {
x = y;
return true;
}
return false;
}
template <class It> constexpr auto sumof(It b, It e) {
return accumulate(b, e, typename iterator_traits<It>::value_type{});
}
const ll INF = (1LL << 62) - 1; // ~ 4.6e18
////////////////////////////////
//
using ll = long long;
template <int M> // m : prime
class modint {
ll x;
struct Table {
// static const int Size = 1e6 + 10;
static const int Size = 1e7 + 10;
static_assert(Size <= M, "");
ll fac[Size], finv[Size], inv[Size];
Table() {
fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
for (int i = 2; i < Size; i++) {
fac[i] = fac[i - 1] * i % M;
inv[i] = M - inv[M % i] * (M / i) % M;
finv[i] = finv[i - 1] * inv[i] % M;
}
}
};
static const Table tab;
public:
static modint fact(int n) {
assert(0 <= n && n < Table::Size);
return tab.fac[n];
}
static modint finv(int n) {
assert(0 <= n && n < Table::Size);
return tab.finv[n];
}
static modint C(int n, int k) {
if (n < 0 || k < 0 || n < k)
return 0;
return fact(n) * finv(k) * finv(n - k);
}
static modint P(int n, int k) {
assert(n >= 0 && k >= 0 && n >= k);
return fact(n) * finv(n - k);
}
public:
modint(ll x = 0) : x((x %= M) < 0 ? x + M : x) {}
ll val() const { return x; }
bool operator==(modint rhs) const { return x == rhs.x; }
bool operator!=(modint rhs) const { return x != rhs.x; }
modint operator+() const { return *this; }
modint operator-() const { return {M - x}; }
modint &operator+=(modint rhs) {
if ((x += rhs.x) >= M)
x -= M;
return *this;
}
modint &operator-=(modint rhs) {
if ((x += M - rhs.x) >= M)
x -= M;
return *this;
}
modint &operator*=(modint rhs) {
(x *= rhs.x) %= M;
return *this;
}
modint operator+(modint rhs) const { return modint(*this) += rhs; }
modint operator-(modint rhs) const { return modint(*this) -= rhs; }
modint operator*(modint rhs) const { return modint(*this) *= rhs; }
modint &operator/=(modint rhs) { return *this *= rhs.inv(); }
modint operator/(modint rhs) const { return *this * rhs.inv(); }
modint pow(ll n) const {
if (n < 0)
return inv().pow(-n);
modint v = *this, r = 1;
for (; n > 0; n >>= 1, v *= v)
if (n & 1)
r *= v;
return r;
}
modint inv() const {
assert(x != 0);
ll t = 1, v = x, q, r;
while (v >= Table::Size) {
q = M / v;
r = M % v;
if (r * 2 < v) {
t *= -q;
t %= M;
v = r;
} else {
t *= q + 1;
t %= M;
v -= r;
}
}
return t * tab.inv[v] % M;
}
};
template <int M> typename modint<M>::Table const modint<M>::tab;
template <int M> ostream &operator<<(ostream &os, modint<M> rhs) {
return os << rhs.val();
}
template <int M> istream &operator>>(istream &is, modint<M> &rhs) {
ll x;
is >> x;
rhs = x;
return is;
}
constexpr int MOD = 998244353;
using mint = modint<MOD>;
//
int32_t main() {
int n;
cin >> n;
mint ans = mint(3).pow(n);
loop(k, n / 2 + 1, <= n) ans -= mint::C(n, k) * mint(2).pow(n - k + 1);
cout << ans << endl;
}
| replace | 110 | 111 | 110 | 112 | 0 | |
p02875 | C++ | Runtime Error | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
// template
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(v) (v).begin(), (v).end()
typedef long long int ll;
typedef pair<ll, ll> P;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
const int inf = 0x3fffffff;
const ll INF = 0x3fffffffffffffff;
// template end
ll mod = 998244353;
struct Mint {
ll val;
Mint inv() const {
ll tmp, a = val, b = mod, x = 1, y = 0;
while (b)
tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
return Mint(x);
}
public:
Mint() : val(0) {}
Mint(ll x) : val(x >= 0 ? x % mod : x % mod + mod) {}
int mtoi() { return this->val; }
Mint pow(ll t) {
Mint res = 1, b = *this;
while (t) {
if (t & 1)
res *= b;
b *= b;
t >>= 1;
}
return res;
}
Mint &operator+=(const Mint &x) {
if ((val += x.val) >= mod)
val -= mod;
return *this;
}
Mint &operator-=(const Mint &x) {
if ((val += mod - x.val) >= mod)
val -= mod;
return *this;
}
Mint &operator*=(const Mint &x) {
val = (ll)val * x.val % mod;
return *this;
}
Mint &operator/=(const Mint &x) { return *this *= x.inv(); }
bool operator==(const Mint &x) const { return val == x.val; }
bool operator!=(const Mint &x) const { return val != x.val; }
bool operator<(const Mint &x) const { return val < x.val; }
bool operator<=(const Mint &x) const { return val <= x.val; }
bool operator>(const Mint &x) const { return val > x.val; }
bool operator>=(const Mint &x) const { return val >= x.val; }
Mint operator+(const Mint &x) const { return Mint(*this) += x; }
Mint operator-(const Mint &x) const { return Mint(*this) -= x; }
Mint operator*(const Mint &x) const { return Mint(*this) *= x; }
Mint operator/(const Mint &x) const { return Mint(*this) /= x; }
};
struct factorial {
vector<Mint> Fact, Finv;
public:
factorial(int maxx) {
Fact.resize(maxx + 1), Finv.resize(maxx + 1);
Fact[0] = Mint(1);
rep(i, 0, maxx) Fact[i + 1] = Fact[i] * Mint(i + 1);
Finv[maxx] = Mint(1) / Fact[maxx];
rrep(i, maxx, 0) Finv[i - 1] = Finv[i] * Mint(i);
}
Mint fact(int n, bool inv = 0) {
if (inv)
return Finv[n];
else
return Fact[n];
}
Mint nPr(int n, int r) {
if (n < 0 || n < r || r < 0)
return Mint(0);
else
return Fact[n] * Finv[n - r];
}
Mint nCr(int n, int r) {
if (n < 0 || n < r || r < 0)
return Mint(0);
else
return Fact[n] * Finv[r] * Finv[n - r];
}
};
int main() {
int n;
scanf("%d", &n);
factorial fact(2000010);
Mint ans = Mint(3).pow(n);
rep(i, n / 2 + 1, n + 1) { ans -= fact.nCr(n, i) * Mint(2).pow(n - i) * 2; }
printf("%d\n", ans.val);
return 0;
} | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
// template
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(v) (v).begin(), (v).end()
typedef long long int ll;
typedef pair<ll, ll> P;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
const int inf = 0x3fffffff;
const ll INF = 0x3fffffffffffffff;
// template end
ll mod = 998244353;
struct Mint {
ll val;
Mint inv() const {
ll tmp, a = val, b = mod, x = 1, y = 0;
while (b)
tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
return Mint(x);
}
public:
Mint() : val(0) {}
Mint(ll x) : val(x >= 0 ? x % mod : x % mod + mod) {}
int mtoi() { return this->val; }
Mint pow(ll t) {
Mint res = 1, b = *this;
while (t) {
if (t & 1)
res *= b;
b *= b;
t >>= 1;
}
return res;
}
Mint &operator+=(const Mint &x) {
if ((val += x.val) >= mod)
val -= mod;
return *this;
}
Mint &operator-=(const Mint &x) {
if ((val += mod - x.val) >= mod)
val -= mod;
return *this;
}
Mint &operator*=(const Mint &x) {
val = (ll)val * x.val % mod;
return *this;
}
Mint &operator/=(const Mint &x) { return *this *= x.inv(); }
bool operator==(const Mint &x) const { return val == x.val; }
bool operator!=(const Mint &x) const { return val != x.val; }
bool operator<(const Mint &x) const { return val < x.val; }
bool operator<=(const Mint &x) const { return val <= x.val; }
bool operator>(const Mint &x) const { return val > x.val; }
bool operator>=(const Mint &x) const { return val >= x.val; }
Mint operator+(const Mint &x) const { return Mint(*this) += x; }
Mint operator-(const Mint &x) const { return Mint(*this) -= x; }
Mint operator*(const Mint &x) const { return Mint(*this) *= x; }
Mint operator/(const Mint &x) const { return Mint(*this) /= x; }
};
struct factorial {
vector<Mint> Fact, Finv;
public:
factorial(int maxx) {
Fact.resize(maxx + 1), Finv.resize(maxx + 1);
Fact[0] = Mint(1);
rep(i, 0, maxx) Fact[i + 1] = Fact[i] * Mint(i + 1);
Finv[maxx] = Mint(1) / Fact[maxx];
rrep(i, maxx, 0) Finv[i - 1] = Finv[i] * Mint(i);
}
Mint fact(int n, bool inv = 0) {
if (inv)
return Finv[n];
else
return Fact[n];
}
Mint nPr(int n, int r) {
if (n < 0 || n < r || r < 0)
return Mint(0);
else
return Fact[n] * Finv[n - r];
}
Mint nCr(int n, int r) {
if (n < 0 || n < r || r < 0)
return Mint(0);
else
return Fact[n] * Finv[r] * Finv[n - r];
}
};
int main() {
int n;
scanf("%d", &n);
factorial fact(10000010);
Mint ans = Mint(3).pow(n);
rep(i, n / 2 + 1, n + 1) { ans -= fact.nCr(n, i) * Mint(2).pow(n - i) * 2; }
printf("%d\n", ans.val);
return 0;
} | replace | 116 | 117 | 116 | 117 | 0 | |
p02875 | C++ | Runtime Error | /*
`-:://:::-
`//:-------:/:`
.+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.o:--...```..---+/`
`/y+o/---....---:+o.
`...````-os+/:---:/+o/--.`
`-/+++++/:. `...` :h+d+oooo+/+-` ...
`/++//:::://++-`....` -.`//````````:` `..`
`o+/::------://o/` `-` -. -` `..`
`---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..``
`....o+:-++/:--.```..-://s. `-` .- -` `-o:
.-//::::/:-`
`:s+/:--....-::/+s-` .- `- -` -///:--------:/:`
./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ
`+:--........--:/`
.:ooo+++++osso-` `.:-...`/` ./::-------:/:` -`
:+--..``````.--:+:...-+:-`
`.-/+++++/+-.-` -. ``:so:/:--.......--:+`
`-```````o+/+--..`````..--:o/-..:s+:.
```````:``.. `-` -`
`+:--..`````..--/+-.../.`````..-o:--.......---/o. `
`: `:- -. .o:--..`` ``..--:o` `-`
`:o+:--------:+o-`
`-`-... .. .o/--...```..--:+/` `-`
`oy/so/////++o/.`
-/` `-` `- ``+s/o/:---...---:++. `-`
.-../d://///:-.`
`.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-.
````
`:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `-
-++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `-
`` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.-
-----ss+:++/:--.```..-://s. /. `:: `-:. ./`
`````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-`
`-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-`
`:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-`
`./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:.
``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `-
`.:--h.``..```
-.-`.- .- `+:--..`````..--//` `-
/s-//::::::::.
-` `/- .. .o:--..`` ``..--:o.```.-
`//:--------://`
-` .-`.-`
-.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+`
..`-. `-. ``:os:o/:---...---:++. `-
``///+:-..``````.--:+-````-.`
`.:///////.-` .:-..` -``-+o+/:::::/+o/. `-
`:+:-..`````..--:o/:--/ys+-
`-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o.
`.`
`++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-`
`````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.`
-----syo/o+/:--.```..-://s. .-` `- .- `...
``-:////:-``
.` `/s//:--....-::/+s. -. `-` .- `..`
.+o+/:::--:://+s/-..` .::+y ``` .- `..`
./oo++////+oso-` `.... :y-+:::::::/` ...
`.:+oooooo/-` `....-. .//:-------:/:-.`
``...`` /+:+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.+/--...```..--:+/`
`-o/:---...---:++.
`-+o+/:---:/+o/.
`.:+oooo+/-.`
``````
*/
#ifdef aimbot
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <limits>
#include <list>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define random escape__from__random__aetuhoetnuhshe
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define umap unordered_map
#define uset unordered_set
#define elif else if
#define len(v) ((int)v.size())
#define f(i, n) for (int i = 0; i < (n); i++)
#define rof(i, n) for (int i = ((n)-1); i >= 0; i--)
#define apply(v, act) \
for (auto &x : v) { \
act; \
}
#define log(args...) \
{ \
string s = #args; \
deque<string> deq; \
string buf = ""; \
int bal = 0; \
for (char c : s) { \
if (c == '(' || c == '[' || c == '{') { \
bal++; \
} else if (c == ')' || c == ']' || c == '}') { \
bal--; \
} else { \
if (bal == 0) { \
if (c == ',') { \
deq.pb(buf); \
buf = ""; \
} else { \
if (c != ' ') { \
buf += c; \
} \
} \
} \
} \
} \
if (!buf.empty()) { \
deq.pb(buf); \
} \
smart_io::precall_print(); \
smart_io::_print(deq, args); \
}
inline int min(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
inline int max(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline long long min(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x;
}
inline long long max(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y;
}
#define print \
smart_io::precall_print(); \
cout,
#define scan cin,
#ifdef fast_allocator
const int MAXMEM = 200 * 1000 * 1024;
char _memory[MAXMEM];
size_t _ptr = 0;
void *operator new(size_t _x) {
_ptr += _x;
assert(_ptr < MAXMEM);
return _memory + _ptr - _x;
}
void operator delete(void *) noexcept {}
#endif
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &x) { scanf("%d", &x); }
void fast_scan(long long &x) { scanf("%lld", &x); }
void fast_scan(unsigned long long &x) { scanf("%llu", &x); }
void fast_scan(double &x) { scanf("%lf", &x); }
void fast_scan(long double &x) { scanf("%Lf", &x); }
void fast_scan(char &x) {
scanf("%c", &x);
if (x == '\n') {
fast_scan(x);
}
}
void fast_scan(string &x) {
scanf("%s", string_in_buffer);
x = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
fast_scan(p.first);
fast_scan(p.second);
}
template <class T> void fast_scan(vector<T> &v) {
for (auto &x : v)
fast_scan(x);
}
void fast_print(const int &x) { printf("%d", x); }
void fast_print(const unsigned int &x) { printf("%u", x); }
void fast_print(const long long &x) { printf("%lld", x); }
void fast_print(const unsigned long long &x) { printf("%llu", x); }
void fast_print(const char &x) { printf("%c", x); };
// void fast_print(__int128 x) {
// if (x == 0) { fast_print('0'); return; }
// if (x < 0) {
// fast_print('-');
// x = -x;
// }
// __int128 p = 1;
// while (x / (p * 10)) p *= 10;
// while (p) {
// __int128 symb = x / p;
// fast_print((int)symb);
// x -= p * symb;
// p /= 10;
// }
// };
void fast_print(const double &x) { printf("%.15lf", x); }
void fast_print(const long double &x) { printf("%.15Lf", x); }
void fast_print(const string &x) { printf("%s", x.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
fast_print(p.first);
fast_print(' ');
fast_print(p.second);
}
template <class T> void fast_print(const vector<T> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print(' ');
fast_print(v[i]);
}
}
template <class T> void fast_print(const vector<vector<T>> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print('\n');
fast_print(v[i]);
}
}
template <class T> void fast_print(const T &v) {
for (const auto &x : v) {
fast_print(x);
fast_print(' ');
}
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
fast_print(print_start);
print_start = "\n";
first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T elem, Args... args) {
if (!first_print) {
fast_print("\n");
} else {
first_print = false;
}
fast_print(names.front());
fast_print(" = ");
fast_print(elem);
names.pop_front();
_print(names, args...);
}
} // namespace smart_io
template <class T> ostream &operator,(ostream &os, const T &object) {
if (!smart_io::first_print) {
fast_print(smart_io::sep);
} else {
smart_io::first_print = false;
}
fast_print(object);
return os;
}
template <class T> istream &operator,(istream &is, T &object) {
fast_scan(object);
return is;
}
namespace random {
using namespace std::chrono;
mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count());
uniform_real_distribution<> prob_dist(0.0, 1.0);
}; // namespace random
#define int long long
namespace typedefs {
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long double ld;
} // namespace typedefs
namespace numbers_operation {
template <class T> inline T floor_mod(T a, const T &b) {
a %= b;
if (a < 0)
a += b;
return a;
}
} // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
using namespace random;
const ll MOD = 998244353;
vector<ll> fact{1};
ll fast_pow(ll x, ll p) {
ll r = 1;
while (p) {
if (p & 1)
r = (r * x) % MOD;
x = (x * x) % MOD;
p /= 2;
}
return r;
}
ll inv(ll x) { return fast_pow(x, MOD - 2); }
ll mul(ll a, ll b) { return (a * b) % MOD; }
ll binom(ll n, ll k) {
return (fact[n] * inv((fact[n - k] * fact[k]) % MOD)) % MOD;
}
signed main(signed argc, char *argv[]) {
int n;
scan n;
for (int i = 1; i < 10000; i++) {
fact.pb((i * fact.back()) % MOD);
}
// for (int i = 2; i < 100; i += 2) {
// n = i;
ll rez = fast_pow(3, n);
for (int x = n / 2 + 1; x <= n; x++) {
rez -= 2 * ((binom(n, x) * fast_pow(2, n - x)) % MOD);
rez %= MOD;
}
if (rez < 0)
rez += MOD;
// for (int y = 0; y <= n / 2; y++) {
// }
print rez;
// print "f(", n / 2, ")=", rez,",";
// fflush(stdout);
// }
}
| /*
`-:://:::-
`//:-------:/:`
.+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.o:--...```..---+/`
`/y+o/---....---:+o.
`...````-os+/:---:/+o/--.`
`-/+++++/:. `...` :h+d+oooo+/+-` ...
`/++//:::://++-`....` -.`//````````:` `..`
`o+/::------://o/` `-` -. -` `..`
`---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..``
`....o+:-++/:--.```..-://s. `-` .- -` `-o:
.-//::::/:-`
`:s+/:--....-::/+s-` .- `- -` -///:--------:/:`
./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ
`+:--........--:/`
.:ooo+++++osso-` `.:-...`/` ./::-------:/:` -`
:+--..``````.--:+:...-+:-`
`.-/+++++/+-.-` -. ``:so:/:--.......--:+`
`-```````o+/+--..`````..--:o/-..:s+:.
```````:``.. `-` -`
`+:--..`````..--/+-.../.`````..-o:--.......---/o. `
`: `:- -. .o:--..`` ``..--:o` `-`
`:o+:--------:+o-`
`-`-... .. .o/--...```..--:+/` `-`
`oy/so/////++o/.`
-/` `-` `- ``+s/o/:---...---:++. `-`
.-../d://///:-.`
`.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-.
````
`:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `-
-++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `-
`` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.-
-----ss+:++/:--.```..-://s. /. `:: `-:. ./`
`````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-`
`-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-`
`:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-`
`./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:.
``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `-
`.:--h.``..```
-.-`.- .- `+:--..`````..--//` `-
/s-//::::::::.
-` `/- .. .o:--..`` ``..--:o.```.-
`//:--------://`
-` .-`.-`
-.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+`
..`-. `-. ``:os:o/:---...---:++. `-
``///+:-..``````.--:+-````-.`
`.:///////.-` .:-..` -``-+o+/:::::/+o/. `-
`:+:-..`````..--:o/:--/ys+-
`-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o.
`.`
`++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-`
`````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.`
-----syo/o+/:--.```..-://s. .-` `- .- `...
``-:////:-``
.` `/s//:--....-::/+s. -. `-` .- `..`
.+o+/:::--:://+s/-..` .::+y ``` .- `..`
./oo++////+oso-` `.... :y-+:::::::/` ...
`.:+oooooo/-` `....-. .//:-------:/:-.`
``...`` /+:+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.+/--...```..--:+/`
`-o/:---...---:++.
`-+o+/:---:/+o/.
`.:+oooo+/-.`
``````
*/
#ifdef aimbot
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <limits>
#include <list>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define random escape__from__random__aetuhoetnuhshe
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define umap unordered_map
#define uset unordered_set
#define elif else if
#define len(v) ((int)v.size())
#define f(i, n) for (int i = 0; i < (n); i++)
#define rof(i, n) for (int i = ((n)-1); i >= 0; i--)
#define apply(v, act) \
for (auto &x : v) { \
act; \
}
#define log(args...) \
{ \
string s = #args; \
deque<string> deq; \
string buf = ""; \
int bal = 0; \
for (char c : s) { \
if (c == '(' || c == '[' || c == '{') { \
bal++; \
} else if (c == ')' || c == ']' || c == '}') { \
bal--; \
} else { \
if (bal == 0) { \
if (c == ',') { \
deq.pb(buf); \
buf = ""; \
} else { \
if (c != ' ') { \
buf += c; \
} \
} \
} \
} \
} \
if (!buf.empty()) { \
deq.pb(buf); \
} \
smart_io::precall_print(); \
smart_io::_print(deq, args); \
}
inline int min(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
inline int max(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline long long min(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x;
}
inline long long max(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y;
}
#define print \
smart_io::precall_print(); \
cout,
#define scan cin,
#ifdef fast_allocator
const int MAXMEM = 200 * 1000 * 1024;
char _memory[MAXMEM];
size_t _ptr = 0;
void *operator new(size_t _x) {
_ptr += _x;
assert(_ptr < MAXMEM);
return _memory + _ptr - _x;
}
void operator delete(void *) noexcept {}
#endif
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &x) { scanf("%d", &x); }
void fast_scan(long long &x) { scanf("%lld", &x); }
void fast_scan(unsigned long long &x) { scanf("%llu", &x); }
void fast_scan(double &x) { scanf("%lf", &x); }
void fast_scan(long double &x) { scanf("%Lf", &x); }
void fast_scan(char &x) {
scanf("%c", &x);
if (x == '\n') {
fast_scan(x);
}
}
void fast_scan(string &x) {
scanf("%s", string_in_buffer);
x = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
fast_scan(p.first);
fast_scan(p.second);
}
template <class T> void fast_scan(vector<T> &v) {
for (auto &x : v)
fast_scan(x);
}
void fast_print(const int &x) { printf("%d", x); }
void fast_print(const unsigned int &x) { printf("%u", x); }
void fast_print(const long long &x) { printf("%lld", x); }
void fast_print(const unsigned long long &x) { printf("%llu", x); }
void fast_print(const char &x) { printf("%c", x); };
// void fast_print(__int128 x) {
// if (x == 0) { fast_print('0'); return; }
// if (x < 0) {
// fast_print('-');
// x = -x;
// }
// __int128 p = 1;
// while (x / (p * 10)) p *= 10;
// while (p) {
// __int128 symb = x / p;
// fast_print((int)symb);
// x -= p * symb;
// p /= 10;
// }
// };
void fast_print(const double &x) { printf("%.15lf", x); }
void fast_print(const long double &x) { printf("%.15Lf", x); }
void fast_print(const string &x) { printf("%s", x.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
fast_print(p.first);
fast_print(' ');
fast_print(p.second);
}
template <class T> void fast_print(const vector<T> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print(' ');
fast_print(v[i]);
}
}
template <class T> void fast_print(const vector<vector<T>> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print('\n');
fast_print(v[i]);
}
}
template <class T> void fast_print(const T &v) {
for (const auto &x : v) {
fast_print(x);
fast_print(' ');
}
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
fast_print(print_start);
print_start = "\n";
first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T elem, Args... args) {
if (!first_print) {
fast_print("\n");
} else {
first_print = false;
}
fast_print(names.front());
fast_print(" = ");
fast_print(elem);
names.pop_front();
_print(names, args...);
}
} // namespace smart_io
template <class T> ostream &operator,(ostream &os, const T &object) {
if (!smart_io::first_print) {
fast_print(smart_io::sep);
} else {
smart_io::first_print = false;
}
fast_print(object);
return os;
}
template <class T> istream &operator,(istream &is, T &object) {
fast_scan(object);
return is;
}
namespace random {
using namespace std::chrono;
mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count());
uniform_real_distribution<> prob_dist(0.0, 1.0);
}; // namespace random
#define int long long
namespace typedefs {
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long double ld;
} // namespace typedefs
namespace numbers_operation {
template <class T> inline T floor_mod(T a, const T &b) {
a %= b;
if (a < 0)
a += b;
return a;
}
} // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
using namespace random;
const ll MOD = 998244353;
vector<ll> fact{1};
ll fast_pow(ll x, ll p) {
ll r = 1;
while (p) {
if (p & 1)
r = (r * x) % MOD;
x = (x * x) % MOD;
p /= 2;
}
return r;
}
ll inv(ll x) { return fast_pow(x, MOD - 2); }
ll mul(ll a, ll b) { return (a * b) % MOD; }
ll binom(ll n, ll k) {
return (fact[n] * inv((fact[n - k] * fact[k]) % MOD)) % MOD;
}
signed main(signed argc, char *argv[]) {
int n;
scan n;
for (int i = 1; i < n + 10; i++) {
fact.pb((i * fact.back()) % MOD);
}
// for (int i = 2; i < 100; i += 2) {
// n = i;
ll rez = fast_pow(3, n);
for (int x = n / 2 + 1; x <= n; x++) {
rez -= 2 * ((binom(n, x) * fast_pow(2, n - x)) % MOD);
rez %= MOD;
}
if (rez < 0)
rez += MOD;
// for (int y = 0; y <= n / 2; y++) {
// }
print rez;
// print "f(", n / 2, ")=", rez,",";
// fflush(stdout);
// }
}
| replace | 369 | 370 | 369 | 370 | 0 | |
p02875 | C++ | Runtime Error | // #include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #include "boost/multiprecision/cpp_int.hpp"
// typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
// #define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7 - 2
ll mod(ll a) {
ll c = a % i_7;
if (c >= 0)
return c;
return c + i_7;
}
typedef pair<ll, ll> l_l;
typedef pair<dd, dd> d_d;
ll inf = (ll)1E16;
#define rep(i, l, r) for (ll i = l; i <= r; i++)
#define pb push_back
ll max(ll a, ll b) {
if (a < b)
return b;
else
return a;
}
ll min(ll a, ll b) {
if (a > b)
return b;
else
return a;
}
void Max(ll &pos, ll val) { pos = max(pos, val); } // Max(dp[n],dp[n-1]);
void Min(ll &pos, ll val) { pos = min(pos, val); }
void Add(ll &pos, ll val) { pos = mod(pos + val); }
dd EPS = 1E-9;
#define fastio \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(), v.end())
#define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define POSL(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define POSU(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
//////////////////////////
ll po(ll i, ll p) {
if (p == 0)
return 1;
else {
i = mod(i);
if (p == 1)
return i;
if (p % 2 == 0)
return po(mod(i * i), p / 2);
return mod(i * po(i, p - 1));
}
}
ll bunbo(ll n) { return po(n, i_5); }
#define N 2000004
ll kai[N];
ll kai2[N];
void calc() {
kai[0] = 1;
kai2[0] = 1;
rep(i, 1, N - 1) { kai[i] = mod(kai[i - 1] * i); }
kai2[N - 1] = po(kai[N - 1], i_5);
for (ll i = N - 2; i >= 0; i--) {
kai2[i] = mod(kai2[i + 1] * (i + 1));
}
}
ll comb(ll n, ll k) {
if (n < k)
return 0;
if (n == 0)
return 1;
return mod(mod(kai[n] * kai2[n - k]) * kai2[k]);
}
int main() {
fastio calc();
ll n;
cin >> n;
ll ans = po(3, n);
ll gen = 0;
rep(a, n / 2 + 1, n) { Add(gen, comb(n, a) * po(2, n - a)); }
cout << mod(ans - gen * 2) << endl;
return 0;
}
| // #include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #include "boost/multiprecision/cpp_int.hpp"
// typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
// #define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7 - 2
ll mod(ll a) {
ll c = a % i_7;
if (c >= 0)
return c;
return c + i_7;
}
typedef pair<ll, ll> l_l;
typedef pair<dd, dd> d_d;
ll inf = (ll)1E16;
#define rep(i, l, r) for (ll i = l; i <= r; i++)
#define pb push_back
ll max(ll a, ll b) {
if (a < b)
return b;
else
return a;
}
ll min(ll a, ll b) {
if (a > b)
return b;
else
return a;
}
void Max(ll &pos, ll val) { pos = max(pos, val); } // Max(dp[n],dp[n-1]);
void Min(ll &pos, ll val) { pos = min(pos, val); }
void Add(ll &pos, ll val) { pos = mod(pos + val); }
dd EPS = 1E-9;
#define fastio \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(), v.end())
#define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define POSL(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define POSU(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
//////////////////////////
ll po(ll i, ll p) {
if (p == 0)
return 1;
else {
i = mod(i);
if (p == 1)
return i;
if (p % 2 == 0)
return po(mod(i * i), p / 2);
return mod(i * po(i, p - 1));
}
}
ll bunbo(ll n) { return po(n, i_5); }
#define N 25000004
ll kai[N];
ll kai2[N];
void calc() {
kai[0] = 1;
kai2[0] = 1;
rep(i, 1, N - 1) { kai[i] = mod(kai[i - 1] * i); }
kai2[N - 1] = po(kai[N - 1], i_5);
for (ll i = N - 2; i >= 0; i--) {
kai2[i] = mod(kai2[i + 1] * (i + 1));
}
}
ll comb(ll n, ll k) {
if (n < k)
return 0;
if (n == 0)
return 1;
return mod(mod(kai[n] * kai2[n - k]) * kai2[k]);
}
int main() {
fastio calc();
ll n;
cin >> n;
ll ans = po(3, n);
ll gen = 0;
rep(a, n / 2 + 1, n) { Add(gen, comb(n, a) * po(2, n - a)); }
cout << mod(ans - gen * 2) << endl;
return 0;
}
| replace | 79 | 80 | 79 | 80 | 0 | |
p02875 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const int MOD = 998244353;
const int MX = 5000005;
int n;
ll ans = 1, k;
ll exp(ll b, ll n) {
ll res = 1;
for (; n; n /= 2, (b *= b) %= MOD)
if (n % 2)
(res *= b) %= MOD;
return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n) {
for (int i = 1; i <= n; i++)
fact[i] = (fact[i - 1] * i) % MOD;
invf[n] = exp(fact[n], MOD - 2);
for (int i = n; i > 0; i--)
invf[i - 1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b) {
return fact[a] * invf[a - b] % MOD * invf[b] % MOD;
}
int main() {
scanf("%d", &n);
setcomb(n);
ans = exp(3, n);
rep(i, n / 2) ans -= comb(n, i) * exp(2, i) * 2 % MOD;
printf("%lld\n", (ans % MOD + MOD) % MOD);
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const int MOD = 998244353;
const int MX = 10000005;
int n;
ll ans = 1, k;
ll exp(ll b, ll n) {
ll res = 1;
for (; n; n /= 2, (b *= b) %= MOD)
if (n % 2)
(res *= b) %= MOD;
return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n) {
for (int i = 1; i <= n; i++)
fact[i] = (fact[i - 1] * i) % MOD;
invf[n] = exp(fact[n], MOD - 2);
for (int i = n; i > 0; i--)
invf[i - 1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b) {
return fact[a] * invf[a - b] % MOD * invf[b] % MOD;
}
int main() {
scanf("%d", &n);
setcomb(n);
ans = exp(3, n);
rep(i, n / 2) ans -= comb(n, i) * exp(2, i) * 2 % MOD;
printf("%lld\n", (ans % MOD + MOD) % MOD);
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02875 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
struct ModInt {
using M = ModInt;
long long v;
ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
M &norm() {
v = (v < MOD) ? v : v - MOD;
return *this;
}
M operator+(const M &x) const { return M(v + x.v); }
M operator-(const M &x) const { return M(v + MOD - x.v); }
M operator*(const M &x) const { return M(v * x.v % MOD); }
M operator/(const M &x) const { return M(v * x.inv().v); }
M &operator+=(const M &x) { return *this = *this + x; }
M &operator-=(const M &x) { return *this = *this - x; }
M &operator*=(const M &x) { return *this = *this * x; }
M &operator/=(const M &x) { return *this = *this / x; }
friend istream &operator>>(istream &input, M &x) {
return input >> x.v, x.norm(), input;
}
friend ostream &operator<<(ostream &output, const M &x) {
return output << x.v;
}
M pow(long long n) const {
M x(v), res(1);
while (n) {
if (n & 1)
res *= x;
x *= x;
n >>= 1;
}
return res;
}
M inv() const { return this->pow(MOD - 2); }
static long long MOD;
static vector<M> fact, finv;
static void build(int n) {
fact.assign(n + 1, 1);
for (int i = 1; i < n + 1; i++)
fact[i] = fact[i - 1] * M(i);
finv.assign(n + 1, fact[n].inv());
for (int i = n; i > 0; i--)
finv[i - 1] = finv[i] * M(i);
}
static M comb(int n, int k) {
if (n < k || k < 0)
return M(0);
return fact[n] * finv[n - k] * finv[k];
}
static M extgcd(int a, int b, int *x, int *y) {
M d(a);
if (b) {
d = extgcd(b, a % b, y, x);
*y -= (a / b) * *x;
} else {
*x = 1, *y = 0;
}
return d;
}
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 998244353;
int main() {
int n;
cin >> n;
ModInt::build(n);
ModInt u = ModInt(3).pow(n);
ModInt c = 0;
for (int i = n / 2 + 1; i <= n; i++) {
c += ModInt::comb(n, i) * ModInt(2).pow(n - i);
}
cout << u - c * 2 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
struct ModInt {
using M = ModInt;
long long v;
ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
M &norm() {
v = (v < MOD) ? v : v - MOD;
return *this;
}
M operator+(const M &x) const { return M(v + x.v); }
M operator-(const M &x) const { return M(v + MOD - x.v); }
M operator*(const M &x) const { return M(v * x.v % MOD); }
M operator/(const M &x) const { return M(v * x.inv().v); }
M &operator+=(const M &x) { return *this = *this + x; }
M &operator-=(const M &x) { return *this = *this - x; }
M &operator*=(const M &x) { return *this = *this * x; }
M &operator/=(const M &x) { return *this = *this / x; }
friend istream &operator>>(istream &input, M &x) {
return input >> x.v, x.norm(), input;
}
friend ostream &operator<<(ostream &output, const M &x) {
return output << x.v;
}
M pow(long long n) const {
M x(v), res(1);
while (n) {
if (n & 1)
res *= x;
x *= x;
n >>= 1;
}
return res;
}
M inv() const { return this->pow(MOD - 2); }
static long long MOD;
static vector<M> fact, finv;
static void build(int n) {
fact.assign(n + 1, 1);
for (int i = 1; i < n + 1; i++)
fact[i] = fact[i - 1] * M(i);
finv.assign(n + 1, fact[n].inv());
for (int i = n; i > 0; i--)
finv[i - 1] = finv[i] * M(i);
}
static M comb(int n, int k) {
if (n < k || k < 0)
return M(0);
return fact[n] * finv[n - k] * finv[k];
}
static M extgcd(int a, int b, int *x, int *y) {
M d(a);
if (b) {
d = extgcd(b, a % b, y, x);
*y -= (a / b) * *x;
} else {
*x = 1, *y = 0;
}
return d;
}
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 998244353;
int main() {
int n;
cin >> n;
ModInt::build(n);
ModInt u = ModInt(3).pow(n);
ModInt c = 0;
ModInt p = 1;
for (int i = n; i > n / 2; i--) {
c += ModInt::comb(n, i) * p;
p *= 2;
}
cout << u - c * 2 << endl;
}
| replace | 73 | 75 | 73 | 77 | TLE | |
p02875 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 998244353;
int n;
ll poww(ll x, ll k) {
ll ans = 1;
while (k) {
if (k & 1)
ans = ans * x % mod;
x = x * x % mod;
k >>= 1;
}
return ans;
}
ll mul[maxn], inv[maxn], er[maxn], ans;
ll C(int a, int b) { return mul[a] * inv[b] % mod * inv[a - b] % mod; }
ll QwQ;
int main() {
scanf("%d", &n);
mul[0] = 1, er[0] = 1;
for (int i = 1; i <= n; ++i)
mul[i] = mul[i - 1] * i % mod, er[i] = er[i - 1] * 2 % mod;
inv[n] = poww(mul[n], mod - 2);
for (int i = n; i; i--)
inv[i - 1] = inv[i] * i % mod;
inv[0] = 1;
for (int i = n / 2 + 1; i <= n; ++i) {
QwQ = (QwQ + C(n, i) * er[n - i] % mod) % mod;
}
cout << (poww(3, n) - QwQ * 2 % mod + mod) % mod << "\n";
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e7 + 10;
const int mod = 998244353;
int n;
ll poww(ll x, ll k) {
ll ans = 1;
while (k) {
if (k & 1)
ans = ans * x % mod;
x = x * x % mod;
k >>= 1;
}
return ans;
}
ll mul[maxn], inv[maxn], er[maxn], ans;
ll C(int a, int b) { return mul[a] * inv[b] % mod * inv[a - b] % mod; }
ll QwQ;
int main() {
scanf("%d", &n);
mul[0] = 1, er[0] = 1;
for (int i = 1; i <= n; ++i)
mul[i] = mul[i - 1] * i % mod, er[i] = er[i - 1] * 2 % mod;
inv[n] = poww(mul[n], mod - 2);
for (int i = n; i; i--)
inv[i - 1] = inv[i] * i % mod;
inv[0] = 1;
for (int i = n / 2 + 1; i <= n; ++i) {
QwQ = (QwQ + C(n, i) * er[n - i] % mod) % mod;
}
cout << (poww(3, n) - QwQ * 2 % mod + mod) % mod << "\n";
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02875 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cerr << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cerr << " " << v[i]; \
cerr << endl;
#define DEBUG_MAT(v) \
cerr << #v << endl; \
for (int i = 0; i < v.size(); i++) { \
for (int j = 0; j < v[i].size(); j++) { \
cerr << v[i][j] << " "; \
} \
cerr << endl; \
}
typedef long long ll;
#define int ll
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrep1(i, n) for (int i = (int)(n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(), c.end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout << setprecision(25) << fixed << p << endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() \
cin.tie(0); \
ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
// #define endl '\n'
const int MAXN = 10555550;
vl fact(MAXN);
vl rfact(MAXN);
ll mod_pow(ll x, ll p, ll M = MOD) {
if (p < 0) {
x = mod_pow(x, M - 2, M);
p = -p;
}
ll a = 1;
while (p) {
if (p % 2)
a = a * x % M;
x = x * x % M;
p /= 2;
}
return a;
}
ll mod_inverse(ll a, ll M = MOD) { return mod_pow(a, M - 2, M); }
void set_fact(ll n, ll M = MOD) {
fact[0] = fact[1] = rfact[0] = rfact[1] = 1;
for (ll i = 2; i <= n; i++) {
fact[i] = i * fact[i - 1] % M;
// rfact[i] = mod_inverse(fact[i], M);
}
}
// http://drken1215.hatenablog.com/entry/2018/06/08/210000
// n���傫��fact���v�Z�ł��Ȃ��Ƃ��̂ق��̌v�Z���@�ɂ��ď����Ă���
ll nCr(ll n, ll r, ll M = MOD) {
if (r > n)
return 0;
assert(fact[2] == 2);
ll ret = fact[n];
if (rfact[r] == 0) {
rfact[r] = mod_inverse(fact[r], M);
}
ret = (ret * rfact[r]) % M;
if (rfact[n - r] == 0) {
rfact[n - r] = mod_inverse(fact[n - r], M);
}
ret = (ret * rfact[n - r]) % M;
return ret;
}
ll nHr(ll n, ll r) { return nCr(n + r - 1, r); }
signed main() {
ll n;
cin >> n;
set_fact(n + 10);
ll zen = mod_pow(3, n);
ll sub = 0;
ll mul = 1;
for (int i = n; i > n / 2; i--) {
// for (int i = n / 2 + 1; i <= n; i++) {
sub += nCr(n, i) * mul % MOD;
mul = mul * 2 % MOD;
}
sub %= MOD;
zen -= 2 * sub;
zen = (zen % MOD + MOD) % MOD;
cout << zen << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cerr << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cerr << " " << v[i]; \
cerr << endl;
#define DEBUG_MAT(v) \
cerr << #v << endl; \
for (int i = 0; i < v.size(); i++) { \
for (int j = 0; j < v[i].size(); j++) { \
cerr << v[i][j] << " "; \
} \
cerr << endl; \
}
typedef long long ll;
#define int ll
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrep1(i, n) for (int i = (int)(n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(), c.end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout << setprecision(25) << fixed << p << endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() \
cin.tie(0); \
ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
// #define endl '\n'
const int MAXN = 10555550;
vl fact(MAXN);
vl rfact(MAXN);
ll mod_pow(ll x, ll p, ll M = MOD) {
if (p < 0) {
x = mod_pow(x, M - 2, M);
p = -p;
}
ll a = 1;
while (p) {
if (p % 2)
a = a * x % M;
x = x * x % M;
p /= 2;
}
return a;
}
ll mod_inverse(ll a, ll M = MOD) { return mod_pow(a, M - 2, M); }
void set_fact(ll n, ll M = MOD) {
fact[0] = fact[1] = rfact[0] = rfact[1] = 1;
for (ll i = 2; i <= n; i++) {
fact[i] = i * fact[i - 1] % M;
// rfact[i] = mod_inverse(fact[i], M);
}
rfact[n] = mod_inverse(fact[n], M);
for (ll i = n - 1; i >= 2; i--) {
rfact[i] = (i + 1) * rfact[i + 1] % M;
}
}
// http://drken1215.hatenablog.com/entry/2018/06/08/210000
// n���傫��fact���v�Z�ł��Ȃ��Ƃ��̂ق��̌v�Z���@�ɂ��ď����Ă���
ll nCr(ll n, ll r, ll M = MOD) {
if (r > n)
return 0;
assert(fact[2] == 2);
ll ret = fact[n];
if (rfact[r] == 0) {
rfact[r] = mod_inverse(fact[r], M);
}
ret = (ret * rfact[r]) % M;
if (rfact[n - r] == 0) {
rfact[n - r] = mod_inverse(fact[n - r], M);
}
ret = (ret * rfact[n - r]) % M;
return ret;
}
ll nHr(ll n, ll r) { return nCr(n + r - 1, r); }
signed main() {
ll n;
cin >> n;
set_fact(n + 10);
ll zen = mod_pow(3, n);
ll sub = 0;
ll mul = 1;
for (int i = n; i > n / 2; i--) {
// for (int i = n / 2 + 1; i <= n; i++) {
sub += nCr(n, i) * mul % MOD;
mul = mul * 2 % MOD;
}
sub %= MOD;
zen -= 2 * sub;
zen = (zen % MOD + MOD) % MOD;
cout << zen << endl;
} | insert | 110 | 110 | 110 | 114 | TLE | |
p02875 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <random>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
// #define ll __int128
// #define int ll
// #define int ll
// #define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for (int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#ifdef MAX_HOME
#define cerr cout
#else
#define cerr \
if (false) \
cerr
#endif
const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1>
inline istream &operator>>(istream &in, pair<T0, T1> &a) {
return in >> a.first >> a.second;
}
template <class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
<< "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
<< ", " << get<3>(a) << "}";
}
template <class T> inline ostream &operator<<(ostream &out, vector<T> &a) {
out << "[";
fori(i, a.size()) out << a[i]
<< vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef MAX_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#endif
cout << setprecision(4) << fixed;
smain();
#ifdef MAX_HOME
cout << "\n\n\n\nTOTAL EXECUTION TIME: "
<< float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif
return 0;
}
const int N = 1e7 + 10;
const int M = 998244353;
int pw(int a, int n = M - 2) {
int ret = 1;
while (n) {
if (n & 1)
ret = (ll)ret * a % M;
a = (ll)a * a % M;
n >>= 1;
}
return ret;
}
int fact[N], rfact[N];
int ncr(int n, int k) {
if (k < 0 || k > n)
return 0;
return (ll)fact[n] * rfact[k] % M * rfact[n - k] % M;
}
void init() {
fact[0] = 1;
for (int i = 1; i < N; ++i) {
fact[i] = (ll)i * fact[i - 1] % M;
}
rfact[N - 1] = pw(fact[N - 1]);
for (int i = N - 2; i >= 0; --i) {
rfact[i] = (ll)(i + 1) * rfact[i + 1] % M;
}
}
int naive(int n) {
n >>= 1;
int ans = 0;
fori(a0, n + 1) {
fori(b0, n - a0 + 1) {
int c0 = n - a0 - b0;
fori(a1, n + 1) {
fori(b1, n + 1 - a1) {
int c1 = n - a1 - b1;
bool ok = 1;
ok &= max(0, a0 - a1) + max(0, b0 - b1) <= c1;
ok &= max(0, a1 - a0) + max(0, b1 - b0) <= c0;
if (ok) {
int cur =
(ll)fact[n] * rfact[a0] % M * rfact[b0] % M * rfact[c0] % M;
cur = (ll)cur * fact[n] % M * rfact[a1] % M * rfact[b1] % M *
rfact[c1] % M;
ans = (ans + cur) % M;
}
}
}
}
}
return ans;
}
void insum(int &a, int b) { a = (a + b) % M; }
int solve(int n) {
n >>= 1;
int ans = 0;
fori(x, n + 1) {
fori(y, n + 1) { insum(ans, (ll)ncr(2 * n, x) * ncr(2 * n - x, y) % M); }
}
return ans;
}
void smain() {
init();
int n;
cin >> n;
// cout << naive(n) << endl;
cout << solve(n);
} | #include <bits/stdc++.h>
#include <random>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
// #define ll __int128
// #define int ll
// #define int ll
// #define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for (int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#ifdef MAX_HOME
#define cerr cout
#else
#define cerr \
if (false) \
cerr
#endif
const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1>
inline istream &operator>>(istream &in, pair<T0, T1> &a) {
return in >> a.first >> a.second;
}
template <class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
<< "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
<< ", " << get<3>(a) << "}";
}
template <class T> inline ostream &operator<<(ostream &out, vector<T> &a) {
out << "[";
fori(i, a.size()) out << a[i]
<< vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef MAX_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#endif
cout << setprecision(4) << fixed;
smain();
#ifdef MAX_HOME
cout << "\n\n\n\nTOTAL EXECUTION TIME: "
<< float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif
return 0;
}
const int N = 1e7 + 10;
const int M = 998244353;
int pw(int a, int n = M - 2) {
int ret = 1;
while (n) {
if (n & 1)
ret = (ll)ret * a % M;
a = (ll)a * a % M;
n >>= 1;
}
return ret;
}
int fact[N], rfact[N];
int ncr(int n, int k) {
if (k < 0 || k > n)
return 0;
return (ll)fact[n] * rfact[k] % M * rfact[n - k] % M;
}
void init() {
fact[0] = 1;
for (int i = 1; i < N; ++i) {
fact[i] = (ll)i * fact[i - 1] % M;
}
rfact[N - 1] = pw(fact[N - 1]);
for (int i = N - 2; i >= 0; --i) {
rfact[i] = (ll)(i + 1) * rfact[i + 1] % M;
}
}
int naive(int n) {
n >>= 1;
int ans = 0;
fori(a0, n + 1) {
fori(b0, n - a0 + 1) {
int c0 = n - a0 - b0;
fori(a1, n + 1) {
fori(b1, n + 1 - a1) {
int c1 = n - a1 - b1;
bool ok = 1;
ok &= max(0, a0 - a1) + max(0, b0 - b1) <= c1;
ok &= max(0, a1 - a0) + max(0, b1 - b0) <= c0;
if (ok) {
int cur =
(ll)fact[n] * rfact[a0] % M * rfact[b0] % M * rfact[c0] % M;
cur = (ll)cur * fact[n] % M * rfact[a1] % M * rfact[b1] % M *
rfact[c1] % M;
ans = (ans + cur) % M;
}
}
}
}
}
return ans;
}
void insum(int &a, int b) { a = (a + b) % M; }
int solve(int n) {
n >>= 1;
int ans = pw(3, n * 2);
for (int x = n + 1; x <= n * 2; ++x) {
int cur = 2LL * ncr(n * 2, x) * pw(2, n * 2 - x) % M;
ans = (ans + M - cur) % M;
}
return ans;
}
void smain() {
init();
int n;
cin >> n;
// cout << naive(n) << endl;
cout << solve(n);
} | replace | 174 | 177 | 174 | 178 | TLE | |
p02875 | C++ | Runtime Error | #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 <class T> ostream &operator<<(ostream &out, set<T> v) {
return prnt(out, v);
}
template <class T1, class T2> ostream &operator<<(ostream &out, map<T1, T2> v) {
return prnt(out, v);
}
template <class T1, class T2>
ostream &operator<<(ostream &out, pair<T1, T2> p) {
return out << '(' << p.st << ' ' << p.nd << ')';
}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
cerr << " " << H;
debug_out(T...);
}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) \
do { \
cerr << #x "[]: "; \
for (int _ = 0; _ < n; ++_) \
cerr << x[_] << " "; \
cerr << '\n'; \
} while (0)
#define dbg_ok cerr << "OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define MOD 998244353
#define zeros(x) x &(x - 1) ^ x
#define fi first
#define se second
#define Nmax 1000005
const long double PI = acos(-1);
int n, x;
int A[Nmax], S[Nmax], B[Nmax], S2[Nmax], P2[Nmax];
template <typename T = long long> T _pow(T a, T b) {
T ans = 1;
for (; b; b >>= 1) {
if (b % 2)
ans = ans * a % MOD;
a = a * a % MOD;
}
return ans;
}
long long P[Nmax], inv[Nmax];
template <typename T = long long> T comb(T n, T m) {
if (P[1] == 0)
cerr << "Apeleaza functia prec!\n";
return P[n] * inv[m] % MOD * inv[n - m] % MOD;
}
template <typename T = long long> inline void add(T &a, T b) {
a += b;
if (a >= MOD)
a -= MOD;
if (a < 0)
a += MOD;
}
void prec(int n = Nmax - 1) {
P[0] = inv[0] = 1;
for (int i = 1; i <= n; i++) {
P[i] = P[i - 1] * i % MOD;
inv[i] = _pow(P[i], MOD - 2LL);
}
}
int main() {
ios::sync_with_stdio(false);
prec();
cin >> n;
int x = n / 2;
P2[0] = 1;
for (int i = 1; i <= n; i++) {
P2[i] = 1LL * P2[i - 1] * 2 % MOD;
}
for (int i = 1; i <= x; i++) {
A[i] = comb(x, i);
}
for (int i = x; i >= 1; i--) {
add(S[i], S[i + 1]);
add(S[i], A[i]);
S2[i] = (S2[i + 1] + 1LL * A[i] * P2[x - i]) % MOD;
}
int ans = 0;
for (int i = 1; i <= x; i++) {
int y = (x + 1) - i;
// dbg(i,A[i],P2[x-i],S2[y]);
ans = (ans + 1LL * A[i] * P2[x - i] % MOD * S2[y]) % MOD;
}
// dbg(ans);
ans = ans * 2 % MOD;
ans = (1LL * _pow(3LL, 1LL * n) - ans + MOD) % MOD;
cout << ans << '\n';
return 0;
} | #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 <class T> ostream &operator<<(ostream &out, set<T> v) {
return prnt(out, v);
}
template <class T1, class T2> ostream &operator<<(ostream &out, map<T1, T2> v) {
return prnt(out, v);
}
template <class T1, class T2>
ostream &operator<<(ostream &out, pair<T1, T2> p) {
return out << '(' << p.st << ' ' << p.nd << ')';
}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
cerr << " " << H;
debug_out(T...);
}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) \
do { \
cerr << #x "[]: "; \
for (int _ = 0; _ < n; ++_) \
cerr << x[_] << " "; \
cerr << '\n'; \
} while (0)
#define dbg_ok cerr << "OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define MOD 998244353
#define zeros(x) x &(x - 1) ^ x
#define fi first
#define se second
#define Nmax 10000005
const long double PI = acos(-1);
int n, x;
int A[Nmax], S[Nmax], B[Nmax], S2[Nmax], P2[Nmax];
template <typename T = long long> T _pow(T a, T b) {
T ans = 1;
for (; b; b >>= 1) {
if (b % 2)
ans = ans * a % MOD;
a = a * a % MOD;
}
return ans;
}
long long P[Nmax], inv[Nmax];
template <typename T = long long> T comb(T n, T m) {
if (P[1] == 0)
cerr << "Apeleaza functia prec!\n";
return P[n] * inv[m] % MOD * inv[n - m] % MOD;
}
template <typename T = long long> inline void add(T &a, T b) {
a += b;
if (a >= MOD)
a -= MOD;
if (a < 0)
a += MOD;
}
void prec(int n = Nmax - 1) {
P[0] = inv[0] = 1;
for (int i = 1; i <= n; i++) {
P[i] = P[i - 1] * i % MOD;
inv[i] = _pow(P[i], MOD - 2LL);
}
}
int main() {
ios::sync_with_stdio(false);
prec();
cin >> n;
int x = n / 2;
P2[0] = 1;
for (int i = 1; i <= n; i++) {
P2[i] = 1LL * P2[i - 1] * 2 % MOD;
}
for (int i = 1; i <= x; i++) {
A[i] = comb(x, i);
}
for (int i = x; i >= 1; i--) {
add(S[i], S[i + 1]);
add(S[i], A[i]);
S2[i] = (S2[i + 1] + 1LL * A[i] * P2[x - i]) % MOD;
}
int ans = 0;
for (int i = 1; i <= x; i++) {
int y = (x + 1) - i;
// dbg(i,A[i],P2[x-i],S2[y]);
ans = (ans + 1LL * A[i] * P2[x - i] % MOD * S2[y]) % MOD;
}
// dbg(ans);
ans = ans * 2 % MOD;
ans = (1LL * _pow(3LL, 1LL * n) - ans + MOD) % MOD;
cout << ans << '\n';
return 0;
} | replace | 43 | 44 | 43 | 44 | 0 | |
p02875 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;
ll mod = 998244353;
ll mod_pow(ll a, ll b) {
a %= mod;
if (b == 0)
return 1;
if (b == 1)
return a;
ll res = mod_pow(a, b / 2) % mod;
res *= res;
res %= mod;
if (b % 2)
res *= a;
return res % mod;
}
struct perm {
private:
int sz;
vector<ll> p, invp;
public:
perm(int n) {
sz = n + 1;
p.resize(sz), invp.resize(sz);
p[0] = 1;
for (int i = 1; i <= sz - 1; i++) {
p[i] = p[i - 1] * i % mod;
}
invp[sz - 1] = mod_pow(p[sz - 1], mod - 2);
for (int i = sz - 2; i >= 0; i--) {
invp[i] = invp[i + 1] * (i + 1) % mod;
}
}
ll comb(ll x, ll y) {
if (x < y || y < 0)
return 0;
return (p[x] * invp[x - y] % mod) * invp[y] % mod;
}
};
perm p(1 << 22);
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = mod_pow(3, n);
vector<ll> p2(n + 1, 1);
for (int i = 0; i < n; i++) {
p2[i + 1] = p2[i] * 2 % mod;
}
for (int i = n / 2 + 1; i <= n; i++) {
ans -= p.comb(n, i) * p2[n - i] * 2;
ans += mod;
ans %= mod;
}
cout << ans << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long int ll;
ll mod = 998244353;
ll mod_pow(ll a, ll b) {
a %= mod;
if (b == 0)
return 1;
if (b == 1)
return a;
ll res = mod_pow(a, b / 2) % mod;
res *= res;
res %= mod;
if (b % 2)
res *= a;
return res % mod;
}
struct perm {
private:
int sz;
vector<ll> p, invp;
public:
perm(int n) {
sz = n + 1;
p.resize(sz), invp.resize(sz);
p[0] = 1;
for (int i = 1; i <= sz - 1; i++) {
p[i] = p[i - 1] * i % mod;
}
invp[sz - 1] = mod_pow(p[sz - 1], mod - 2);
for (int i = sz - 2; i >= 0; i--) {
invp[i] = invp[i + 1] * (i + 1) % mod;
}
}
ll comb(ll x, ll y) {
if (x < y || y < 0)
return 0;
return (p[x] * invp[x - y] % mod) * invp[y] % mod;
}
};
perm p(1 << 24);
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = mod_pow(3, n);
vector<ll> p2(n + 1, 1);
for (int i = 0; i < n; i++) {
p2[i + 1] = p2[i] * 2 % mod;
}
for (int i = n / 2 + 1; i <= n; i++) {
ans -= p.comb(n, i) * p2[n - i] * 2;
ans += mod;
ans %= mod;
}
cout << ans << endl;
} | replace | 46 | 47 | 46 | 47 | 0 | |
p02875 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("vpt")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:256000000")
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
typedef long double ld;
const ld pi = 3.14159265358979323846264;
const char el = '\n';
// const int inf = 1000'000'000;
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define all(v) v.begin(), v.end()
#define x first
#define y second
template <typename T> bool uin(T &a, T b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T> bool uax(T &a, T b) {
if (b > a) {
a = b;
return 1;
}
return 0;
}
template <class iterator>
void output(iterator begin, iterator end, char p = ' ', ostream &out = cout) {
while (begin != end) {
out << (*begin) << p;
begin++;
}
out << el;
}
template <class T> void output(T x, char p = ' ', ostream &out = cout) {
output(all(x), p, out);
}
mt19937 rnd(time(NULL));
#define int long long
const int N = 1000 * 1000 + 228;
const int MOD = 998244353;
int n;
int f[N], rf[N];
int mod(int x) {
x %= MOD;
if (x < 0)
x += MOD;
return x;
}
int fp(int a, int b) {
int res = 1;
while (b) {
if (b & 1) {
res = mod(res * a);
}
a = mod(a * a);
b >>= 1;
}
return res;
}
int C(int n, int k) { return mod(f[n] * mod(rf[k] * rf[n - k])); }
int base[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n;
f[0] = 1;
for (int i = 1; i <= n; ++i) {
f[i] = mod(f[i - 1] * i);
}
rf[n] = fp(f[n], MOD - 2);
for (int i = n - 1; i + 1; --i) {
rf[i] = mod(rf[i + 1] * (i + 1));
}
base[0] = 1;
for (int i = 1; i <= n; ++i) {
base[i] = mod(base[i - 1] * 2);
}
int res = fp(3, n);
for (int A = n / 2 + 1; A <= n; ++A) {
res = mod(res - mod(2 * C(n, A) * base[n - A]));
}
cout << res << '\n';
return 0;
}
/*
<>>><<><<<<<>>><
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1
0 3 2 1 0 1 2 0 1 2 3 4 5 3 2 0 1
*/ | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("vpt")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:256000000")
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
typedef long double ld;
const ld pi = 3.14159265358979323846264;
const char el = '\n';
// const int inf = 1000'000'000;
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define all(v) v.begin(), v.end()
#define x first
#define y second
template <typename T> bool uin(T &a, T b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T> bool uax(T &a, T b) {
if (b > a) {
a = b;
return 1;
}
return 0;
}
template <class iterator>
void output(iterator begin, iterator end, char p = ' ', ostream &out = cout) {
while (begin != end) {
out << (*begin) << p;
begin++;
}
out << el;
}
template <class T> void output(T x, char p = ' ', ostream &out = cout) {
output(all(x), p, out);
}
mt19937 rnd(time(NULL));
#define int long long
const int N = 1000 * 10000 + 228;
const int MOD = 998244353;
int n;
int f[N], rf[N];
int mod(int x) {
x %= MOD;
if (x < 0)
x += MOD;
return x;
}
int fp(int a, int b) {
int res = 1;
while (b) {
if (b & 1) {
res = mod(res * a);
}
a = mod(a * a);
b >>= 1;
}
return res;
}
int C(int n, int k) { return mod(f[n] * mod(rf[k] * rf[n - k])); }
int base[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n;
f[0] = 1;
for (int i = 1; i <= n; ++i) {
f[i] = mod(f[i - 1] * i);
}
rf[n] = fp(f[n], MOD - 2);
for (int i = n - 1; i + 1; --i) {
rf[i] = mod(rf[i + 1] * (i + 1));
}
base[0] = 1;
for (int i = 1; i <= n; ++i) {
base[i] = mod(base[i - 1] * 2);
}
int res = fp(3, n);
for (int A = n / 2 + 1; A <= n; ++A) {
res = mod(res - mod(2 * C(n, A) * base[n - A]));
}
cout << res << '\n';
return 0;
}
/*
<>>><<><<<<<>>><
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1
0 3 2 1 0 1 2 0 1 2 3 4 5 3 2 0 1
*/ | replace | 71 | 72 | 71 | 72 | 0 | |
p02875 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
#define MOD (long)(998244353)
#define MAX 1000001 // 階乗をいくつまで計算するか
class modlong;
void computeAll(long n);
modlong modComb(long n, long k);
modlong modFact(long n);
class modlong {
long val;
const long mod = MOD;
public:
// 初期化 値を引数に与えなかった場合はval=0としておく
modlong(long init = 0) {
while (init < 0)
init += mod; // 0以上であることを保証
val = init % mod;
}
// longへのキャスト operator long()で定義すると modlong +
// longとかができなくなる
long tol() { return this->val; }
// 代入
void operator=(const modlong &r) { this->val = r.val; }
void operator=(const long &r) {
long rr = r;
while (rr < 0)
rr += mod; // 0以上であることを保証
this->val = rr % mod;
}
// 比較
bool operator<(const modlong &r) { return this->val < r.val; }
bool operator>(const modlong &r) { return this->val > r.val; }
bool operator==(const modlong &r) { return this->val == r.val; }
bool operator!=(const modlong &r) { return !(*this == r); }
bool operator<=(const modlong &r) { return !(*this > r); }
bool operator>=(const modlong &r) { return !(*this < r); }
// 足し算; 符号反転; 引き算
modlong operator+(const modlong &r) {
long aval = (this->val + r.val) % mod;
modlong ans(aval);
return ans;
}
modlong operator-() {
long aval = (mod - this->val) % mod;
modlong ans(aval);
return ans;
}
modlong operator-(const modlong &r) {
modlong rr = r;
return *this + (-rr);
}
// かけ算; 逆元; わり算
modlong operator*(const modlong &r) {
long aval = (this->val * r.val) % mod;
modlong ans(aval);
return ans;
}
modlong inv() {
if (*this == 1)
return modlong(1);
if (*this == 0)
cerr << "modlong warning: dividebyzero!!!" << '\n';
modlong p, q = *this, m(0), n(1), r, c;
p.val = mod; // p=modとかくとp.val=mod%mod=0となってしまう
while (q > 1) {
r = p.val % q.val; // r.val=p.val / q.val
// とかくよりもこのほうが代入時に%modされるので安全
c = m.val - n.val * (p.val / q.val);
p = q, q = r, m = n, n = c;
}
return n;
}
modlong operator/(const modlong &r) {
modlong rr = r;
return *this * rr.inv();
}
// ++ -- 前付きと後ろ付き
void operator++() { ++this->val; }
void operator++(int a) {
a = 0;
this->val++;
} // a使ってなくねっていうwarningをsilenceするためにaをいじってる
void operator--() { --this->val; }
void operator--(int a) {
a = 0;
this->val--;
}
// 四則演算&代入
void operator+=(const modlong &r) { *this = *this + r; }
void operator-=(const modlong &r) { *this = *this - r; }
void operator*=(const modlong &r) { *this = *this * r; }
void operator/=(const modlong &r) { *this = *this / r; }
// べき乗
modlong pow(long n) {
if (n < 0)
return inv().pow(-n); // 逆元の-n乗
else if (n == 0)
return modlong(1);
modlong half = pow(n / 2);
if (n % 2)
return *this * half * half;
else
return half * half;
}
// コンビネーション modCombは少し下に書いてある
modlong C(modlong k) { return modComb(this->val, k.val); }
modlong fact() { return modFact(this->val); }
friend ostream &operator<<(ostream &os, const modlong &out);
friend istream &operator>>(istream &is, modlong &out);
};
// cout、cerr、cin用の演算子たち
ostream &operator<<(ostream &os, const modlong &out) {
os << out.val;
return os;
}
istream &operator>>(istream &is, modlong &in) {
long inl;
is >> inl;
in.val = inl % MOD;
return is;
}
////// 階乗を全て求める -> 二項係数を求める
long invs[MAX], facts[MAX], finvs[MAX];
long listlen = 0; // invs, facts, finvsの配列長
void computeAll(long n) {
if (n >= MAX)
cerr << "modlong error: index out of range in computeAll" << '\n';
long i;
if (listlen == 0) {
invs[1] = 1;
facts[0] = 1;
facts[1] = 1;
finvs[0] = 1;
finvs[1] = 1;
i = 2;
} else {
i = listlen;
}
if (n < 2)
return;
for (; i <= n; i++) {
invs[i] = -invs[MOD % i] * (MOD / i) % MOD;
facts[i] = facts[i - 1] * i % MOD;
finvs[i] = finvs[i - 1] * invs[i] % MOD;
}
listlen = n + 1; // 次呼び出すときはn+1以降から再開すれば良い
}
// コンビネーション
modlong modComb(long n, long k) {
if (k < 0 || k > n)
return 0;
if (k == 0 || k == n)
return 1;
if (listlen <= n)
computeAll(n); // 毎回足りない分だけ補う
return modlong(facts[n]) * finvs[k] * finvs[n - k];
}
// 階乗
modlong modFact(long n) {
if (listlen <= n)
computeAll(n); // 毎回足りない分だけ補う
return modlong(facts[n]);
}
int main() {
int n;
cin >> n;
// modlong dp[n/2+1][3];
// fill(dp[0], dp[n/2+1], 0);
// dp[0][0] = 1;
// for (int i=0; i<n/2; i++) {
// dp[i+1][0] = dp[i][0] * 2;
// dp[i+1][1] = dp[i][0] + dp[i][1] * 3;
// dp[i+1][2] = dp[i][1] + dp[i][2] * 3;
// }
// cout << modlong(3).pow(n) - (dp[n/2][1] + dp[n/2][2]) * 2 << '\n';
modlong ans = modlong(3).pow(n);
for (int i = 0; i < n / 2; i++) {
ans -= modComb(n, i) * modlong(2).pow(i + 1);
}
cout << ans << '\n';
return 0;
} | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
#define MOD (long)(998244353)
#define MAX 10000001 // 階乗をいくつまで計算するか
class modlong;
void computeAll(long n);
modlong modComb(long n, long k);
modlong modFact(long n);
class modlong {
long val;
const long mod = MOD;
public:
// 初期化 値を引数に与えなかった場合はval=0としておく
modlong(long init = 0) {
while (init < 0)
init += mod; // 0以上であることを保証
val = init % mod;
}
// longへのキャスト operator long()で定義すると modlong +
// longとかができなくなる
long tol() { return this->val; }
// 代入
void operator=(const modlong &r) { this->val = r.val; }
void operator=(const long &r) {
long rr = r;
while (rr < 0)
rr += mod; // 0以上であることを保証
this->val = rr % mod;
}
// 比較
bool operator<(const modlong &r) { return this->val < r.val; }
bool operator>(const modlong &r) { return this->val > r.val; }
bool operator==(const modlong &r) { return this->val == r.val; }
bool operator!=(const modlong &r) { return !(*this == r); }
bool operator<=(const modlong &r) { return !(*this > r); }
bool operator>=(const modlong &r) { return !(*this < r); }
// 足し算; 符号反転; 引き算
modlong operator+(const modlong &r) {
long aval = (this->val + r.val) % mod;
modlong ans(aval);
return ans;
}
modlong operator-() {
long aval = (mod - this->val) % mod;
modlong ans(aval);
return ans;
}
modlong operator-(const modlong &r) {
modlong rr = r;
return *this + (-rr);
}
// かけ算; 逆元; わり算
modlong operator*(const modlong &r) {
long aval = (this->val * r.val) % mod;
modlong ans(aval);
return ans;
}
modlong inv() {
if (*this == 1)
return modlong(1);
if (*this == 0)
cerr << "modlong warning: dividebyzero!!!" << '\n';
modlong p, q = *this, m(0), n(1), r, c;
p.val = mod; // p=modとかくとp.val=mod%mod=0となってしまう
while (q > 1) {
r = p.val % q.val; // r.val=p.val / q.val
// とかくよりもこのほうが代入時に%modされるので安全
c = m.val - n.val * (p.val / q.val);
p = q, q = r, m = n, n = c;
}
return n;
}
modlong operator/(const modlong &r) {
modlong rr = r;
return *this * rr.inv();
}
// ++ -- 前付きと後ろ付き
void operator++() { ++this->val; }
void operator++(int a) {
a = 0;
this->val++;
} // a使ってなくねっていうwarningをsilenceするためにaをいじってる
void operator--() { --this->val; }
void operator--(int a) {
a = 0;
this->val--;
}
// 四則演算&代入
void operator+=(const modlong &r) { *this = *this + r; }
void operator-=(const modlong &r) { *this = *this - r; }
void operator*=(const modlong &r) { *this = *this * r; }
void operator/=(const modlong &r) { *this = *this / r; }
// べき乗
modlong pow(long n) {
if (n < 0)
return inv().pow(-n); // 逆元の-n乗
else if (n == 0)
return modlong(1);
modlong half = pow(n / 2);
if (n % 2)
return *this * half * half;
else
return half * half;
}
// コンビネーション modCombは少し下に書いてある
modlong C(modlong k) { return modComb(this->val, k.val); }
modlong fact() { return modFact(this->val); }
friend ostream &operator<<(ostream &os, const modlong &out);
friend istream &operator>>(istream &is, modlong &out);
};
// cout、cerr、cin用の演算子たち
ostream &operator<<(ostream &os, const modlong &out) {
os << out.val;
return os;
}
istream &operator>>(istream &is, modlong &in) {
long inl;
is >> inl;
in.val = inl % MOD;
return is;
}
////// 階乗を全て求める -> 二項係数を求める
long invs[MAX], facts[MAX], finvs[MAX];
long listlen = 0; // invs, facts, finvsの配列長
void computeAll(long n) {
if (n >= MAX)
cerr << "modlong error: index out of range in computeAll" << '\n';
long i;
if (listlen == 0) {
invs[1] = 1;
facts[0] = 1;
facts[1] = 1;
finvs[0] = 1;
finvs[1] = 1;
i = 2;
} else {
i = listlen;
}
if (n < 2)
return;
for (; i <= n; i++) {
invs[i] = -invs[MOD % i] * (MOD / i) % MOD;
facts[i] = facts[i - 1] * i % MOD;
finvs[i] = finvs[i - 1] * invs[i] % MOD;
}
listlen = n + 1; // 次呼び出すときはn+1以降から再開すれば良い
}
// コンビネーション
modlong modComb(long n, long k) {
if (k < 0 || k > n)
return 0;
if (k == 0 || k == n)
return 1;
if (listlen <= n)
computeAll(n); // 毎回足りない分だけ補う
return modlong(facts[n]) * finvs[k] * finvs[n - k];
}
// 階乗
modlong modFact(long n) {
if (listlen <= n)
computeAll(n); // 毎回足りない分だけ補う
return modlong(facts[n]);
}
int main() {
int n;
cin >> n;
// modlong dp[n/2+1][3];
// fill(dp[0], dp[n/2+1], 0);
// dp[0][0] = 1;
// for (int i=0; i<n/2; i++) {
// dp[i+1][0] = dp[i][0] * 2;
// dp[i+1][1] = dp[i][0] + dp[i][1] * 3;
// dp[i+1][2] = dp[i][1] + dp[i][2] * 3;
// }
// cout << modlong(3).pow(n) - (dp[n/2][1] + dp[n/2][2]) * 2 << '\n';
modlong ans = modlong(3).pow(n);
for (int i = 0; i < n / 2; i++) {
ans -= modComb(n, i) * modlong(2).pow(i + 1);
}
cout << ans << '\n';
return 0;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p02875 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll modinv(ll a, ll m) {
assert(m > 0);
if (m == 1)
return 0;
a %= m;
if (a < 0)
a += m;
assert(a != 0);
if (a == 1)
return 1;
return m - modinv(m, a) * m / a;
}
template <int MOD_> struct modnum {
private:
int v;
public:
static const int MOD = MOD_;
modnum() : v(0) {}
modnum(ll v_) : v(int(v_ % MOD)) {
if (v < 0)
v += MOD;
}
explicit operator int() const { return v; }
friend bool operator==(const modnum &a, const modnum &b) {
return a.v == b.v;
}
friend bool operator!=(const modnum &a, const modnum &b) {
return a.v != b.v;
}
modnum operator~() const {
modnum res;
res.v = modinv(v, MOD);
return res;
}
modnum &operator+=(const modnum &o) {
v += o.v;
if (v >= MOD)
v -= MOD;
return *this;
}
modnum &operator-=(const modnum &o) {
v -= o.v;
if (v < 0)
v += MOD;
return *this;
}
modnum &operator*=(const modnum &o) {
v = int(ll(v) * ll(o.v) % MOD);
return *this;
}
modnum &operator/=(const modnum &o) { return *this *= (~o); }
friend modnum operator+(const modnum &a, const modnum &b) {
return modnum(a) += b;
}
friend modnum operator-(const modnum &a, const modnum &b) {
return modnum(a) -= b;
}
friend modnum operator*(const modnum &a, const modnum &b) {
return modnum(a) *= b;
}
friend modnum operator/(const modnum &a, const modnum &b) {
return modnum(a) /= b;
}
};
using num = modnum<998244353>;
vector<num> fact;
vector<num> ifact;
void init() {
fact = {1};
for (int i = 1; i < 11000000; i++)
fact.push_back(i * fact[i - 1]);
for (num x : fact)
ifact.push_back(1 / x);
}
num ncr(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
init();
num ans = 1;
int n;
cin >> n;
for (int i = 0; i < n; i++)
ans *= 3;
vector<num> p2(n + 1, 0);
p2[0] = 1;
for (int i = 1; i <= n; i++) {
p2[i] = 2 * p2[i - 1];
}
for (int i = 0; i < n / 2; i++) {
ans -= 2 * p2[i] * ncr(n, i);
}
cout << (int)ans << '\n';
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll modinv(ll a, ll m) {
assert(m > 0);
if (m == 1)
return 0;
a %= m;
if (a < 0)
a += m;
assert(a != 0);
if (a == 1)
return 1;
return m - modinv(m, a) * m / a;
}
template <int MOD_> struct modnum {
private:
int v;
public:
static const int MOD = MOD_;
modnum() : v(0) {}
modnum(ll v_) : v(int(v_ % MOD)) {
if (v < 0)
v += MOD;
}
explicit operator int() const { return v; }
friend bool operator==(const modnum &a, const modnum &b) {
return a.v == b.v;
}
friend bool operator!=(const modnum &a, const modnum &b) {
return a.v != b.v;
}
modnum operator~() const {
modnum res;
res.v = modinv(v, MOD);
return res;
}
modnum &operator+=(const modnum &o) {
v += o.v;
if (v >= MOD)
v -= MOD;
return *this;
}
modnum &operator-=(const modnum &o) {
v -= o.v;
if (v < 0)
v += MOD;
return *this;
}
modnum &operator*=(const modnum &o) {
v = int(ll(v) * ll(o.v) % MOD);
return *this;
}
modnum &operator/=(const modnum &o) { return *this *= (~o); }
friend modnum operator+(const modnum &a, const modnum &b) {
return modnum(a) += b;
}
friend modnum operator-(const modnum &a, const modnum &b) {
return modnum(a) -= b;
}
friend modnum operator*(const modnum &a, const modnum &b) {
return modnum(a) *= b;
}
friend modnum operator/(const modnum &a, const modnum &b) {
return modnum(a) /= b;
}
};
using num = modnum<998244353>;
vector<num> fact;
vector<num> ifact;
void init() {
fact = {1};
for (int i = 1; i < 11000000; i++)
fact.push_back(i * fact[i - 1]);
ifact.resize(fact.size());
ifact.back() = 1 / fact.back();
for (int i = (int)fact.size() - 1; i >= 1; i--) {
ifact[i - 1] = i * ifact[i];
}
}
num ncr(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
init();
num ans = 1;
int n;
cin >> n;
for (int i = 0; i < n; i++)
ans *= 3;
vector<num> p2(n + 1, 0);
p2[0] = 1;
for (int i = 1; i <= n; i++) {
p2[i] = 2 * p2[i - 1];
}
for (int i = 0; i < n / 2; i++) {
ans -= 2 * p2[i] * ncr(n, i);
}
cout << (int)ans << '\n';
} | replace | 84 | 86 | 84 | 89 | TLE | |
p02875 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
const int mod = 998244353;
int n;
long long ans, ji[10000007];
long long qpow(long long a, long long b) {
long long res = 1;
long long now = a % mod;
while (b) {
if (b & 1)
res = res * now % mod;
now = now * now % mod;
b >>= 1;
}
return res;
}
void init() {
ji[0] = 1;
for (int i = 1; i <= n; i++)
ji[i] = ji[i - 1] * i % mod;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
init();
ans = qpow(3, n);
for (int i = (n / 2) + 1; i <= n; i++) {
ans =
(ans -
(((((ji[n] * qpow(ji[i], mod - 2)) % mod) * qpow(ji[n - i], mod - 2)) %
mod) *
qpow(2, n - i) % mod)) %
mod;
ans =
(ans -
(((((ji[n] * qpow(ji[i], mod - 2)) % mod) * qpow(ji[n - i], mod - 2)) %
mod) *
qpow(2, n - i) % mod)) %
mod;
}
cout << (ans + mod) % mod << endl;
return 0;
} | #include <iostream>
using namespace std;
const int mod = 998244353;
int n;
long long ans, ji[10000007];
long long qpow(long long a, long long b) {
long long res = 1;
long long now = a % mod;
while (b) {
if (b & 1)
res = res * now % mod;
now = now * now % mod;
b >>= 1;
}
return res;
}
void init() {
ji[0] = 1;
for (int i = 1; i <= n; i++)
ji[i] = ji[i - 1] * i % mod;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
init();
ans = qpow(3, n);
for (int i = (n / 2) + 1; i <= n; i++) {
ans = (ans - 2 * (((((ji[n] * qpow(ji[i], mod - 2)) % mod) *
qpow(ji[n - i], mod - 2)) %
mod) *
qpow(2, n - i) % mod)) %
mod;
}
cout << (ans + mod) % mod << endl;
return 0;
} | replace | 27 | 39 | 27 | 32 | TLE | |
p02876 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define a first
#define b second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i, u) for (register int i = head[u]; i; i = nxt[i])
#define rep(i, a, b) for (register int i = (a); i <= (b); i++)
#define per(i, a, b) for (register int i = (a); i >= (b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
template <class T> inline void read(T &x) {
x = 0;
char c = getchar();
int f = 1;
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c)) {
x = x * 10 + c - '0';
c = getchar();
}
x *= f;
}
template <class T> inline void umin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void umax(T &x, T y) { x = x > y ? x : y; }
inline ui R() {
static ui seed = 416;
return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 266666;
int n, v[N];
Pii s[N];
struct Frac {
ll a, b; // a/b
Frac(ll A = 0, ll B = 1) {
a = A;
b = B;
}
} ans;
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
inline Frac Norm(Frac y) {
ll g = gcd(y.a, y.b);
y.a /= g;
y.b /= g;
return y;
}
inline void upd(Frac &x, Frac y) {
y = Norm(y);
if (1.0 * x.a / x.b > 1.0 * y.a / y.b)
x = y;
}
bool cmp(Pii x, Pii y) {
return x.a + max(x.b - x.a, 0) < y.a + max(y.b - y.a, 0);
}
bool ck(int k) {
ll tot = 0;
rep(i, 1, n) tot += max(s[i].b - s[i].a, 0);
rep(i, 1, k) tot -= v[i];
return tot >= 0;
}
int main() {
read(n);
rep(i, 1, n) read(s[i].a), read(s[i].b);
sort(s + 1, s + n + 1, cmp);
rep(i, 1, n) v[i] = s[i].a + max(s[i].b - s[i].a, 0);
int L = 0, R = n;
while (L < R) {
int mid = (L + R) >> 1;
if (ck(mid))
L = mid;
else
R = mid - 1;
}
int k = L;
assert(k < n);
ll ori = 0;
rep(i, 1, n) ori += max(s[i].b - s[i].a, 0);
rep(i, 1, k) ori -= v[i];
ans.a = 1;
ans.b = 1;
rep(i, 1, n) {
ll tot = ori;
if (i <= k)
tot = tot + s[i].a - v[k + 1];
else
tot -= max(s[i].b - s[i].a, 0);
upd(ans, (Frac){s[i].a - tot, s[i].b});
// printf("%d %lld %lld\n",i,s[i].a-tot,s[i].b);
}
ll x = ans.a, y = ans.b;
// printf("%d %lld %lld\n",k,x,y);
ans = (Frac){y - x + y * k, n * y};
ans = Norm(ans);
printf("%lld %lld\n", ans.a, ans.b);
return 0;
}
| #include <bits/stdc++.h>
#define a first
#define b second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i, u) for (register int i = head[u]; i; i = nxt[i])
#define rep(i, a, b) for (register int i = (a); i <= (b); i++)
#define per(i, a, b) for (register int i = (a); i >= (b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
template <class T> inline void read(T &x) {
x = 0;
char c = getchar();
int f = 1;
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c)) {
x = x * 10 + c - '0';
c = getchar();
}
x *= f;
}
template <class T> inline void umin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void umax(T &x, T y) { x = x > y ? x : y; }
inline ui R() {
static ui seed = 416;
return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 266666;
int n, v[N];
Pii s[N];
struct Frac {
ll a, b; // a/b
Frac(ll A = 0, ll B = 1) {
a = A;
b = B;
}
} ans;
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
inline Frac Norm(Frac y) {
ll g = gcd(y.a, y.b);
y.a /= g;
y.b /= g;
return y;
}
inline void upd(Frac &x, Frac y) {
y = Norm(y);
if (1.0 * x.a / x.b > 1.0 * y.a / y.b)
x = y;
}
bool cmp(Pii x, Pii y) {
return x.a + max(x.b - x.a, 0) < y.a + max(y.b - y.a, 0);
}
bool ck(int k) {
ll tot = 0;
rep(i, 1, n) tot += max(s[i].b - s[i].a, 0);
rep(i, 1, k) tot -= v[i];
return tot >= 0;
}
int main() {
read(n);
rep(i, 1, n) read(s[i].a), read(s[i].b);
sort(s + 1, s + n + 1, cmp);
rep(i, 1, n) v[i] = s[i].a + max(s[i].b - s[i].a, 0);
int L = 0, R = n;
while (L < R) {
int mid = (L + R + 1) >> 1;
if (ck(mid))
L = mid;
else
R = mid - 1;
}
int k = L;
assert(k < n);
ll ori = 0;
rep(i, 1, n) ori += max(s[i].b - s[i].a, 0);
rep(i, 1, k) ori -= v[i];
ans.a = 1;
ans.b = 1;
rep(i, 1, n) {
ll tot = ori;
if (i <= k)
tot = tot + s[i].a - v[k + 1];
else
tot -= max(s[i].b - s[i].a, 0);
upd(ans, (Frac){s[i].a - tot, s[i].b});
// printf("%d %lld %lld\n",i,s[i].a-tot,s[i].b);
}
ll x = ans.a, y = ans.b;
// printf("%d %lld %lld\n",k,x,y);
ans = (Frac){y - x + y * k, n * y};
ans = Norm(ans);
printf("%lld %lld\n", ans.a, ans.b);
return 0;
}
| replace | 72 | 73 | 72 | 73 | TLE | |
p02876 | C++ | Runtime Error | #include <bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i, a, b) for (int(i) = (a); i < (b); ++(i))
#define EFOR(i, a, b) for (int(i) = (a); i <= (b); ++(i))
#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define REP rep
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD = 1e9 + 7;
#define rall(X) (X).rbegin(), (X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())
#define reps(X, S, Y) for (int(X) = S; (X) < (Y); ++(X))
#define rreps(X, S, Y) for (int(X) = (Y)-1; (X) >= (S); --(X))
template <class T> inline bool MX(T &l, const T &r) {
return l < r ? l = r, 1 : 0;
}
template <class T> inline bool MN(T &l, const T &r) {
return l > r ? l = r, 1 : 0;
}
int N;
LL A[114514];
LL B[114514];
bool check(int l) {
LL cur = 0;
multiset<pll> as, bs;
rep(i, N) {
LL d = B[i] - A[i];
if (d >= 0) {
bs.insert(pll(B[i], A[i]));
} else {
as.insert(pll(A[i], B[i]));
}
}
while (as.size() > l) {
as.erase(as.find(*as.rbegin()));
}
while (as.size() < l && bs.size()) {
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
}
if (as.size() < l)
return false;
for (auto &p : as)
cur -= p.XX;
for (auto &p : bs)
cur += p.XX - p.YY;
while (!as.empty() && !bs.empty()) {
if (bs.begin()->XX < as.rbegin()->XX) {
cur += as.rbegin()->XX - bs.begin()->XX;
as.erase(as.find(*as.rbegin()));
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
} else
break;
}
return cur >= 0;
}
pll GetAns(int l) {
assert(l < N);
LL cur = 0;
multiset<pll> as, bs;
rep(i, N) {
LL d = B[i] - A[i];
if (d >= 0) {
bs.insert(pll(B[i], A[i]));
} else {
as.insert(pll(A[i], B[i]));
}
}
multiset<pll> cs;
while (as.size() > l) {
cs.insert(pll(as.rbegin()->XX, as.rbegin()->YY));
as.erase(as.find(*as.rbegin()));
}
while (as.size() < l && bs.size()) {
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
}
assert(as.size() >= l);
for (auto &p : as)
cur -= p.XX;
for (auto &p : bs)
cur += p.XX - p.YY;
while (!as.empty() && !bs.empty()) {
if (bs.begin()->XX < as.rbegin()->XX) {
cs.insert(pll(as.rbegin()->XX, as.rbegin()->YY));
cur += as.rbegin()->XX - bs.begin()->XX;
as.erase(as.find(*as.rbegin()));
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
} else
break;
}
if (cur == 0) {
LL p = l;
LL q = N;
if (p == 0)
return pll(0, 1);
LL g = __gcd(p, q);
return pll(p / g, q / g);
}
assert(!bs.empty());
pll ret(cur, bs.begin()->XX);
for (auto &p : cs) {
pll tmp(cur + p.YY - p.XX, p.YY);
assert(tmp.XX < tmp.YY);
if (tmp.XX * ret.YY > ret.XX * tmp.YY)
ret = tmp;
}
for (auto &p : as) {
assert(!cs.empty());
LL v = cur + p.YY - min(bs.begin()->XX, cs.begin()->XX);
pll tmp(v, p.YY);
if (tmp.XX * ret.YY > ret.XX * tmp.YY)
ret = tmp;
}
ret.XX += l * ret.YY;
ret.YY *= N;
LL g = __gcd(ret.XX, ret.YY);
return pll(ret.XX / g, ret.YY / g);
}
signed main() {
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(0);
cin >> N;
rep(i, N) { cin >> A[i] >> B[i]; }
int low = 0;
int high = N + 1;
while (high - low > 1) {
int mid = (high + low) / 2;
if (check(mid))
low = mid;
else
high = mid;
}
// cout << low << endl;
auto ans = GetAns(low);
cout << ans.XX << " " << ans.YY << endl;
}
| #include <bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i, a, b) for (int(i) = (a); i < (b); ++(i))
#define EFOR(i, a, b) for (int(i) = (a); i <= (b); ++(i))
#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define REP rep
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD = 1e9 + 7;
#define rall(X) (X).rbegin(), (X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())
#define reps(X, S, Y) for (int(X) = S; (X) < (Y); ++(X))
#define rreps(X, S, Y) for (int(X) = (Y)-1; (X) >= (S); --(X))
template <class T> inline bool MX(T &l, const T &r) {
return l < r ? l = r, 1 : 0;
}
template <class T> inline bool MN(T &l, const T &r) {
return l > r ? l = r, 1 : 0;
}
int N;
LL A[114514];
LL B[114514];
bool check(int l) {
LL cur = 0;
multiset<pll> as, bs;
rep(i, N) {
LL d = B[i] - A[i];
if (d >= 0) {
bs.insert(pll(B[i], A[i]));
} else {
as.insert(pll(A[i], B[i]));
}
}
while (as.size() > l) {
as.erase(as.find(*as.rbegin()));
}
while (as.size() < l && bs.size()) {
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
}
if (as.size() < l)
return false;
for (auto &p : as)
cur -= p.XX;
for (auto &p : bs)
cur += p.XX - p.YY;
while (!as.empty() && !bs.empty()) {
if (bs.begin()->XX < as.rbegin()->XX) {
cur += as.rbegin()->XX - bs.begin()->XX;
as.erase(as.find(*as.rbegin()));
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
} else
break;
}
return cur >= 0;
}
pll GetAns(int l) {
assert(l < N);
LL cur = 0;
multiset<pll> as, bs;
rep(i, N) {
LL d = B[i] - A[i];
if (d >= 0) {
bs.insert(pll(B[i], A[i]));
} else {
as.insert(pll(A[i], B[i]));
}
}
multiset<pll> cs;
while (as.size() > l) {
cs.insert(pll(as.rbegin()->XX, as.rbegin()->YY));
as.erase(as.find(*as.rbegin()));
}
while (as.size() < l && bs.size()) {
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
}
assert(as.size() >= l);
for (auto &p : as)
cur -= p.XX;
for (auto &p : bs)
cur += p.XX - p.YY;
while (!as.empty() && !bs.empty()) {
if (bs.begin()->XX < as.rbegin()->XX) {
cs.insert(pll(as.rbegin()->XX, as.rbegin()->YY));
cur += as.rbegin()->XX - bs.begin()->XX;
as.erase(as.find(*as.rbegin()));
as.insert(pll(bs.begin()->YY, bs.begin()->XX));
bs.erase(bs.begin());
} else
break;
}
if (cur == 0) {
LL p = l;
LL q = N;
if (p == 0)
return pll(0, 1);
LL g = __gcd(p, q);
return pll(p / g, q / g);
}
assert(!bs.empty());
pll ret(cur, bs.begin()->XX);
for (auto &p : cs) {
pll tmp(cur + p.YY - p.XX, p.YY);
assert(tmp.XX < tmp.YY);
if (tmp.XX * ret.YY > ret.XX * tmp.YY)
ret = tmp;
}
for (auto &p : as) {
LL t = bs.begin()->XX;
if (cs.size())
MN(t, cs.begin()->XX);
LL v = cur + p.YY - t;
pll tmp(v, p.YY);
if (tmp.XX * ret.YY > ret.XX * tmp.YY)
ret = tmp;
}
ret.XX += l * ret.YY;
ret.YY *= N;
LL g = __gcd(ret.XX, ret.YY);
return pll(ret.XX / g, ret.YY / g);
}
signed main() {
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(0);
cin >> N;
rep(i, N) { cin >> A[i] >> B[i]; }
int low = 0;
int high = N + 1;
while (high - low > 1) {
int mid = (high + low) / 2;
if (check(mid))
low = mid;
else
high = mid;
}
// cout << low << endl;
auto ans = GetAns(low);
cout << ans.XX << " " << ans.YY << endl;
}
| replace | 132 | 134 | 132 | 136 | 0 | |
p02877 | C++ | Time Limit Exceeded | // Zory-2019
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pr pair<int, int>
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll << (x))
#define fo(i, l, r) for (int i = (l), I = (r); i <= I; i++)
#define fd(i, r, l) for (int i = (r), I = (l); i >= I; i--)
#ifdef DEBUG
#define GG(x) assert(x)
#else
#define GG(x) (x)
#endif
namespace mine {
ll qread() {
ll ans = 0, f = 1;
char c = getchar();
while (c < '0' or c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while ('0' <= c and c <= '9')
ans = ans * 10 + c - '0', c = getchar();
return ans * f;
}
void write(ll num) {
if (num < 0)
putchar('-'), num = -num;
if (num >= 10)
write(num / 10);
putchar('0' + num % 10);
}
void write1(ll num) {
write(num);
putchar(' ');
}
void write2(ll num) {
write(num);
putchar('\n');
}
template <typename T> void chmax(T &x, const T y) { x = (x > y ? x : y); }
template <typename T> void chmin(T &x, const T y) { x = (x < y ? x : y); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int mm(const int x) { return x >= MOD ? x - MOD : x; }
template <typename T> void add(T &x, const int &y) {
x = (x + y >= MOD ? x + y - MOD : x + y);
}
ll qpower(ll x, ll e, int mod = MOD) {
ll ans = 1;
GG(e >= 0);
while (e) {
if (e & 1)
ans = ans * x % mod;
x = x * x % mod;
e >>= 1;
}
return ans;
}
ll invm(ll x) { return qpower(x, MOD - 2); }
const int N = 2e5 + 10;
int A[N];
map<int, int> f[N];
void upd(int x, int pos, int val) { // 差分
if (pos < 0 or pos > A[x])
return;
if (f[x].count(pos))
chmin(f[x][pos], val);
else
f[x][pos] = val;
}
void main() {
int n = qread();
fo(i, 1, n) A[i] = qread();
f[0][0] = 0;
fo(i, 0, n) {
int lst = f[i].begin()->SE;
for (map<int, int>::iterator IT = ++f[i].begin(); IT != f[i].end();) {
chmin(IT->SE, lst);
if (lst == IT->SE)
f[i].erase(IT++);
else
IT++;
}
for (auto now : f[i]) {
int xi = now.FR, val = now.SE;
if (!xi)
upd(i + 1, 0, val + (A[i + 1] - A[i] > 0)),
upd(i + 1, A[i + 1] - A[i], val);
else if (A[i + 1] == A[i])
upd(i + 1, 0, val + 2), upd(i + 1, xi, val);
else if (A[i + 1] - A[i] + xi > 0)
upd(i + 1, 0, val + 2),
upd(i + 1, min(xi, A[i + 1] - A[i] + xi), val + 1),
upd(i + 1, max(xi, A[i + 1] - A[i] + xi), val);
else
upd(i + 1, 0, val + 1), upd(i + 1, xi, val);
}
}
write(f[n + 1][0]);
}
}; // namespace mine
signed main() {
srand(time(0));
mine::main();
}
| // Zory-2019
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pr pair<int, int>
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll << (x))
#define fo(i, l, r) for (int i = (l), I = (r); i <= I; i++)
#define fd(i, r, l) for (int i = (r), I = (l); i >= I; i--)
#ifdef DEBUG
#define GG(x) assert(x)
#else
#define GG(x) (x)
#endif
namespace mine {
ll qread() {
ll ans = 0, f = 1;
char c = getchar();
while (c < '0' or c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while ('0' <= c and c <= '9')
ans = ans * 10 + c - '0', c = getchar();
return ans * f;
}
void write(ll num) {
if (num < 0)
putchar('-'), num = -num;
if (num >= 10)
write(num / 10);
putchar('0' + num % 10);
}
void write1(ll num) {
write(num);
putchar(' ');
}
void write2(ll num) {
write(num);
putchar('\n');
}
template <typename T> void chmax(T &x, const T y) { x = (x > y ? x : y); }
template <typename T> void chmin(T &x, const T y) { x = (x < y ? x : y); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int mm(const int x) { return x >= MOD ? x - MOD : x; }
template <typename T> void add(T &x, const int &y) {
x = (x + y >= MOD ? x + y - MOD : x + y);
}
ll qpower(ll x, ll e, int mod = MOD) {
ll ans = 1;
GG(e >= 0);
while (e) {
if (e & 1)
ans = ans * x % mod;
x = x * x % mod;
e >>= 1;
}
return ans;
}
ll invm(ll x) { return qpower(x, MOD - 2); }
const int N = 2e5 + 10;
int A[N];
map<int, int> f[N];
void upd(int x, int pos, int val) { // 差分
if (pos < 0 or pos > A[x])
return;
if (f[x].count(pos))
chmin(f[x][pos], val);
else
f[x][pos] = val;
}
void main() {
int n = qread();
fo(i, 1, n) A[i] = qread();
f[0][0] = 0;
fo(i, 0, n) {
int lst = f[i].begin()->SE;
for (map<int, int>::iterator IT = ++f[i].begin(); IT != f[i].end();) {
chmin(IT->SE, lst);
if (lst == IT->SE)
f[i].erase(IT++);
else
lst = IT->SE, IT++;
}
for (auto now : f[i]) {
int xi = now.FR, val = now.SE;
if (!xi)
upd(i + 1, 0, val + (A[i + 1] - A[i] > 0)),
upd(i + 1, A[i + 1] - A[i], val);
else if (A[i + 1] == A[i])
upd(i + 1, 0, val + 2), upd(i + 1, xi, val);
else if (A[i + 1] - A[i] + xi > 0)
upd(i + 1, 0, val + 2),
upd(i + 1, min(xi, A[i + 1] - A[i] + xi), val + 1),
upd(i + 1, max(xi, A[i + 1] - A[i] + xi), val);
else
upd(i + 1, 0, val + 1), upd(i + 1, xi, val);
}
}
write(f[n + 1][0]);
}
}; // namespace mine
signed main() {
srand(time(0));
mine::main();
}
| replace | 93 | 94 | 93 | 94 | TLE | |
p02877 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
template <class T> inline void read(T &x) {
static char ch;
while (!isdigit(ch = getchar()))
;
x = ch - '0';
while (isdigit(ch = getchar()))
x = x * 10 + ch - '0';
}
template <class T> inline void tense(T &x, const T &y) {
if (x > y)
x = y;
}
template <class T> inline void relax(T &x, const T &y) {
if (x < y)
x = y;
}
typedef std::pair<int, int> pii;
const int MaxN = 2e5 + 5;
struct node {
int l, r, val;
node() {}
node(int a, int b, int c) : l(a), r(b), val(c) {}
inline bool operator<(const node &rhs) const {
if (val != rhs.val)
return val > rhs.val;
if (r != rhs.r)
return r < rhs.r;
return l > rhs.l;
}
inline void operator-=(const node &rhs) {
if (rhs.l <= l && r <= rhs.r)
return (void)(r = l - 1);
if (rhs.l >= l)
tense(r, rhs.l - 1);
if (rhs.r <= r)
relax(l, rhs.r + 1);
}
};
int n, a[MaxN];
std::vector<node> f[MaxN];
int main() {
freopen("operate.in", "r", stdin);
freopen("operate.out", "w", stdout);
read(n);
for (int i = 1; i <= n; ++i)
read(a[i]);
f[0].push_back(node(0, 0, 0));
for (int i = 1; i <= n + 1; ++i) {
std::vector<node> cur;
for (node lst : f[i - 1]) {
int l = lst.l, v = lst.val;
int tmin = std::min(l - 1, a[i] - a[i - 1] + l - 1);
int tmax = std::max(l - 1, a[i] - a[i - 1] + l - 1);
tense(tmax, a[i]);
if (tmin >= 0)
cur.push_back(node(0, tmin, v + 2));
if (tmin < tmax && tmax >= 0)
cur.push_back(node(std::max(0, tmin + 1), tmax, v + 1));
if (tmax < a[i])
cur.push_back(node(tmax + 1, a[i], v));
}
std::sort(cur.begin(), cur.end());
for (int j = 0; j < (int)cur.size(); ++j) {
for (int k = 0; k < j; ++k)
cur[k] -= cur[j];
}
for (int j = 0; j < (int)cur.size(); ++j)
if (cur[j].l <= cur[j].r) {
if (!f[i].empty() && f[i].rbegin()->val == cur[j].val)
f[i].rbegin()->r = cur[j].r;
else
f[i].push_back(cur[j]);
}
}
std::cout << f[n + 1][0].val << '\n';
return 0;
} | #include <bits/stdc++.h>
template <class T> inline void read(T &x) {
static char ch;
while (!isdigit(ch = getchar()))
;
x = ch - '0';
while (isdigit(ch = getchar()))
x = x * 10 + ch - '0';
}
template <class T> inline void tense(T &x, const T &y) {
if (x > y)
x = y;
}
template <class T> inline void relax(T &x, const T &y) {
if (x < y)
x = y;
}
typedef std::pair<int, int> pii;
const int MaxN = 2e5 + 5;
struct node {
int l, r, val;
node() {}
node(int a, int b, int c) : l(a), r(b), val(c) {}
inline bool operator<(const node &rhs) const {
if (val != rhs.val)
return val > rhs.val;
if (r != rhs.r)
return r < rhs.r;
return l > rhs.l;
}
inline void operator-=(const node &rhs) {
if (rhs.l <= l && r <= rhs.r)
return (void)(r = l - 1);
if (rhs.l >= l)
tense(r, rhs.l - 1);
if (rhs.r <= r)
relax(l, rhs.r + 1);
}
};
int n, a[MaxN];
std::vector<node> f[MaxN];
int main() {
read(n);
for (int i = 1; i <= n; ++i)
read(a[i]);
f[0].push_back(node(0, 0, 0));
for (int i = 1; i <= n + 1; ++i) {
std::vector<node> cur;
for (node lst : f[i - 1]) {
int l = lst.l, v = lst.val;
int tmin = std::min(l - 1, a[i] - a[i - 1] + l - 1);
int tmax = std::max(l - 1, a[i] - a[i - 1] + l - 1);
tense(tmax, a[i]);
if (tmin >= 0)
cur.push_back(node(0, tmin, v + 2));
if (tmin < tmax && tmax >= 0)
cur.push_back(node(std::max(0, tmin + 1), tmax, v + 1));
if (tmax < a[i])
cur.push_back(node(tmax + 1, a[i], v));
}
std::sort(cur.begin(), cur.end());
for (int j = 0; j < (int)cur.size(); ++j) {
for (int k = 0; k < j; ++k)
cur[k] -= cur[j];
}
for (int j = 0; j < (int)cur.size(); ++j)
if (cur[j].l <= cur[j].r) {
if (!f[i].empty() && f[i].rbegin()->val == cur[j].val)
f[i].rbegin()->r = cur[j].r;
else
f[i].push_back(cur[j]);
}
}
std::cout << f[n + 1][0].val << '\n';
return 0;
} | delete | 53 | 56 | 53 | 53 | TLE | |
p02877 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100005;
inline int gi() {
char c = getchar();
while (c < '0' || c > '9')
c = getchar();
int sum = 0;
while ('0' <= c && c <= '9')
sum = sum * 10 + c - 48, c = getchar();
return sum;
}
int n, a[maxn], ans, f[3], g[3], h[3];
int main() {
n = gi();
for (int i = 1; i <= n; ++i)
a[i] = gi();
for (int i = 1; i <= n + 1; ++i) {
f[0] = 0;
f[1] = a[i] - a[i - 1];
if (f[0] < f[1])
swap(f[0], f[1]);
g[0] = g[1] = 1e9;
g[2] = 0;
for (int j = 0; j < 2; ++j)
for (int k = 0; k < 2; ++k)
g[j + k] = min(g[j + k], max(0, f[j] + h[k]));
int d = g[0] > a[i];
ans += d;
for (int j = 0; j < 2; ++j)
h[j] = g[j + d];
}
printf("%d\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200005;
inline int gi() {
char c = getchar();
while (c < '0' || c > '9')
c = getchar();
int sum = 0;
while ('0' <= c && c <= '9')
sum = sum * 10 + c - 48, c = getchar();
return sum;
}
int n, a[maxn], ans, f[3], g[3], h[3];
int main() {
n = gi();
for (int i = 1; i <= n; ++i)
a[i] = gi();
for (int i = 1; i <= n + 1; ++i) {
f[0] = 0;
f[1] = a[i] - a[i - 1];
if (f[0] < f[1])
swap(f[0], f[1]);
g[0] = g[1] = 1e9;
g[2] = 0;
for (int j = 0; j < 2; ++j)
for (int k = 0; k < 2; ++k)
g[j + k] = min(g[j + k], max(0, f[j] + h[k]));
int d = g[0] > a[i];
ans += d;
for (int j = 0; j < 2; ++j)
h[j] = g[j + d];
}
printf("%d\n", ans);
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02878 | C++ | Runtime Error | #pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a)
#define trav(a, x) for (auto &a : x)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
const int MOD = 998244353; // = (119<<23)+1
const ll INF = 1e18;
const int MX = 2e5 + 5;
const ld PI = 4 * atan((ld)1);
template <class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
namespace input {
template <class T> void re(complex<T> &x);
template <class T1, class T2> void re(pair<T1, T2> &p);
template <class T> void re(vector<T> &a);
template <class T, size_t SZ> void re(array<T, SZ> &a);
template <class T> void re(T &x) { cin >> x; }
void re(double &x) {
string t;
re(t);
x = stod(t);
}
void re(ld &x) {
string t;
re(t);
x = stold(t);
}
template <class T, class... Ts> void re(T &t, Ts &...ts) {
re(t);
re(ts...);
}
template <class T> void re(complex<T> &x) {
T a, b;
re(a, b);
x = cd(a, b);
}
template <class T1, class T2> void re(pair<T1, T2> &p) { re(p.f, p.s); }
template <class T> void re(vector<T> &a) { F0R(i, sz(a)) re(a[i]); }
template <class T, size_t SZ> void re(array<T, SZ> &a) { F0R(i, SZ) re(a[i]); }
} // namespace input
using namespace input;
namespace output {
void pr(int x) { cout << x; }
void pr(long x) { cout << x; }
void pr(ll x) { cout << x; }
void pr(unsigned x) { cout << x; }
void pr(unsigned long x) { cout << x; }
void pr(unsigned long long x) { cout << x; }
void pr(float x) { cout << x; }
void pr(double x) { cout << x; }
void pr(ld x) { cout << x; }
void pr(char x) { cout << x; }
void pr(const char *x) { cout << x; }
void pr(const string &x) { cout << x; }
void pr(bool x) { pr(x ? "true" : "false"); }
template <class T> void pr(const complex<T> &x) { cout << x; }
template <class T1, class T2> void pr(const pair<T1, T2> &x);
template <class T> void pr(const T &x);
template <class T, class... Ts> void pr(const T &t, const Ts &...ts) {
pr(t);
pr(ts...);
}
template <class T1, class T2> void pr(const pair<T1, T2> &x) {
pr("{", x.f, ", ", x.s, "}");
}
template <class T> void pr(const T &x) {
pr("{"); // const iterator needed for vector<bool>
bool fst = 1;
for (const auto &a : x)
pr(!fst ? ", " : "", a), fst = 0;
pr("}");
}
void ps() { pr("\n"); } // print w/ spaces
template <class T, class... Ts> void ps(const T &t, const Ts &...ts) {
pr(t);
if (sizeof...(ts))
pr(" ");
ps(ts...);
}
void pc() { pr("]\n"); } // debug w/ commas
template <class T, class... Ts> void pc(const T &t, const Ts &...ts) {
pr(t);
if (sizeof...(ts))
pr(", ");
pc(ts...);
}
#define dbg(x...) pr("[", #x, "] = ["), pc(x);
} // namespace output
using namespace output;
namespace io {
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
void setIO(string s = "") {
cin.sync_with_stdio(0);
cin.tie(0); // fast I/O
cin.exceptions(
cin.failbit); // ex. throws exception when you try to read letter into int
if (sz(s)) {
setIn(s + ".in"), setOut(s + ".out");
} // for USACO
}
} // namespace io
using namespace io;
template <class T> T invGeneral(T a, T b) {
a %= b;
if (a == 0)
return b == 1 ? 0 : -1;
T x = invGeneral(b, a);
return x == -1 ? -1 : ((1 - (ll)b * x) / a + b) % b;
}
template <class T> struct modular {
T val;
explicit operator T() const { return val; }
modular() { val = 0; }
modular(const ll &v) {
val = (-MOD <= v && v <= MOD) ? v : v % MOD;
if (val < 0)
val += MOD;
}
// friend ostream& operator<<(ostream& os, const modular& a) { return os <<
// a.val; }
friend void pr(const modular &a) { pr(a.val); }
friend void re(modular &a) {
ll x;
re(x);
a = modular(x);
}
friend bool operator==(const modular &a, const modular &b) {
return a.val == b.val;
}
friend bool operator!=(const modular &a, const modular &b) {
return !(a == b);
}
friend bool operator<(const modular &a, const modular &b) {
return a.val < b.val;
}
modular operator-() const { return modular(-val); }
modular &operator+=(const modular &m) {
if ((val += m.val) >= MOD)
val -= MOD;
return *this;
}
modular &operator-=(const modular &m) {
if ((val -= m.val) < 0)
val += MOD;
return *this;
}
modular &operator*=(const modular &m) {
val = (ll)val * m.val % MOD;
return *this;
}
friend modular pow(modular a, ll p) {
modular ans = 1;
for (; p; p /= 2, a *= a)
if (p & 1)
ans *= a;
return ans;
}
friend modular inv(const modular &a) {
auto i = invGeneral(a.val, MOD);
assert(i != -1);
return i;
} // equivalent to return exp(b,MOD-2) if MOD is prime
modular &operator/=(const modular &m) { return (*this) *= inv(m); }
friend modular operator+(modular a, const modular &b) { return a += b; }
friend modular operator-(modular a, const modular &b) { return a -= b; }
friend modular operator*(modular a, const modular &b) { return a *= b; }
friend modular operator/(modular a, const modular &b) { return a /= b; }
};
typedef modular<int> mi;
typedef pair<mi, mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;
int N, A, B;
vi invs, fac, ifac;
void genFac(int SZ) {
invs.rsz(SZ), fac.rsz(SZ), ifac.rsz(SZ);
invs[1] = 1;
FOR(i, 2, SZ) invs[i] = MOD - (ll)MOD / i * invs[MOD % i] % MOD;
fac[0] = ifac[0] = 1;
FOR(i, 1, SZ) {
fac[i] = (ll)fac[i - 1] * i % MOD;
ifac[i] = (ll)ifac[i - 1] * invs[i] % MOD;
}
}
ll comb(int a, int b) {
if (a < b)
return 0;
return (ll)fac[a] * ifac[b] % MOD * ifac[a - b] % MOD;
}
mi path(int a, int b) {
if (min(a, b) < 0)
return 0;
return comb(a + b, b);
}
mi lower(int k) {
if (k == 0)
return 1;
if (B - 1 < k)
return 0;
return path(B - 1, k) - path(B, k - 1);
}
int main() {
genFac(2000005);
setIO();
re(N, A, B);
mi ans = 0;
F0R(k, min(A, N - B) + 1) {
if (N - B - k == 0) {
if (k == A)
ans += lower(k);
} else {
// N-B-k-1 over A-k+1 categories
ans += comb(N - B - k - 1 + A - k, A - k) * lower(k);
}
}
ps(ans);
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), set tle
* do smth instead of nothing and stay organized
*/
| #pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a)
#define trav(a, x) for (auto &a : x)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
const int MOD = 998244353; // = (119<<23)+1
const ll INF = 1e18;
const int MX = 2e5 + 5;
const ld PI = 4 * atan((ld)1);
template <class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
namespace input {
template <class T> void re(complex<T> &x);
template <class T1, class T2> void re(pair<T1, T2> &p);
template <class T> void re(vector<T> &a);
template <class T, size_t SZ> void re(array<T, SZ> &a);
template <class T> void re(T &x) { cin >> x; }
void re(double &x) {
string t;
re(t);
x = stod(t);
}
void re(ld &x) {
string t;
re(t);
x = stold(t);
}
template <class T, class... Ts> void re(T &t, Ts &...ts) {
re(t);
re(ts...);
}
template <class T> void re(complex<T> &x) {
T a, b;
re(a, b);
x = cd(a, b);
}
template <class T1, class T2> void re(pair<T1, T2> &p) { re(p.f, p.s); }
template <class T> void re(vector<T> &a) { F0R(i, sz(a)) re(a[i]); }
template <class T, size_t SZ> void re(array<T, SZ> &a) { F0R(i, SZ) re(a[i]); }
} // namespace input
using namespace input;
namespace output {
void pr(int x) { cout << x; }
void pr(long x) { cout << x; }
void pr(ll x) { cout << x; }
void pr(unsigned x) { cout << x; }
void pr(unsigned long x) { cout << x; }
void pr(unsigned long long x) { cout << x; }
void pr(float x) { cout << x; }
void pr(double x) { cout << x; }
void pr(ld x) { cout << x; }
void pr(char x) { cout << x; }
void pr(const char *x) { cout << x; }
void pr(const string &x) { cout << x; }
void pr(bool x) { pr(x ? "true" : "false"); }
template <class T> void pr(const complex<T> &x) { cout << x; }
template <class T1, class T2> void pr(const pair<T1, T2> &x);
template <class T> void pr(const T &x);
template <class T, class... Ts> void pr(const T &t, const Ts &...ts) {
pr(t);
pr(ts...);
}
template <class T1, class T2> void pr(const pair<T1, T2> &x) {
pr("{", x.f, ", ", x.s, "}");
}
template <class T> void pr(const T &x) {
pr("{"); // const iterator needed for vector<bool>
bool fst = 1;
for (const auto &a : x)
pr(!fst ? ", " : "", a), fst = 0;
pr("}");
}
void ps() { pr("\n"); } // print w/ spaces
template <class T, class... Ts> void ps(const T &t, const Ts &...ts) {
pr(t);
if (sizeof...(ts))
pr(" ");
ps(ts...);
}
void pc() { pr("]\n"); } // debug w/ commas
template <class T, class... Ts> void pc(const T &t, const Ts &...ts) {
pr(t);
if (sizeof...(ts))
pr(", ");
pc(ts...);
}
#define dbg(x...) pr("[", #x, "] = ["), pc(x);
} // namespace output
using namespace output;
namespace io {
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
void setIO(string s = "") {
cin.sync_with_stdio(0);
cin.tie(0); // fast I/O
cin.exceptions(
cin.failbit); // ex. throws exception when you try to read letter into int
if (sz(s)) {
setIn(s + ".in"), setOut(s + ".out");
} // for USACO
}
} // namespace io
using namespace io;
template <class T> T invGeneral(T a, T b) {
a %= b;
if (a == 0)
return b == 1 ? 0 : -1;
T x = invGeneral(b, a);
return x == -1 ? -1 : ((1 - (ll)b * x) / a + b) % b;
}
template <class T> struct modular {
T val;
explicit operator T() const { return val; }
modular() { val = 0; }
modular(const ll &v) {
val = (-MOD <= v && v <= MOD) ? v : v % MOD;
if (val < 0)
val += MOD;
}
// friend ostream& operator<<(ostream& os, const modular& a) { return os <<
// a.val; }
friend void pr(const modular &a) { pr(a.val); }
friend void re(modular &a) {
ll x;
re(x);
a = modular(x);
}
friend bool operator==(const modular &a, const modular &b) {
return a.val == b.val;
}
friend bool operator!=(const modular &a, const modular &b) {
return !(a == b);
}
friend bool operator<(const modular &a, const modular &b) {
return a.val < b.val;
}
modular operator-() const { return modular(-val); }
modular &operator+=(const modular &m) {
if ((val += m.val) >= MOD)
val -= MOD;
return *this;
}
modular &operator-=(const modular &m) {
if ((val -= m.val) < 0)
val += MOD;
return *this;
}
modular &operator*=(const modular &m) {
val = (ll)val * m.val % MOD;
return *this;
}
friend modular pow(modular a, ll p) {
modular ans = 1;
for (; p; p /= 2, a *= a)
if (p & 1)
ans *= a;
return ans;
}
friend modular inv(const modular &a) {
auto i = invGeneral(a.val, MOD);
assert(i != -1);
return i;
} // equivalent to return exp(b,MOD-2) if MOD is prime
modular &operator/=(const modular &m) { return (*this) *= inv(m); }
friend modular operator+(modular a, const modular &b) { return a += b; }
friend modular operator-(modular a, const modular &b) { return a -= b; }
friend modular operator*(modular a, const modular &b) { return a *= b; }
friend modular operator/(modular a, const modular &b) { return a /= b; }
};
typedef modular<int> mi;
typedef pair<mi, mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;
int N, A, B;
vi invs, fac, ifac;
void genFac(int SZ) {
invs.rsz(SZ), fac.rsz(SZ), ifac.rsz(SZ);
invs[1] = 1;
FOR(i, 2, SZ) invs[i] = MOD - (ll)MOD / i * invs[MOD % i] % MOD;
fac[0] = ifac[0] = 1;
FOR(i, 1, SZ) {
fac[i] = (ll)fac[i - 1] * i % MOD;
ifac[i] = (ll)ifac[i - 1] * invs[i] % MOD;
}
}
ll comb(int a, int b) {
if (a < b)
return 0;
return (ll)fac[a] * ifac[b] % MOD * ifac[a - b] % MOD;
}
mi path(int a, int b) {
if (min(a, b) < 0)
return 0;
return comb(a + b, b);
}
mi lower(int k) {
if (k == 0)
return 1;
if (B - 1 < k)
return 0;
return path(B - 1, k) - path(B, k - 1);
}
int main() {
genFac(20000005);
setIO();
re(N, A, B);
mi ans = 0;
F0R(k, min(A, N - B) + 1) {
if (N - B - k == 0) {
if (k == A)
ans += lower(k);
} else {
// N-B-k-1 over A-k+1 categories
ans += comb(N - B - k - 1 + A - k, A - k) * lower(k);
}
}
ps(ans);
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), set tle
* do smth instead of nothing and stay organized
*/
| replace | 285 | 286 | 285 | 286 | 0 | |
p02878 | C++ | Runtime Error | #include <bits/stdc++.h>
const int N = 1e7 + 5;
const int mod = 998244353;
int fra[N], inv[N];
int n, a, b, ans;
template <class T> inline T Min(T x, T y) { return x < y ? x : y; }
inline void add(int &x, int y) {
x += y;
x >= mod ? x -= mod : 0;
}
inline void dec(int &x, int y) {
x -= y;
x < 0 ? x += mod : 0;
}
inline void add_prod(int &x, int u, int v) { x = (1ll * u * v + x) % mod; }
inline int quick_pow(int x, int k) {
int res = 1;
while (k) {
if (k & 1)
res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
k >>= 1;
}
return res;
}
inline int C(int n, int m) {
if (n < m)
return 0;
return 1ll * fra[n] * inv[n - m] % mod * inv[m] % mod;
}
inline int ask(int k) {
int res = C(k + b - 1, b - 1);
dec(res, C(k + b - 1, k - 1));
return res;
}
int main() {
scanf("%d%d%d", &n, &a, &b);
if (a == 0 && b == 0)
return puts("1"), 0;
fra[0] = 1;
for (int i = 1; i <= n; ++i)
fra[i] = 1ll * fra[i - 1] * i % mod;
inv[n] = quick_pow(fra[n], mod - 2);
for (int i = n; i >= 1; --i)
inv[i - 1] = 1ll * inv[i] * i % mod;
for (int k = 0, km = Min(a, b - 1); k <= km; ++k) {
int tmp = k ? ask(k) : 1;
if (k == a) {
int x = n - b - k, y = a - k + 1;
if (x >= 0)
add_prod(ans, tmp, C(x + y - 1, y - 1));
} else {
int x = n - b - k - 1, y = a - k + 1;
if (x >= 0)
add_prod(ans, tmp, C(x + y - 1, y - 1));
}
}
printf("%d\n", ans);
return 0;
} | #include <bits/stdc++.h>
const int N = 1e7 + 5;
const int mod = 998244353;
int fra[N], inv[N];
int n, a, b, ans;
template <class T> inline T Min(T x, T y) { return x < y ? x : y; }
inline void add(int &x, int y) {
x += y;
x >= mod ? x -= mod : 0;
}
inline void dec(int &x, int y) {
x -= y;
x < 0 ? x += mod : 0;
}
inline void add_prod(int &x, int u, int v) { x = (1ll * u * v + x) % mod; }
inline int quick_pow(int x, int k) {
int res = 1;
while (k) {
if (k & 1)
res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
k >>= 1;
}
return res;
}
inline int C(int n, int m) {
if (n < m)
return 0;
return 1ll * fra[n] * inv[n - m] % mod * inv[m] % mod;
}
inline int ask(int k) {
int res = C(k + b - 1, b - 1);
dec(res, C(k + b - 1, k - 1));
return res;
}
int main() {
scanf("%d%d%d", &n, &a, &b);
if (a == 0 && b == 0)
return puts("1"), 0;
fra[0] = 1;
for (int i = 1; i <= n; ++i)
fra[i] = 1ll * fra[i - 1] * i % mod;
inv[n] = quick_pow(fra[n], mod - 2);
for (int i = n; i >= 1; --i)
inv[i - 1] = 1ll * inv[i] * i % mod;
for (int k = 0, km = Min(n - b, Min(a, b - 1)); k <= km; ++k) {
int tmp = k ? ask(k) : 1;
if (k == a) {
int x = n - b - k, y = a - k + 1;
if (x >= 0)
add_prod(ans, tmp, C(x + y - 1, y - 1));
} else {
int x = n - b - k - 1, y = a - k + 1;
if (x >= 0)
add_prod(ans, tmp, C(x + y - 1, y - 1));
}
}
printf("%d\n", ans);
return 0;
} | replace | 55 | 56 | 55 | 56 | 0 | |
p02878 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll modinv(ll a, ll m) {
assert(m > 0);
if (m == 1)
return 0;
a %= m;
if (a < 0)
a += m;
assert(a != 0);
if (a == 1)
return 1;
return m - modinv(m, a) * m / a;
}
template <int MOD_> struct modnum {
private:
int v;
public:
static const int MOD = MOD_;
modnum() : v(0) {}
modnum(ll v_) : v(int(v_ % MOD)) {
if (v < 0)
v += MOD;
}
explicit operator int() const { return v; }
friend bool operator==(const modnum &a, const modnum &b) {
return a.v == b.v;
}
friend bool operator!=(const modnum &a, const modnum &b) {
return a.v != b.v;
}
modnum operator~() const {
modnum res;
res.v = modinv(v, MOD);
return res;
}
modnum &operator+=(const modnum &o) {
v += o.v;
if (v >= MOD)
v -= MOD;
return *this;
}
modnum &operator-=(const modnum &o) {
v -= o.v;
if (v < 0)
v += MOD;
return *this;
}
modnum &operator*=(const modnum &o) {
v = int(ll(v) * ll(o.v) % MOD);
return *this;
}
modnum &operator/=(const modnum &o) { return *this *= (~o); }
friend modnum operator+(const modnum &a, const modnum &b) {
return modnum(a) += b;
}
friend modnum operator-(const modnum &a, const modnum &b) {
return modnum(a) -= b;
}
friend modnum operator*(const modnum &a, const modnum &b) {
return modnum(a) *= b;
}
friend modnum operator/(const modnum &a, const modnum &b) {
return modnum(a) /= b;
}
friend modnum pow() {}
};
using num = modnum<998244353>;
template <typename T> T pow(T a, long long b) {
assert(b >= 0);
T r = 1;
while (b) {
if (b & 1)
r *= a;
b >>= 1;
a *= a;
}
return r;
}
vector<num> fact;
vector<num> ifact;
void init() {
fact = {1};
for (int i = 1; i < 1100000; i++)
fact.push_back(i * fact[i - 1]);
ifact.resize(fact.size());
ifact.back() = 1 / fact.back();
for (int i = (int)ifact.size() - 1; i > 0; i--)
ifact[i - 1] = i * ifact[i];
}
num ncr(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
init();
int n, a, b;
cin >> n >> a >> b;
num ans = 0;
for (int i = 0; i + b <= n; i++) {
int nreset = i;
int nup = n - b - nreset;
int nright = b;
num ways = 0;
if (nright == 0 && nup == 0) {
ways = 1;
} else if (nright <= nup || b - a > nright - nup) {
ways = 0;
} else {
num path = ncr(nright + nup - 1, nup) / nright * (nright - nup);
int z = (nright - nup) - (b - a);
if (z > 0) {
if (nreset == 0)
continue;
nreset -= 1;
}
num mult = ncr(z + nreset, nreset);
ways = path * mult;
}
ans += ways;
}
cout << (int)ans << '\n';
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll modinv(ll a, ll m) {
assert(m > 0);
if (m == 1)
return 0;
a %= m;
if (a < 0)
a += m;
assert(a != 0);
if (a == 1)
return 1;
return m - modinv(m, a) * m / a;
}
template <int MOD_> struct modnum {
private:
int v;
public:
static const int MOD = MOD_;
modnum() : v(0) {}
modnum(ll v_) : v(int(v_ % MOD)) {
if (v < 0)
v += MOD;
}
explicit operator int() const { return v; }
friend bool operator==(const modnum &a, const modnum &b) {
return a.v == b.v;
}
friend bool operator!=(const modnum &a, const modnum &b) {
return a.v != b.v;
}
modnum operator~() const {
modnum res;
res.v = modinv(v, MOD);
return res;
}
modnum &operator+=(const modnum &o) {
v += o.v;
if (v >= MOD)
v -= MOD;
return *this;
}
modnum &operator-=(const modnum &o) {
v -= o.v;
if (v < 0)
v += MOD;
return *this;
}
modnum &operator*=(const modnum &o) {
v = int(ll(v) * ll(o.v) % MOD);
return *this;
}
modnum &operator/=(const modnum &o) { return *this *= (~o); }
friend modnum operator+(const modnum &a, const modnum &b) {
return modnum(a) += b;
}
friend modnum operator-(const modnum &a, const modnum &b) {
return modnum(a) -= b;
}
friend modnum operator*(const modnum &a, const modnum &b) {
return modnum(a) *= b;
}
friend modnum operator/(const modnum &a, const modnum &b) {
return modnum(a) /= b;
}
friend modnum pow() {}
};
using num = modnum<998244353>;
template <typename T> T pow(T a, long long b) {
assert(b >= 0);
T r = 1;
while (b) {
if (b & 1)
r *= a;
b >>= 1;
a *= a;
}
return r;
}
vector<num> fact;
vector<num> ifact;
void init() {
fact = {1};
for (int i = 1; i < 21000000; i++)
fact.push_back(i * fact[i - 1]);
ifact.resize(fact.size());
ifact.back() = 1 / fact.back();
for (int i = (int)ifact.size() - 1; i > 0; i--)
ifact[i - 1] = i * ifact[i];
}
num ncr(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
init();
int n, a, b;
cin >> n >> a >> b;
num ans = 0;
for (int i = 0; i + b <= n; i++) {
int nreset = i;
int nup = n - b - nreset;
int nright = b;
num ways = 0;
if (nright == 0 && nup == 0) {
ways = 1;
} else if (nright <= nup || b - a > nright - nup) {
ways = 0;
} else {
num path = ncr(nright + nup - 1, nup) / nright * (nright - nup);
int z = (nright - nup) - (b - a);
if (z > 0) {
if (nreset == 0)
continue;
nreset -= 1;
}
num mult = ncr(z + nreset, nreset);
ways = path * mult;
}
ans += ways;
}
cout << (int)ans << '\n';
} | replace | 95 | 96 | 95 | 96 | 0 | |
p02878 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e7 + 10, mod = 998244353;
inline int gi() {
char c = getchar();
while (c < '0' || c > '9')
c = getchar();
int sum = 0;
while ('0' <= c && c <= '9')
sum = sum * 10 + c - 48, c = getchar();
return sum;
}
inline int add(int x, int y) { return x + y > mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x < y ? x - y + mod : x - y; }
inline int fpow(int x, int k) {
int res = 1;
while (k) {
if (k & 1)
res = (ll)res * x % mod;
k >>= 1;
x = (ll)x * x % mod;
}
return res;
}
int n, a, b;
int fac[maxn], ifac[maxn];
inline int C(int m, int n) {
if (m < 0 || m < n)
return 0;
return (ll)fac[m] * ifac[n] % mod * ifac[m - n] % mod;
}
inline int F(int x, int y) {
if (y <= x - 1)
return 0;
return sub(C(x + y, x), C(x + y, x - 1));
}
int main() {
n = gi();
a = gi();
b = gi();
fac[0] = ifac[0] = ifac[1] = 1;
for (int i = 1; i < maxn; ++i)
fac[i] = (ll)fac[i - 1] * i % mod;
ifac[maxn - 1] = fpow(fac[maxn - 1], mod - 2);
for (int i = maxn - 2; ~i; --i)
ifac[i] = (ll)ifac[i + 1] * (i + 1) % mod;
if (!b)
return puts("1"), 0;
int ans = 0;
for (int i = 0; i <= n - b; ++i) {
int tmp = F(i, b - 1);
if (i + b == n) {
if (i == a)
ans = add(ans, tmp);
} else {
int x = n - b - i - 1, y = a - i + 1;
ans = (ans + (ll)tmp * C(x + y - 1, y - 1)) % mod;
}
}
printf("%d\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e7 + 10, mod = 998244353;
inline int gi() {
char c = getchar();
while (c < '0' || c > '9')
c = getchar();
int sum = 0;
while ('0' <= c && c <= '9')
sum = sum * 10 + c - 48, c = getchar();
return sum;
}
inline int add(int x, int y) { return x + y > mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x < y ? x - y + mod : x - y; }
inline int fpow(int x, int k) {
int res = 1;
while (k) {
if (k & 1)
res = (ll)res * x % mod;
k >>= 1;
x = (ll)x * x % mod;
}
return res;
}
int n, a, b;
int fac[maxn], ifac[maxn];
inline int C(int m, int n) {
if (n < 0 || m < n)
return 0;
return (ll)fac[m] * ifac[n] % mod * ifac[m - n] % mod;
}
inline int F(int x, int y) {
if (y <= x - 1)
return 0;
return sub(C(x + y, x), C(x + y, x - 1));
}
int main() {
n = gi();
a = gi();
b = gi();
fac[0] = ifac[0] = ifac[1] = 1;
for (int i = 1; i < maxn; ++i)
fac[i] = (ll)fac[i - 1] * i % mod;
ifac[maxn - 1] = fpow(fac[maxn - 1], mod - 2);
for (int i = maxn - 2; ~i; --i)
ifac[i] = (ll)ifac[i + 1] * (i + 1) % mod;
if (!b)
return puts("1"), 0;
int ans = 0;
for (int i = 0; i <= n - b; ++i) {
int tmp = F(i, b - 1);
if (i + b == n) {
if (i == a)
ans = add(ans, tmp);
} else {
int x = n - b - i - 1, y = a - i + 1;
ans = (ans + (ll)tmp * C(x + y - 1, y - 1)) % mod;
}
}
printf("%d\n", ans);
return 0;
}
| replace | 33 | 34 | 33 | 34 | -11 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
if (0 < A && A < 10 && 0 < B && B < 10)
cout << A * B << endl;
else
return -1;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
if (0 < A && A < 10 && 0 < B && B < 10)
cout << A * B << endl;
else
cout << -1 << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repA(a, i, n) for (int i = a; i < n; i++)
#define trav(a, x) for (auto &a : x)
#define fll(a) memset(a, 0, sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fst first
#define sec second
#define itr(it, x) for (auto it = x.begin(); it != x.end(); it++)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> ma;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
void fopen() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
}
int main() {
fastio;
fopen();
int n, m;
cin >> n >> m;
if (n / 10 == 0 && m / 10 == 0) {
cout << n * m;
} else {
cout << -1;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repA(a, i, n) for (int i = a; i < n; i++)
#define trav(a, x) for (auto &a : x)
#define fll(a) memset(a, 0, sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fst first
#define sec second
#define itr(it, x) for (auto it = x.begin(); it != x.end(); it++)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> ma;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
void fopen() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
}
int main() {
fastio;
// fopen();
int n, m;
cin >> n >> m;
if (n / 10 == 0 && m / 10 == 0) {
cout << n * m;
} else {
cout << -1;
}
}
| replace | 27 | 28 | 27 | 28 | 0 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000;
signed main() {
int a, b;
cin >> a >> b;
if (a < 1 || a > 9)
return -1;
if (b < 1 || b > 9)
return -1;
cout << (a * b) << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000;
signed main() {
int a, b;
cin >> a >> b;
if (a < 1 || a > 9) {
cout << -1 << endl;
return 0;
}
if (b < 1 || b > 9) {
cout << -1 << endl;
return 0;
}
cout << (a * b) << endl;
} | replace | 12 | 16 | 12 | 20 | 0 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 400
#define mod 1000000007
#define sin(s) scanf("%lld", &s);
#define sout(s) printf("%lld\n", s);
#define in(s) cin >> s
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define out(s) cout << s
#define outs(s, a) cout << s << a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define nfl(i, n) for (i = 0; i < n; i++)
#define sfl(i, s, e) for (i = s; i < e; i++)
#define ufl(i, n) for (i = n - 1; i >= 0; i--)
using namespace std;
void solve() {
ll a, b;
in2(a, b);
if (a <= 9 && b <= 9)
cout << a * b << "\n";
else
cout << "-1\n";
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif
gear_change;
ll test = 1;
// in(test);
while (test--) {
solve();
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 400
#define mod 1000000007
#define sin(s) scanf("%lld", &s);
#define sout(s) printf("%lld\n", s);
#define in(s) cin >> s
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define out(s) cout << s
#define outs(s, a) cout << s << a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define nfl(i, n) for (i = 0; i < n; i++)
#define sfl(i, s, e) for (i = s; i < e; i++)
#define ufl(i, n) for (i = n - 1; i >= 0; i--)
using namespace std;
void solve() {
ll a, b;
in2(a, b);
if (a <= 9 && b <= 9)
cout << a * b << "\n";
else
cout << "-1\n";
}
int main() {
gear_change;
ll test = 1;
// in(test);
while (test--) {
solve();
}
return 0;
}
| replace | 32 | 36 | 32 | 33 | 0 | |
p02879 | C++ | Runtime Error | // someshsingh22
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define loop(i, n) for (int i = 0; i < n; i++)
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define inp_int(n, arr) \
int arr[n]; \
loop(i, n) cin >> arr[i];
#define inp_ll(n, arr) \
ll arr[n]; \
loop(i, n) cin >> arr[i];
#define out_int(n, arr) loop(i, n) printf("%d ", arr[i]);
#define out_ll(n, arr) \
loop(i, n) printf("%lld ", arr[i]); \
cout << endl;
#define all(c) c.begin(), c.end()
// Snippets : BFS, DFS, edger, ncr, chef, inverse, sieve, lis-d*, mat_d*, pow
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
int main() {
FAST;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int a, b;
cin >> a >> b;
if (a > 0 && b > 0 && a < 10 && b < 10)
cout << a * b;
else
cout << -1;
return 0;
}
| // someshsingh22
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define loop(i, n) for (int i = 0; i < n; i++)
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define inp_int(n, arr) \
int arr[n]; \
loop(i, n) cin >> arr[i];
#define inp_ll(n, arr) \
ll arr[n]; \
loop(i, n) cin >> arr[i];
#define out_int(n, arr) loop(i, n) printf("%d ", arr[i]);
#define out_ll(n, arr) \
loop(i, n) printf("%lld ", arr[i]); \
cout << endl;
#define all(c) c.begin(), c.end()
// Snippets : BFS, DFS, edger, ncr, chef, inverse, sieve, lis-d*, mat_d*, pow
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
int main() {
int a, b;
cin >> a >> b;
if (a > 0 && b > 0 && a < 10 && b < 10)
cout << a * b;
else
cout << -1;
return 0;
} | delete | 29 | 34 | 29 | 29 | 0 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define max1 1000005
#define sz1 100001
#define mod 1000000007
#define moda 421412341324321ll
#define inf 1e18
#define ll long long int
#define debug(x) cout << #x << " " << x << endl
typedef pair<ll, ll> pr;
#define rte \
cout << "Correct"; \
exit(0);
int intlog(double x) { return (int)(log(x) / log(2)); }
double max(double x, double y) {
if (x >= y) {
return x;
} else {
return y;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll l, r;
cin >> l >> r;
if (l >= 1 && l <= 9) {
if (r >= 1 && r <= 9) {
cout << l * r;
return 0;
}
}
cout << -1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define max1 1000005
#define sz1 100001
#define mod 1000000007
#define moda 421412341324321ll
#define inf 1e18
#define ll long long int
#define debug(x) cout << #x << " " << x << endl
typedef pair<ll, ll> pr;
#define rte \
cout << "Correct"; \
exit(0);
int intlog(double x) { return (int)(log(x) / log(2)); }
double max(double x, double y) {
if (x >= y) {
return x;
} else {
return y;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif*/
ll l, r;
cin >> l >> r;
if (l >= 1 && l <= 9) {
if (r >= 1 && r <= 9) {
cout << l * r;
return 0;
}
}
cout << -1 << endl;
} | replace | 25 | 29 | 25 | 29 | 0 | |
p02879 | Python | Runtime Error | S = list(input())
if len(S) > 3:
print(int(S[0]) * int(S[1]))
else:
print(-1)
| S = list(input())
if len(S) < 4:
print(int(S[0]) * int(S[-1]))
else:
print(-1)
| replace | 1 | 3 | 1 | 3 | 0 | |
p02879 | C++ | Runtime Error | #include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
if (a > 9 || b > 9) {
std::cout << -1 << std::endl;
} else {
std::cout << a * b << std::endl;
}
return -1;
} | #include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
if (a > 9 || b > 9) {
std::cout << -1 << std::endl;
} else {
std::cout << a * b << std::endl;
}
} | delete | 10 | 11 | 10 | 10 | 255 | |
p02879 | Python | Runtime Error | a = int(input())
b = int(input())
if a >= 10 or b >= 10:
print(-1)
else:
print(a * b)
| a, b = map(int, input().split())
if a >= 10 or b >= 10:
print(-1)
else:
print(a * b)
| replace | 0 | 2 | 0 | 1 | ValueError: invalid literal for int() with base 10: '2 5' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02879/Python/s727358727.py", line 1, in <module>
a = int(input())
ValueError: invalid literal for int() with base 10: '2 5'
|
p02879 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 30;
const int MAX = 1e5;
int n;
template <class T> inline void xmin(T &a, T b) { a = (a < b) ? a : b; }
template <class T> inline void xmax(T &a, T b) { a = (a > b) ? a : b; }
int a, b;
void solve() {
cin >> a >> b;
if (a > 9 || b > 9) {
cout << -1 << endl;
} else {
cout << a * b << endl;
}
}
signed main() {
while (1)
solve();
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 30;
const int MAX = 1e5;
int n;
template <class T> inline void xmin(T &a, T b) { a = (a < b) ? a : b; }
template <class T> inline void xmax(T &a, T b) { a = (a > b) ? a : b; }
int a, b;
void solve() {
cin >> a >> b;
if (a > 9 || b > 9) {
cout << -1 << endl;
} else {
cout << a * b << endl;
}
}
signed main() {
// while(1)
solve();
}
| replace | 27 | 29 | 27 | 29 | TLE | |
p02879 | C++ | Runtime Error | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("INPUT.txt", "r", stdin);
freopen("OUTPUT.txt", "w", stdout);
#endif
clock_t clk;
clk = clock();
// --------------Code s0tarts
// here---------------------------------------------------------------------
int a, b;
cin >> a >> b;
if (a < 10 && b < 10) {
cout << a * b;
} else {
cout << -1;
}
// -------------------------------------Code ends
// here------------------------------------------------------
clk = clock() - clk;
cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
<< "\n";
return 0;
} | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen ("INPUT.txt" , "r" , stdin);
// freopen ("OUTPUT.txt" , "w" , stdout);
// #endif
clock_t clk;
clk = clock();
// --------------Code s0tarts
// here---------------------------------------------------------------------
int a, b;
cin >> a >> b;
if (a < 10 && b < 10) {
cout << a * b;
} else {
cout << -1;
}
// -------------------------------------Code ends
// here------------------------------------------------------
clk = clock() - clk;
cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
<< "\n";
return 0;
} | replace | 10 | 14 | 10 | 14 | 0 | Time: 0.000162
|
p02879 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if ((a > 9 || b > 9) || (a < 1 || b < 1))
return -1;
cout << a * b << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (a > 9 || b > 9)
cout << -1 << endl;
else
cout << a * b << endl;
return 0;
}
| replace | 5 | 8 | 5 | 9 | 0 | |
p02879 | C++ | Runtime Error | // Nihal Mittal - nihal_47
// Shine Like a Sun , Burn like a Sun
/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include <bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(), (v).end()
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(0);
#define pii pair<int, int>
#define maxn 100005
using namespace std;
signed main() {
fast;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int a, b;
cin >> a >> b;
if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
cout << a * b;
else
cout << "-1";
} | // Nihal Mittal - nihal_47
// Shine Like a Sun , Burn like a Sun
/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include <bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(), (v).end()
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(0);
#define pii pair<int, int>
#define maxn 100005
using namespace std;
signed main() {
fast;
int a, b;
cin >> a >> b;
if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
cout << a * b;
else
cout << "-1";
} | replace | 40 | 44 | 40 | 41 | 0 | |
p02879 | C++ | Runtime Error | /* Don't try to hack it :|
_/﹋\_
(҂`_´)
<,︻╦╤─҉- - - - - - - - - - - - - - -
_/﹋\_
*/
#include <bits/stdc++.h>
#define ll long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for (auto it = con.begin(); it != con.end(); it++)
#define INF 1e9 + 7 // 1 * 10^9+ 7
#define rep(i, l, r) for (ll i = l; i <= r; i++)
#define fo(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll a, b;
cin >> a >> b;
if (a < 10 && b < 10)
cout << a * b;
else
cout << "-1";
return 0;
}
| /* Don't try to hack it :|
_/﹋\_
(҂`_´)
<,︻╦╤─҉- - - - - - - - - - - - - - -
_/﹋\_
*/
#include <bits/stdc++.h>
#define ll long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for (auto it = con.begin(); it != con.end(); it++)
#define INF 1e9 + 7 // 1 * 10^9+ 7
#define rep(i, l, r) for (ll i = l; i <= r; i++)
#define fo(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll a, b;
cin >> a >> b;
if (a < 10 && b < 10)
cout << a * b;
else
cout << "-1";
return 0;
}
| replace | 22 | 26 | 22 | 23 | 0 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
void solve() {
int a, b;
cin >> a >> b;
if (max(a, b) >= 10) {
cout << -1 << endl;
} else {
cout << a * b << endl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int tests = 1;
// cin>>tests;
while (tests--) {
solve();
}
return 0;
} | #include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
void solve() {
int a, b;
cin >> a >> b;
if (max(a, b) >= 10) {
cout << -1 << endl;
} else {
cout << a * b << endl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int tests = 1;
// cin>>tests;
while (tests--) {
solve();
}
return 0;
} | replace | 24 | 28 | 24 | 28 | 0 | |
p02879 | C++ | Time Limit Exceeded | #include <cstdio>
inline int in();
inline void wr(int);
int main(int argc, char **argv) {
#ifndef ONLINE_JUDGE
freopen("A.in", "r", stdin);
freopen("A.ans", "w", stdout);
#endif
register int a = in(), b = in();
if (a > 9 || b > 9) {
wr(-1), putchar('\n');
return 0;
}
wr(a * b), putchar('\n');
}
inline int in() {
register char c = getchar();
register int x = 0, f = 1;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-')
f = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = (x << 1) + (x << 3) + (c & 15);
return x * f;
}
inline void wr(int x) {
if (x < 0)
putchar('-'), x = -x;
if (x / 10)
wr(x / 10);
putchar(x % 10 + '0');
}
| #include <cstdio>
inline int in();
inline void wr(int);
int main(int argc, char **argv) {
#ifndef ONLINE_JUDGE
// freopen("A.in","r",stdin);
// freopen("A.ans","w",stdout);
#endif
register int a = in(), b = in();
if (a > 9 || b > 9) {
wr(-1), putchar('\n');
return 0;
}
wr(a * b), putchar('\n');
}
inline int in() {
register char c = getchar();
register int x = 0, f = 1;
for (; c < '0' || c > '9'; c = getchar())
if (c == '-')
f = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = (x << 1) + (x << 3) + (c & 15);
return x * f;
}
inline void wr(int x) {
if (x < 0)
putchar('-'), x = -x;
if (x / 10)
wr(x / 10);
putchar(x % 10 + '0');
}
| replace | 5 | 7 | 5 | 7 | TLE | |
p02879 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <vector>
using namespace std;
using namespace tr1;
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define FORD(i, j, k) for (int i = j; i >= k; i--)
#define ll long long int
// Make sure no overflow problems
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i, n) __typeof(n) i = (n)
#define FOREACH(i, c) for (VAR(i, (c).begin()); i != (c).end(); i++)
#define FORDEACH(i, c) for (VAR(i, (c).rbegin()), i != (c).rend(); i++)
#define REP(i, n) FOR(i, 0, n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int A, B;
cin >> A >> B;
if (A > 9 || B > 9)
cout << -1;
else
cout << A * B;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <vector>
using namespace std;
using namespace tr1;
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define FORD(i, j, k) for (int i = j; i >= k; i--)
#define ll long long int
// Make sure no overflow problems
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i, n) __typeof(n) i = (n)
#define FOREACH(i, c) for (VAR(i, (c).begin()); i != (c).end(); i++)
#define FORDEACH(i, c) for (VAR(i, (c).rbegin()), i != (c).rend(); i++)
#define REP(i, n) FOR(i, 0, n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
/*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif */
int A, B;
cin >> A >> B;
if (A > 9 || B > 9)
cout << -1;
else
cout << A * B;
return 0;
}
| replace | 40 | 45 | 40 | 45 | 0 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define mod 1000000000
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string, ll>
#define pii pair<ll, ll>
#define vsi vector<psi>
#define vii vector<pii>
#define mp make_pair
#define pb push_back
#define rep(n) for (long i = 0; i < n; i++)
#define repr(n) for (long i = (n - 1); i >= 0; i--)
#define fori(i, a, b) for (auto i = a; i <= b; i++)
#define ford(i, b, a) for (auto i = b; i >= a; i--)
#define mset(a, i) memset(a, i, sizeof(a))
#define minv(a) min_element(a.begin(), a.end())
#define maxv(a) max_element(a.begin(), a.end())
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define sotit(a) sort(a.begin(), a.end());
#define sot(a) sort(a, a + n);
#define ff first
#define maxheap(v) priority_queue<v>
#define minheap(v) priority_queue<v, vector<v>, greater<v>>
#define ss second
#define endl "\n"
#define NL cout << endl;
#define printmat(a, m, n) \
for (int i = 0; i < m; i++) { \
for (int j = 0; j < n; j++) { \
cout << a[i][j] << " "; \
} \
cout << endl; \
}
#define dbgn(x) cout << " $ " << x << " $ " << endl;
#define dbg(x) cout << " $ " << x << " $ ";
#define all(v) v.begin(), v.end()
#define show(a, n) \
for (int i = 0; i < n; i++) { \
cout << a[i] << " "; \
} \
NL
#define fast_io() \
cin.sync_with_stdio(false); \
cout.sync_with_stdio(false); \
cin.tie(NULL);
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
int main() {
fast_io()
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll a, b;
cin >> a >> b;
if (a >= 1 && b >= 1 && a <= 9 && b <= 9) {
cout << a * b;
} else {
cout << -1;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define mod 1000000000
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string, ll>
#define pii pair<ll, ll>
#define vsi vector<psi>
#define vii vector<pii>
#define mp make_pair
#define pb push_back
#define rep(n) for (long i = 0; i < n; i++)
#define repr(n) for (long i = (n - 1); i >= 0; i--)
#define fori(i, a, b) for (auto i = a; i <= b; i++)
#define ford(i, b, a) for (auto i = b; i >= a; i--)
#define mset(a, i) memset(a, i, sizeof(a))
#define minv(a) min_element(a.begin(), a.end())
#define maxv(a) max_element(a.begin(), a.end())
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define sotit(a) sort(a.begin(), a.end());
#define sot(a) sort(a, a + n);
#define ff first
#define maxheap(v) priority_queue<v>
#define minheap(v) priority_queue<v, vector<v>, greater<v>>
#define ss second
#define endl "\n"
#define NL cout << endl;
#define printmat(a, m, n) \
for (int i = 0; i < m; i++) { \
for (int j = 0; j < n; j++) { \
cout << a[i][j] << " "; \
} \
cout << endl; \
}
#define dbgn(x) cout << " $ " << x << " $ " << endl;
#define dbg(x) cout << " $ " << x << " $ ";
#define all(v) v.begin(), v.end()
#define show(a, n) \
for (int i = 0; i < n; i++) { \
cout << a[i] << " "; \
} \
NL
#define fast_io() \
cin.sync_with_stdio(false); \
cout.sync_with_stdio(false); \
cin.tie(NULL);
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
int main() {
fast_io()
ll a,
b;
cin >> a >> b;
if (a >= 1 && b >= 1 && a <= 9 && b <= 9) {
cout << a * b;
} else {
cout << -1;
}
return 0;
} | replace | 56 | 62 | 56 | 58 | 0 | |
p02879 | C++ | Runtime Error | #include <stdio.h>
int main() {
int A, B;
scanf("%d %d", &A, &B);
return (A < 10 && B < 10) ? A * B : -1;
} | #include <stdio.h>
int main() {
int A, B;
scanf("%d %d", &A, &B);
printf("%d", (A < 10 && B < 10) ? A * B : -1);
return 0;
} | replace | 4 | 5 | 4 | 6 | 10 | |
p02879 | C++ | Runtime Error | #include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
int ans;
if (a > 9 || b > 9) {
ans = -1;
} else {
ans = a * b;
}
std::cout << ans;
return 1;
} | #include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
int ans;
if (a > 9 || b > 9) {
ans = -1;
} else {
ans = a * b;
}
std::cout << ans;
return 0;
} | replace | 12 | 13 | 12 | 13 | 1 | |
p02879 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
#endif
int a, b;
cin >> a >> b;
if (a >= 1 && a <= 9 && b <= 9 && b >= 1) {
cout << a * b << "\n";
}
else {
cout << -1;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a, b;
cin >> a >> b;
if (a >= 1 && a <= 9 && b <= 9 && b >= 1) {
cout << a * b << "\n";
}
else {
cout << -1;
}
}
| delete | 12 | 17 | 12 | 12 | 0 | |
p02880 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
int n, i;
cin >> n;
for (i = 0; i < 10; i++)
if (n % i == 0 && n / i < 10)
break;
if (i == 10)
cout << "No" << endl;
else
cout << "Yes" << endl;
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
int n, i;
cin >> n;
for (i = 1; i < 10; i++)
if (n % i == 0 && n / i < 10)
break;
if (i == 10)
cout << "No" << endl;
else
cout << "Yes" << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool flag = false;
for (int i = 0; i < 9; i++) {
if (N % i == 0 && N / i <= 9) {
flag = 1;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool flag = false;
for (int i = 1; i <= 9; i++) {
if (N % i == 0 && N / i <= 9) {
flag = 1;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| replace | 9 | 10 | 9 | 10 | -8 | |
p02880 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x));
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
};
};
int k = 0, n = 0, m = 0, l = 0, a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0,
ans2 = 0, x = 0, y = 0;
string s, t, S;
signed main() {
cin >> n;
for (int i = 1; i <= 9; a++)
for (int j = 1; j <= 9; b++) {
if (i * j == n) {
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x));
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
};
};
int k = 0, n = 0, m = 0, l = 0, a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0,
ans2 = 0, x = 0, y = 0;
string s, t, S;
signed main() {
cin >> n;
for (int i = 1; i <= 9; i++)
for (int j = 1; j <= 9; j++) {
if (i * j == n) {
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}
| replace | 22 | 24 | 22 | 24 | TLE | |
p02880 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl
#define FLG(flg) \
if (flg) \
cout << "Yes" << endl; \
else \
cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define COUT(s) cout << s << endl;
#define AN \
vector<int> a(n); \
for (int i = 0; i < n; i++) \
cin >> a[i];
#define IN \
int n; \
cin >> n;
#define VI vector<int>
#define SS stringstream ss;
#define SOLVE cout << solve() << endl;
int main() {
IN bool flg = false;
REP(i, n) {
for (int j = i; i * j <= n; j++) {
if (i * j == n)
flg = true;
}
}
FLG(flg)
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl
#define FLG(flg) \
if (flg) \
cout << "Yes" << endl; \
else \
cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define COUT(s) cout << s << endl;
#define AN \
vector<int> a(n); \
for (int i = 0; i < n; i++) \
cin >> a[i];
#define IN \
int n; \
cin >> n;
#define VI vector<int>
#define SS stringstream ss;
#define SOLVE cout << solve() << endl;
int main() {
IN bool flg = false;
for (int i = 1; i <= 9; i++) {
for (int j = i; j <= 9; j++) {
if (i * j == n)
flg = true;
}
}
FLG(flg)
} | replace | 28 | 30 | 28 | 30 | TLE | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0;
cin >> N;
for (int i = 1; i <= 9; i++) {
if ((N % i) == 0 && (N / i) < 10) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 1;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0;
cin >> N;
for (int i = 1; i <= 9; i++) {
if ((N % i) == 0 && (N / i) < 10) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p02880 | C++ | Runtime Error | #include <iostream>
int main() {
int N = 0;
std::cin >> N; // hold a number
for (int i = 0; i < 10; ++i)
if (N % i == 0 && N / i < 10) {
std::cout << "Yes" << std::endl;
return 0;
}
std::cout << "No" << std::endl;
return 0;
} | #include <iostream>
int main() {
int N = 0;
std::cin >> N; // hold a number
for (int i = 1; i < 10; ++i)
if (N % i == 0 && N / i < 10) {
std::cout << "Yes" << std::endl;
return 0;
}
std::cout << "No" << std::endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | -8 | |
p02880 | C++ | Runtime Error | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("INPUT.txt", "r", stdin);
freopen("OUTPUT.txt", "w", stdout);
#endif
clock_t clk;
clk = clock();
// --------------Code s0tarts
// here---------------------------------------------------------------------
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
if (n % i == 0) {
if (n / i < 10 && i < 10) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
// -------------------------------------Code ends
// here------------------------------------------------------
clk = clock() - clk;
cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
<< "\n";
return 0;
} | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen ("INPUT.txt" , "r" , stdin);
// freopen ("OUTPUT.txt" , "w" , stdout);
// #endif
clock_t clk;
clk = clock();
// --------------Code s0tarts
// here---------------------------------------------------------------------
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
if (n % i == 0) {
if (n / i < 10 && i < 10) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
// -------------------------------------Code ends
// here------------------------------------------------------
clk = clock() - clk;
cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
<< "\n";
return 0;
} | replace | 10 | 14 | 10 | 14 | TLE | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int a;
cin >> a;
if (a > 81) {
cout << "No" << endl;
return 0;
}
int cnt = 0;
rep(i, 9) {
if (a % i == 0 && (0 <= a / i && a / i <= 9))
cnt++;
}
if (cnt > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int a;
cin >> a;
if (a > 81) {
cout << "No" << endl;
return 0;
}
int cnt = 0;
rep(i, 9) {
if (a % (i + 1) == 0 && (0 <= a / (i + 1) && a / (i + 1) <= 9))
cnt++;
}
if (cnt > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | replace | 14 | 15 | 14 | 15 | -8 | |
p02880 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool ans = false;
for (int i = 1; i < 10;) {
for (int j = 1; j < 10; j++) {
if (i * j == N)
ans = true;
}
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool ans = false;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i * j == N)
ans = true;
}
}
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| replace | 7 | 8 | 7 | 8 | TLE | |
p02880 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, k = 9;
cin >> n;
for (k = 0; k >= 1; k--) {
if (n % k == 0)
break;
}
int c = n / k;
if (c >= 10)
cout << "No" << endl;
else
cout << "Yes" << endl;
} | #include <iostream>
using namespace std;
int main() {
int n, k = 9;
cin >> n;
for (k = 9; k >= 1; k--) {
if (n % k == 0)
break;
}
int c = n / k;
if (c >= 10)
cout << "No" << endl;
else
cout << "Yes" << endl;
} | replace | 7 | 8 | 7 | 8 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod);
#define mod_in(a) exp(a, mod - 2)
#define ncr(n, r) ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl '\n'
ll prime[100000];
ll exp(ll a, ll b);
void sieve(ll n);
ll gcd(ll a, ll b);
ll countdigit(ll n);
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
flash ll arr[10][10];
ll n;
cin >> n;
ll f = 0;
rep(i, 1, 10) {
rep(j, 1, 10) { arr[i][j] = i * j; }
}
rep(i, 1, 10) {
rep(j, 1, 10) {
if (arr[i][j] == n) {
cout << "Yes";
f = 1;
break;
}
}
if (f == 1)
break;
}
if (f == 0)
cout << "No";
}
//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
int res = 1;
while (b) {
if (b & 1)
res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
void sieve(ll n) {
for (ll i = 0; i <= n; i++) {
prime[i] = 1;
}
prime[0] = 0;
prime[1] = 0;
for (ll i = 2; i <= n; i++) {
if (prime[i] == 1) {
for (ll j = 2; i * j <= n; j++) {
prime[i * j] = 0;
}
}
}
}
ll countdigit(ll n) { return floor(log10(n) + 1); }
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod);
#define mod_in(a) exp(a, mod - 2)
#define ncr(n, r) ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl '\n'
ll prime[100000];
ll exp(ll a, ll b);
void sieve(ll n);
ll gcd(ll a, ll b);
ll countdigit(ll n);
int main() {
flash ll arr[10][10];
ll n;
cin >> n;
ll f = 0;
rep(i, 1, 10) {
rep(j, 1, 10) { arr[i][j] = i * j; }
}
rep(i, 1, 10) {
rep(j, 1, 10) {
if (arr[i][j] == n) {
cout << "Yes";
f = 1;
break;
}
}
if (f == 1)
break;
}
if (f == 0)
cout << "No";
}
//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
int res = 1;
while (b) {
if (b & 1)
res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
void sieve(ll n) {
for (ll i = 0; i <= n; i++) {
prime[i] = 1;
}
prime[0] = 0;
prime[1] = 0;
for (ll i = 2; i <= n; i++) {
if (prime[i] == 1) {
for (ll j = 2; i * j <= n; j++) {
prime[i * j] = 0;
}
}
}
}
ll countdigit(ll n) { return floor(log10(n) + 1); }
| delete | 34 | 38 | 34 | 34 | 0 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int i, N, judge = 0;
cin >> N;
rep(i, 9) {
if (N % i == 0 && N / i < 10) {
judge = 1;
break;
}
}
if (judge)
cout << "Yes";
else
cout << "No";
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int i, N, judge = 0;
cin >> N;
rep(i, 9) {
if (N % (i + 1) == 0 && N / (i + 1) < 10) {
judge = 1;
break;
}
}
if (judge)
cout << "Yes";
else
cout << "No";
}
| replace | 12 | 13 | 12 | 13 | -8 | |
p02880 | C++ | Runtime Error | #include <iostream>
int main() {
int n;
std::cin >> n;
bool ans = false;
for (int i = 1; i < 10; ++i) {
if (n % i == 0 && n / i < 10) {
ans = true;
break;
}
}
if (ans) {
std::cout << "Yes";
} else {
std::cout << "No";
}
return 1;
} | #include <iostream>
int main() {
int n;
std::cin >> n;
bool ans = false;
for (int i = 1; i < 10; ++i) {
if (n % i == 0 && n / i < 10) {
ans = true;
break;
}
}
if (ans) {
std::cout << "Yes";
} else {
std::cout << "No";
}
return 0;
} | replace | 17 | 18 | 17 | 18 | 1 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> P;
int N;
int M = 0;
int count = 0;
cin >> N;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
P.at(M) = i * j;
M++;
}
}
for (int i = 0; i < 81; i++) {
if (N == P.at(i)) {
cout << "Yes" << endl;
break;
}
else
count++;
}
if (count == 81)
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> P(81);
int N;
int M = 0;
int count = 0;
cin >> N;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
P.at(M) = i * j;
M++;
}
}
for (int i = 0; i < 81; i++) {
if (N == P.at(i)) {
cout << "Yes" << endl;
break;
}
else
count++;
}
if (count == 81)
cout << "No" << endl;
}
| replace | 4 | 5 | 4 | 5 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
|
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define For(i, start, end) for (i64 i = start; i < end; i++)
#define newline std::cout << '\n';
#define newlinedx(num) \
for (int i = 0; i < num; i++) \
std::cout << '\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;
//----------------library in this time--------------------------------
template <class T> T gcd(const T a, const T b) {
return (b == 0) ? a : gcd(b, a % b);
}
template <class T> T lcm(const T a, const T b) { return a * b / gcd(a, b); }
template <class T> inline T ave(const T a, const T b) { return (a + b) / 2.0f; }
long long squareTwo(const long long a, const long long b) {
return (b == 1) ? a : squareTwo(a * 2, b - 1);
}
template <class T> inline T Max(const T a, const T b) {
return (a >= b) ? a : b;
}
template <class T> inline T Min(const T a, const T b) {
return (a <= b) ? a : b;
}
//------------------------main function-------------------------------
void Main() {
int N;
cin >> N;
for (int i = 1; i * i < N; i--)
if (N % i == 0 && N / i < 10) {
cout << "Yes" << endl;
return;
}
cout << "No" << endl;
}
//--------------------------------------------------------------------
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(10);
Main();
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define For(i, start, end) for (i64 i = start; i < end; i++)
#define newline std::cout << '\n';
#define newlinedx(num) \
for (int i = 0; i < num; i++) \
std::cout << '\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;
//----------------library in this time--------------------------------
template <class T> T gcd(const T a, const T b) {
return (b == 0) ? a : gcd(b, a % b);
}
template <class T> T lcm(const T a, const T b) { return a * b / gcd(a, b); }
template <class T> inline T ave(const T a, const T b) { return (a + b) / 2.0f; }
long long squareTwo(const long long a, const long long b) {
return (b == 1) ? a : squareTwo(a * 2, b - 1);
}
template <class T> inline T Max(const T a, const T b) {
return (a >= b) ? a : b;
}
template <class T> inline T Min(const T a, const T b) {
return (a <= b) ? a : b;
}
//------------------------main function-------------------------------
void Main() {
int N;
cin >> N;
for (int i = 1; i * i <= N; i++)
if (N % i == 0 && N / i < 10) {
cout << "Yes" << endl;
return;
}
cout << "No" << endl;
}
//--------------------------------------------------------------------
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(10);
Main();
return 0;
}
| replace | 46 | 47 | 46 | 47 | -8 | |
p02880 | C++ | Runtime Error | /*
author: Apoorv Singh
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef vector<long long> vi;
typedef pair<long long, long long> pii;
#define pb push_back
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#define fast_io() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
template <class X> void printarr(X arr[], int n) {
for (int i = 0; i < n; ++i)
cout << arr[i] << ' ';
cout << endl;
}
template <typename X> ostream &operator<<(ostream &x, const vector<X> &v) {
for (X a : v)
x << a << ' ';
return x;
}
template <typename X, typename Y>
ostream &operator<<(ostream &x, const vector<pair<X, Y>> &v) {
for (pair<X, Y> it : v)
x << it.first << ' ' << it.second << endl;
return x;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &v) {
for (pair<T, S> it : v)
os << it.first << " => " << it.second << endl;
return os;
}
template <class T, class cmp = less<T>>
using ordered_set =
tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
int modulo = 1e9 + 7;
int fpow(int a, int n) {
int ans = 1;
while (n) {
if (n & 1)
ans = (ans * a) % modulo;
a = (a * a) % modulo;
n = n >> 1;
}
return ans;
}
signed main() {
fast_io();
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
For(i, 1, 10) {
For(j, 1, 10) {
if (i * j == n) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
return 0;
} | /*
author: Apoorv Singh
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef vector<long long> vi;
typedef pair<long long, long long> pii;
#define pb push_back
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#define fast_io() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
template <class X> void printarr(X arr[], int n) {
for (int i = 0; i < n; ++i)
cout << arr[i] << ' ';
cout << endl;
}
template <typename X> ostream &operator<<(ostream &x, const vector<X> &v) {
for (X a : v)
x << a << ' ';
return x;
}
template <typename X, typename Y>
ostream &operator<<(ostream &x, const vector<pair<X, Y>> &v) {
for (pair<X, Y> it : v)
x << it.first << ' ' << it.second << endl;
return x;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &v) {
for (pair<T, S> it : v)
os << it.first << " => " << it.second << endl;
return os;
}
template <class T, class cmp = less<T>>
using ordered_set =
tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
int modulo = 1e9 + 7;
int fpow(int a, int n) {
int ans = 1;
while (n) {
if (n & 1)
ans = (ans * a) % modulo;
a = (a * a) % modulo;
n = n >> 1;
}
return ans;
}
signed main() {
fast_io();
int n;
cin >> n;
For(i, 1, 10) {
For(j, 1, 10) {
if (i * j == n) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
return 0;
}
| delete | 94 | 98 | 94 | 94 | 0 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
#define M 1000000007
#define MAX 100005
int A[MAX], tree[4 * MAX];
int power(int x, int p) {
if (p == 0)
return 1;
int y = power(x, p / 2);
y *= y;
y %= M;
if (p % 2 == 0)
return y;
y *= x;
y %= M;
return y;
}
void build(int node, int start, int end) {
if (start == end)
// Leaf node will have a single element
tree[node] = start;
else {
int mid = (start + end) / 2;
// Recurse on the left child
build(2 * node, start, mid);
// Recurse on the right child
build(2 * node + 1, mid + 1, end);
// Internal node will have the sum of both of its children
tree[node] = tree[2 * node] + tree[2 * node + 1];
}
}
void update(int node, int start, int end, int idx, int val) {
if (start == end) {
// Leaf Node
A[idx] = val;
tree[node] += val;
} else {
int mid = (start - end) / 2 + end;
if (start <= idx && idx <= mid) {
// If idx is in the left child, recurse on the left child
update(2 * node, start, mid, idx, val);
} else {
// if idx is in the right child, recurse on the right child
update(2 * node + 1, mid + 1, end, idx, val);
}
// Internal node will have the sum of both of its children
tree[node] = tree[2 * node] + tree[2 * node + 1];
}
}
int query(int node, int start, int end, int l, int r) {
if (r < start || l > end) {
// range represented by a node is completely outside the given range
return 0;
}
if (l <= start && end <= r) {
// range represented by a node is completely inside the given range
return tree[node];
}
// range represented by a node is partially inside and partially outside the
// given range
int mid = (start + end) / 2;
int p1 = query(2 * node, start, mid, l, r);
int p2 = query(2 * node + 1, mid + 1, end, l, r);
return p1 + p2;
}
signed main() {
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
rootdada;
int n;
cin >> n;
int a[101];
int x;
int l = 0;
rep(i, 1, 10) {
rep(j, 1, 10) {
x = i * j;
a[l] = x;
l++;
}
}
int flag = 0;
rep(i, 0, 101) {
if (a[i] == n) {
flag = 1;
}
}
if (flag)
cout << "Yes" << endl;
else {
/* code */
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
#define M 1000000007
#define MAX 100005
int A[MAX], tree[4 * MAX];
int power(int x, int p) {
if (p == 0)
return 1;
int y = power(x, p / 2);
y *= y;
y %= M;
if (p % 2 == 0)
return y;
y *= x;
y %= M;
return y;
}
void build(int node, int start, int end) {
if (start == end)
// Leaf node will have a single element
tree[node] = start;
else {
int mid = (start + end) / 2;
// Recurse on the left child
build(2 * node, start, mid);
// Recurse on the right child
build(2 * node + 1, mid + 1, end);
// Internal node will have the sum of both of its children
tree[node] = tree[2 * node] + tree[2 * node + 1];
}
}
void update(int node, int start, int end, int idx, int val) {
if (start == end) {
// Leaf Node
A[idx] = val;
tree[node] += val;
} else {
int mid = (start - end) / 2 + end;
if (start <= idx && idx <= mid) {
// If idx is in the left child, recurse on the left child
update(2 * node, start, mid, idx, val);
} else {
// if idx is in the right child, recurse on the right child
update(2 * node + 1, mid + 1, end, idx, val);
}
// Internal node will have the sum of both of its children
tree[node] = tree[2 * node] + tree[2 * node + 1];
}
}
int query(int node, int start, int end, int l, int r) {
if (r < start || l > end) {
// range represented by a node is completely outside the given range
return 0;
}
if (l <= start && end <= r) {
// range represented by a node is completely inside the given range
return tree[node];
}
// range represented by a node is partially inside and partially outside the
// given range
int mid = (start + end) / 2;
int p1 = query(2 * node, start, mid, l, r);
int p2 = query(2 * node + 1, mid + 1, end, l, r);
return p1 + p2;
}
signed main() {
rootdada;
int n;
cin >> n;
int a[101];
int x;
int l = 0;
rep(i, 1, 10) {
rep(j, 1, 10) {
x = i * j;
a[l] = x;
l++;
}
}
int flag = 0;
rep(i, 0, 101) {
if (a[i] == n) {
flag = 1;
}
}
if (flag)
cout << "Yes" << endl;
else {
/* code */
cout << "No" << endl;
}
} | replace | 85 | 91 | 85 | 86 | 0 | |
p02880 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < 10; i++) {
if (n % i == 0) {
if (n / i < 10) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
return 1;
} | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < 10; i++) {
if (n % i == 0) {
if (n / i < 10) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
return 0;
} | replace | 18 | 19 | 18 | 19 | 0 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
int main() {
int n;
cin >> n;
rep(i, 10) {
if (n % i == 0 && n / i < 10) {
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
int main() {
int n;
cin >> n;
rep1(i, 10) {
if (n % i == 0 && n / i < 10) {
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}
| replace | 9 | 10 | 9 | 10 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {
if (b > a)
return b;
else
return a;
}
int min(int a, int b) {
if (b < a)
return b;
else
return a;
}
signed main() {
int N;
cin >> N;
rep(i, 10) {
if (N % i)
continue;
else if (N / i < 10) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {
if (b > a)
return b;
else
return a;
}
int min(int a, int b) {
if (b < a)
return b;
else
return a;
}
signed main() {
int N;
cin >> N;
FOR(i, 1, 10) {
if (N % i)
continue;
else if (N / i < 10) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
} | replace | 35 | 36 | 35 | 36 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool flag = false;
for (int i = 0; i < 10; i++) {
if (N % i == 0 && N / i < 10) {
flag = true;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool flag = false;
for (int i = 1; i < 10; i++) {
if (N % i == 0 && N / i < 10) {
flag = true;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | replace | 7 | 8 | 7 | 8 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i * j == n) {
cout << "Yes" << endl;
exit(1);
}
}
}
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i * j == n) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
} | replace | 11 | 12 | 11 | 12 | 1 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool ans = false;
for (int i = 0; i < 10; i++) {
if (N % i == 0 && N / i < 10) {
ans = true;
break;
}
}
if (ans == true) {
cout << "Yes";
} else {
cout << "No";
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
bool ans = false;
for (int i = 1; i < 10; i++) {
if (N % i == 0 && N / i < 10) {
ans = true;
break;
}
}
if (ans == true) {
cout << "Yes";
} else {
cout << "No";
}
return 0;
} | replace | 8 | 9 | 8 | 9 | -8 | |
p02880 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i * j == n) {
cout << "Yes";
exit(1);
}
}
}
cout << "No";
}
| #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i < 10; i++) {
for (int j = 1; j < 10; j++) {
if (i * j == n) {
cout << "Yes";
exit(0);
}
}
}
cout << "No";
}
| replace | 9 | 10 | 9 | 10 | 1 | |
p02880 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main(void) {
int a, b;
int c = 0;
cin >> a;
for (int i = 1; i < 10; ++i) {
for (int ii = 1; i < 10; ++ii) {
if (i * ii == a) {
c = 1;
}
}
}
if (c == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <iostream>
using namespace std;
int main(void) {
int a, b;
int c = 0;
cin >> a;
for (int i = 1; i < 10; i++) {
for (int ii = 1; ii < 10; ii++) {
if (i * ii == a) {
c = 1;
}
}
}
if (c == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | replace | 8 | 10 | 8 | 10 | TLE | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define forn(i, n) for (int i = 0; i < n; i++)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rforn(i, n) for (int i = n; i >= 0; i--)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int search;
cin >> search;
bool done = false;
for (int i = 1; i < 10 && !done; i++) {
if (search % i == 0 && (search / i) <= 9) {
done = true;
}
}
if (done) {
cout << "Yes"
<< "\n";
} else {
cout << "No\n";
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define forn(i, n) for (int i = 0; i < n; i++)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rforn(i, n) for (int i = n; i >= 0; i--)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
int search;
cin >> search;
bool done = false;
for (int i = 1; i < 10 && !done; i++) {
if (search % i == 0 && (search / i) <= 9) {
done = true;
}
}
if (done) {
cout << "Yes"
<< "\n";
} else {
cout << "No\n";
}
return 0;
} | delete | 39 | 43 | 39 | 39 | 0 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
// const ll MOD = ;
ll mod(ll A, ll M) { return (A % M + M) % M; }
const ll INF = 1LL << 60;
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll divceil(ll A, ll B) { return (A + (B - 1)) / B; }
ll myctoi(char C) { return C - '0'; }
char myitoc(ll N) { return '0' + N; }
#define FINALANS(A) \
{ \
cout << (A) << '\n'; \
exit(0); \
}
int main() {
ll N;
cin >> N;
vector<bool> ok(100, false);
for (ll i = 1; i <= 9; i++) {
for (ll j = 1; j <= 9; j++) {
ok.at(i * j) = true;
}
}
cout << ((ok.at(N)) ? "Yes" : "No") << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
// const ll MOD = ;
ll mod(ll A, ll M) { return (A % M + M) % M; }
const ll INF = 1LL << 60;
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll divceil(ll A, ll B) { return (A + (B - 1)) / B; }
ll myctoi(char C) { return C - '0'; }
char myitoc(ll N) { return '0' + N; }
#define FINALANS(A) \
{ \
cout << (A) << '\n'; \
exit(0); \
}
int main() {
ll N;
cin >> N;
vector<bool> ok(1000, false);
for (ll i = 1; i <= 9; i++) {
for (ll j = 1; j <= 9; j++) {
ok.at(i * j) = true;
}
}
cout << ((ok.at(N)) ? "Yes" : "No") << endl;
}
| replace | 35 | 36 | 35 | 36 | 0 | |
p02880 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main(void) {
// Your code here!
int a;
cin >> a;
for (int i = 0; i <= 9; i++) {
if (a % i == 0 && a / i <= 9 && a / i >= 1) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main(void) {
// Your code here!
int a;
cin >> a;
for (int i = 1; i <= 9; i++) {
if (a % i == 0 && a / i <= 9 && a / i >= 1) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
}
| replace | 6 | 7 | 6 | 7 | -8 | |
p02880 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ff(ii, nn, mm) for (int ii = nn; ii < mm; ii++)
#define i64 int64_t
#define tos(x) to_string(x)
int main() {
int n;
cin >> n;
int a = 0;
ff(i, 0, 10) {
a = n / i;
if (a < 10 && n % i == 0) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ff(ii, nn, mm) for (int ii = nn; ii < mm; ii++)
#define i64 int64_t
#define tos(x) to_string(x)
int main() {
int n;
cin >> n;
int a = 0;
ff(i, 1, 10) {
a = n / i;
if (a < 10 && n % i == 0) {
cout << "Yes" << endl;
return 0;
}
}
cout << "No" << endl;
return 0;
} | replace | 17 | 18 | 17 | 18 | -8 | |
p02880 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a[101] = {0};
cin >> n;
for (int i = 0; i < 9; i++) {
for (int j = 0; i < 9; j++) {
a[(i + 1) * (j + 1) - 1]++;
}
}
if (a[n - 1])
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a[101] = {0};
cin >> n;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
a[(i + 1) * (j + 1) - 1]++;
}
}
if (a[n - 1])
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | TLE | |
p02880 | C++ | Time Limit Exceeded | #include <cstdio>
#include <string>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int i;
int j;
bool canflag = false;
for (i = 1; i = 9; i++) {
for (j = 1; j = 9; j++) {
if (n % i == j)
canflag = true;
}
}
if (canflag == true)
printf("Yes");
else
printf("No");
} | #include <cstdio>
#include <string>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int i;
int j;
bool canflag = false;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= 9; j++) {
if (i * j == n)
canflag = true;
}
}
if (canflag == true)
printf("Yes");
else
printf("No");
} | replace | 15 | 18 | 15 | 18 | TLE | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#ifdef __LOCAL
#define DBG(X) cout << #X << " = " << (X) << endl;
#define SAY(X) cout << (X) << endl;
#else
#define DBG(X)
#define SAY(X)
#endif
#ifdef __LOCAL
#include <filesystem>
namespace fs = std::filesystem;
#endif
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int dx[] = {1, 0, -1, 0, 0};
int dy[] = {0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
std::string pad(int num) {
char buffer[4];
std::snprintf(buffer, sizeof(buffer), "%03d", num);
return buffer;
}
inline ll randint(ll a, ll b) {
ll w = (_g() << 31LL) ^ _g();
return a + w % (b - a + 1);
}
inline void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
};
template <typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template <typename T, typename S>
inline ostream &operator<<(ostream &os, const pair<T, S> p) {
cout << "[" << p.first << ";" << p.second << "]";
return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto el : v)
cout << el << " ";
return os;
}
template <typename T> inline T fetch() {
T ret;
cin >> ret;
return ret;
}
template <typename T> inline vector<T> fetch_vec(int sz) {
vector<T> ret(sz);
for (auto &elem : ret)
cin >> elem;
return ret;
}
int main() {
fast_io();
#ifdef __LOCAL
fs::path p = __FILE__;
fs::path input, output;
input = output = p.parent_path();
input += string("/input/") + string(p.stem()) + string(".txt");
output += string("/output/") + string(p.stem()) + string(".txt");
freopen(input.c_str(), "r", stdin);
freopen(output.c_str(), "w", stdout);
#endif
int N;
cin >> N;
FOR(i, 0, 10) if (N % i == 0) {
cout << "Yes" << endl;
return 0;
}
cout << "No" << endl;
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#ifdef __LOCAL
#define DBG(X) cout << #X << " = " << (X) << endl;
#define SAY(X) cout << (X) << endl;
#else
#define DBG(X)
#define SAY(X)
#endif
#ifdef __LOCAL
#include <filesystem>
namespace fs = std::filesystem;
#endif
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int dx[] = {1, 0, -1, 0, 0};
int dy[] = {0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
std::string pad(int num) {
char buffer[4];
std::snprintf(buffer, sizeof(buffer), "%03d", num);
return buffer;
}
inline ll randint(ll a, ll b) {
ll w = (_g() << 31LL) ^ _g();
return a + w % (b - a + 1);
}
inline void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
};
template <typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template <typename T, typename S>
inline ostream &operator<<(ostream &os, const pair<T, S> p) {
cout << "[" << p.first << ";" << p.second << "]";
return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto el : v)
cout << el << " ";
return os;
}
template <typename T> inline T fetch() {
T ret;
cin >> ret;
return ret;
}
template <typename T> inline vector<T> fetch_vec(int sz) {
vector<T> ret(sz);
for (auto &elem : ret)
cin >> elem;
return ret;
}
int main() {
fast_io();
#ifdef __LOCAL
fs::path p = __FILE__;
fs::path input, output;
input = output = p.parent_path();
input += string("/input/") + string(p.stem()) + string(".txt");
output += string("/output/") + string(p.stem()) + string(".txt");
freopen(input.c_str(), "r", stdin);
freopen(output.c_str(), "w", stdout);
#endif
int N;
cin >> N;
if (N <= 10) {
cout << "Yes" << endl;
return 0;
}
FOR(i, 2, 10) if (N % i == 0 & N / i < 10) {
cout << "Yes" << endl;
return 0;
}
cout << "No" << endl;
return 0;
}
| replace | 91 | 92 | 91 | 96 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int num = 0;
for (int i = 1; i < 100; i++) {
if (N != i && N % i == 0) {
num = N / i;
}
}
if (num <= 9 && N / num <= 9) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int num = 0;
for (int i = 1; i <= 9; i++) {
if (N % i == 0) {
num = N / i;
}
}
if (num <= 9 && N / num <= 9) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| replace | 9 | 11 | 9 | 11 | 0 | |
p02880 | C++ | Runtime Error | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define endl "\n"
#define PI acos(-1.0)
#define IOS \
cin.tie(0); \
ios::sync_with_stdio(false)
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#define stoll(argument_string) atoll((argument_string).c_str())
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
#define CIN(x) cin >> (x)
#define CIN2(x, y) cin >> (x) >> (y)
#define CIN3(x, y, z) cin >> (x) >> (y) >> (z)
#define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w)
#define CIN5(x, y, z, w, u) cin >> (x) >> (y) >> (z) >> (w) >> (u)
#define SCAND(x) scanf("%d", &(x))
#define SCAND2(x, y) scanf("%d%d", &(x), &(y))
#define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z))
#define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w))
#define SCAND5(x, y, z, w, u) scanf("%d%d%d%d%d", &(x), &(y), &(z), &(w), &(u))
#define SCANLLD(x) scanf("%lld", &(x))
#define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y))
#define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z))
#define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w))
#define SCANLLD5(x, y, z, w, u) \
scanf("%lld%lld%lld%lld%lld", &(x), &(y), &(z), &(w), &(u))
#define I64DSCAN(x) scanf("%I64d", &(x))
#define I64DSCAN2(x, y) scanf("%I64d%I64d", &(x), &(y))
#define I64DSCAN3(x, y, z) scanf("%I64d%I64d%I64d", &(x), &(y), &(z))
#define I64DSCAN4(x, y, z, w) \
scanf("%I64d%I64d%I64d%I64d", &(x), &(y), &(z), &(w))
#define I64DSCAN5(x, y, z, w, u) \
scanf("%I64d%I64d%I64d%I64d%I64d", &(x), &(y), &(z), &(w), &(u))
#define PRINTD(x) printf("%d\n", (x))
#define PRINTLLD(x) printf("%lld\n", (x))
#define PRINTI64D(x) printf("%I64d\n", (x))
#define DEBUG(argument) cerr << (#argument) << " : " << (argument) << "\n"
typedef long long lli;
typedef unsigned long long ulli;
using namespace std;
int ctoi(char c) {
if (c >= '0' and c <= '9') {
return (int)(c - '0');
}
return -1;
}
int alphabet_pos(char c) {
if (c >= 'a' and c <= 'z') {
return (int)(c - 'a');
}
return -1;
}
int alphabet_pos_capital(char c) {
if (c >= 'A' and c <= 'Z') {
return (int)(c - 'A');
}
return -1;
}
vector<string> split(string str, char ch) {
int first = 0;
int last = str.find_first_of(ch);
if (last == string::npos) {
last = SIZ(str);
}
vector<string> result;
while (first < SIZ(str)) {
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if (last == string::npos) {
last = SIZ(str);
}
}
return result;
}
int gcd(int a, int b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (a == 0) {
return b;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
long long gcd(long long a, long long b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (a == 0LL) {
return b;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long lcm(long long a, long long b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long pow_fast(long long x, long long n_power, long long modulus) {
if (n_power == 0) {
return 1;
}
if (n_power % 2 == 0) {
return pow_fast(x * x % modulus, n_power / 2, modulus);
}
return x * pow_fast(x, n_power - 1, modulus) % modulus;
}
struct CombinationTable {
vector<vector<long long>> val;
CombinationTable(int size)
: val(size + 1, vector<long long>(size + 1)) // constructor
{
for (int i = 0; i <= size; ++i) // note that 0 <= i <= size
{
for (int j = 0; j <= i; ++j) {
if (j == 0 or j == i) {
val[i][j] = 1LL;
} else {
val[i][j] = val[i - 1][j - 1] + val[i - 1][j];
}
}
}
}
};
void print_vector(vector<int> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%d", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_vector(vector<long long> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%lld", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_matrix2D(vector<vector<int>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%d", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<vector<long long>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%lld", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<string> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%c", h[i][j]);
} else {
cerr << h[i][j];
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
void print_binary(int val, int num_digit = 31, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%d", (val >> k) & 1);
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
void print_binary(long long val, int num_digit = 63, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%lld", ((val >> k) & 1));
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
struct UnionFind // size-based
{
vector<int> parent, treesize;
UnionFind(int size)
: parent(size), treesize(size, 1) // constructor
{
for (int i = 0; i < size; ++i) {
parent[i] = i;
}
}
int root(int x) {
if (parent[x] == x) {
return x;
}
return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y) {
return;
}
if (treesize[x] < treesize[y]) {
parent[x] = y;
treesize[y] += treesize[x];
} else {
parent[y] = x;
treesize[x] += treesize[y];
}
}
bool sametree(int x, int y) { return root(x) == root(y); }
int gettreesize(int x) { return treesize[root(x)]; }
};
template <typename Type_value>
struct SegmentTree // Range Minimum Query (RMQ)
{
private:
int n;
vector<Type_value> node;
Type_value identity_element_segmenttree;
public:
SegmentTree(vector<Type_value> v,
Type_value identity_element_st) // constructor
{
int sz = v.size();
identity_element_segmenttree = identity_element_st;
n = 1;
while (n < sz) {
n <<= 1;
}
node.resize(2 * n - 1, identity_element_segmenttree);
for (int i = 0; i < sz; ++i) {
node[i + n - 1] = v[i];
}
for (int i = n - 2; i >= 0; --i) {
node[i] = min(node[2 * i + 1], node[2 * i + 2]);
}
}
void update(int x, Type_value val) {
x += (n - 1);
node[x] = val;
while (x > 0) {
x = (x - 1) / 2;
node[x] = min(node[2 * x + 1], node[2 * x + 2]);
}
}
Type_value getmin(int a, int b, int k = 0, int l = 0,
int r = -1) // getting minimum value in [a,b)
{
// k : index of the referred node
// [l,r) : range covered by the k-th node
if (r < 0) {
r = n;
}
if (r <= a or b <= l) {
return identity_element_segmenttree;
}
if (a <= l and r <= b) {
return node[k];
}
Type_value vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
Type_value vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
return min(vl, vr);
}
};
template <typename Type_value>
struct BinaryIndexedTree // Range Sum Query (RSQ), 0-indexed
{
private:
int size_;
vector<Type_value> data;
public:
BinaryIndexedTree(int sz, Type_value identity_element_binaryindexedtree =
0.0) // constructor
{
size_ = sz;
data.resize(sz + 1, identity_element_binaryindexedtree);
}
Type_value sum(int i) // sum within [0,i)
{
if (i <= 0) {
return (Type_value)0.0;
}
if (i > size_) {
i = size_;
}
Type_value sm = 0.0;
while (i > 0) {
sm += data[i];
i -= i & -i;
}
return sm;
}
void add(int i, Type_value x) {
if (i < 0 or i >= size_) {
return;
}
++i;
while (i <= size_) {
data[i] += x;
i += i & -i;
}
}
};
struct RollingHash {
/*
10 primes near 1e9(for other mod(s)):
{
1000000007,
1000000009,
1000000021,
1000000033,
1000000087,
1000000093,
1000000097,
1000000103,
1000000123,
1000000181
}
10 primes near 1e5(for other base(s)):
{100003,
100019,
100043,
100049,
100057,
100069,
100103,
100109,
100129,
100151}
*/
private:
vector<unsigned long long> hash;
vector<unsigned long long> base_pow;
unsigned long long base, modulus;
const unsigned long long MODULUS_DEFAULT = (1ULL << 61) - 1;
const unsigned long long MASK30 = (1ULL << 30) - 1;
const unsigned long long MASK31 = (1ULL << 31) - 1;
const unsigned long long BASE_MIN = 1e7;
unsigned long long Modulus_2pow61m1(unsigned long long val) {
val = (val & MODULUS_DEFAULT) + (val >> 61);
if (MODULUS_DEFAULT < val) {
val -= MODULUS_DEFAULT;
}
return val;
}
unsigned long long Multiple_2pow61m1(unsigned long long a,
unsigned long long b) {
unsigned long long au = a >> 31;
unsigned long long ad = a & MASK31;
unsigned long long bu = b >> 31;
unsigned long long bd = b & MASK31;
unsigned long long mid = ad * bu + au * bd;
unsigned long long midu = mid >> 30;
unsigned long long midd = mid & MASK30;
return Modulus_2pow61m1(((au * bu) << 1) + midu + (midd << 31) + ad * bd);
}
void initialize(string &S) {
int N = S.size();
vector<int> s(N);
for (int i = 0; i < N; ++i) {
s[i] = S[i];
}
initialize(s);
}
void initialize(vector<int> &S) {
hash.resize(S.size() + 1);
base_pow.resize(S.size() + 1);
hash[0] = 0;
base_pow[0] = 1;
if (modulus == MODULUS_DEFAULT) {
for (int i = 1; i <= S.size(); ++i) {
hash[i] =
Modulus_2pow61m1(Multiple_2pow61m1(hash[i - 1], base) + S[i - 1]);
base_pow[i] = Multiple_2pow61m1(base_pow[i - 1], base);
}
} else {
for (int i = 1; i <= S.size(); ++i) {
hash[i] = (hash[i - 1] * base + S[i - 1]) % modulus;
base_pow[i] = (base_pow[i - 1] * base) % modulus;
}
}
}
public:
RollingHash(string S = "", unsigned long long base_ = 0,
unsigned long long modulus_ = 0) {
if (0 < modulus_) {
modulus = modulus_;
} else {
modulus = MODULUS_DEFAULT;
}
if (0 < base_) {
base = base_;
} else {
mt19937_64 mt64(static_cast<unsigned int>(time(nullptr)));
uniform_int_distribution<unsigned long long> rand_uniform(
BASE_MIN, modulus - BASE_MIN);
base = rand_uniform(mt64);
}
if (S.size() > 0) {
initialize(S);
}
}
// 0-indexed, [a, b)
unsigned long long between(int a, int b) {
if (modulus == MODULUS_DEFAULT) {
return Modulus_2pow61m1(modulus + hash[b] -
Multiple_2pow61m1(hash[a], base_pow[b - a]));
}
return (modulus + hash[b] - (hash[a] * base_pow[b - a]) % modulus) %
modulus;
}
};
/*------------------ the end of the template -----------------------*/
signed main() {
IOS; /* making cin faster */
int N;
SCAND(N);
FOR(n, 1, 10) {
if (N % n == 0) {
int m = N / m;
if (1 <= m and m <= 9) {
puts("Yes");
return 0;
}
}
}
puts("No");
}
| #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define endl "\n"
#define PI acos(-1.0)
#define IOS \
cin.tie(0); \
ios::sync_with_stdio(false)
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#define stoll(argument_string) atoll((argument_string).c_str())
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
#define CIN(x) cin >> (x)
#define CIN2(x, y) cin >> (x) >> (y)
#define CIN3(x, y, z) cin >> (x) >> (y) >> (z)
#define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w)
#define CIN5(x, y, z, w, u) cin >> (x) >> (y) >> (z) >> (w) >> (u)
#define SCAND(x) scanf("%d", &(x))
#define SCAND2(x, y) scanf("%d%d", &(x), &(y))
#define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z))
#define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w))
#define SCAND5(x, y, z, w, u) scanf("%d%d%d%d%d", &(x), &(y), &(z), &(w), &(u))
#define SCANLLD(x) scanf("%lld", &(x))
#define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y))
#define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z))
#define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w))
#define SCANLLD5(x, y, z, w, u) \
scanf("%lld%lld%lld%lld%lld", &(x), &(y), &(z), &(w), &(u))
#define I64DSCAN(x) scanf("%I64d", &(x))
#define I64DSCAN2(x, y) scanf("%I64d%I64d", &(x), &(y))
#define I64DSCAN3(x, y, z) scanf("%I64d%I64d%I64d", &(x), &(y), &(z))
#define I64DSCAN4(x, y, z, w) \
scanf("%I64d%I64d%I64d%I64d", &(x), &(y), &(z), &(w))
#define I64DSCAN5(x, y, z, w, u) \
scanf("%I64d%I64d%I64d%I64d%I64d", &(x), &(y), &(z), &(w), &(u))
#define PRINTD(x) printf("%d\n", (x))
#define PRINTLLD(x) printf("%lld\n", (x))
#define PRINTI64D(x) printf("%I64d\n", (x))
#define DEBUG(argument) cerr << (#argument) << " : " << (argument) << "\n"
typedef long long lli;
typedef unsigned long long ulli;
using namespace std;
int ctoi(char c) {
if (c >= '0' and c <= '9') {
return (int)(c - '0');
}
return -1;
}
int alphabet_pos(char c) {
if (c >= 'a' and c <= 'z') {
return (int)(c - 'a');
}
return -1;
}
int alphabet_pos_capital(char c) {
if (c >= 'A' and c <= 'Z') {
return (int)(c - 'A');
}
return -1;
}
vector<string> split(string str, char ch) {
int first = 0;
int last = str.find_first_of(ch);
if (last == string::npos) {
last = SIZ(str);
}
vector<string> result;
while (first < SIZ(str)) {
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if (last == string::npos) {
last = SIZ(str);
}
}
return result;
}
int gcd(int a, int b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (a == 0) {
return b;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
long long gcd(long long a, long long b) // assuming a,b >= 1
{
if (a < b) {
swap(a, b);
}
if (a == 0LL) {
return b;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long lcm(long long a, long long b) // assuming a,b >= 1
{
return a * b / gcd(a, b);
}
long long pow_fast(long long x, long long n_power, long long modulus) {
if (n_power == 0) {
return 1;
}
if (n_power % 2 == 0) {
return pow_fast(x * x % modulus, n_power / 2, modulus);
}
return x * pow_fast(x, n_power - 1, modulus) % modulus;
}
struct CombinationTable {
vector<vector<long long>> val;
CombinationTable(int size)
: val(size + 1, vector<long long>(size + 1)) // constructor
{
for (int i = 0; i <= size; ++i) // note that 0 <= i <= size
{
for (int j = 0; j <= i; ++j) {
if (j == 0 or j == i) {
val[i][j] = 1LL;
} else {
val[i][j] = val[i - 1][j - 1] + val[i - 1][j];
}
}
}
}
};
void print_vector(vector<int> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%d", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_vector(vector<long long> h, bool verbose = true) {
int L = h.size();
for (int i = 0; i < L; ++i) {
if (verbose) {
printf("%lld", h[i]);
} else {
cerr << h[i];
}
if (i != L - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
void print_matrix2D(vector<vector<int>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%d", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<vector<long long>> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%lld", h[i][j]);
} else {
cerr << h[i][j];
}
if (j != Lx - 1) {
if (verbose) {
printf(" ");
} else {
cerr << " ";
}
} else {
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
}
}
void print_matrix2D(vector<string> h, bool verbose = true) {
int Ly = h.size();
for (int i = 0; i < Ly; ++i) {
int Lx = h[i].size();
for (int j = 0; j < Lx; ++j) {
if (verbose) {
printf("%c", h[i][j]);
} else {
cerr << h[i][j];
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
}
void print_binary(int val, int num_digit = 31, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%d", (val >> k) & 1);
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
void print_binary(long long val, int num_digit = 63, bool verbose = false) {
for (int k = num_digit - 1; k >= 0; --k) {
if (verbose) {
printf("%lld", ((val >> k) & 1));
} else {
cerr << ((val >> k) & 1);
}
}
if (verbose) {
printf("\n");
} else {
cerr << "\n";
}
}
struct UnionFind // size-based
{
vector<int> parent, treesize;
UnionFind(int size)
: parent(size), treesize(size, 1) // constructor
{
for (int i = 0; i < size; ++i) {
parent[i] = i;
}
}
int root(int x) {
if (parent[x] == x) {
return x;
}
return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y) {
return;
}
if (treesize[x] < treesize[y]) {
parent[x] = y;
treesize[y] += treesize[x];
} else {
parent[y] = x;
treesize[x] += treesize[y];
}
}
bool sametree(int x, int y) { return root(x) == root(y); }
int gettreesize(int x) { return treesize[root(x)]; }
};
template <typename Type_value>
struct SegmentTree // Range Minimum Query (RMQ)
{
private:
int n;
vector<Type_value> node;
Type_value identity_element_segmenttree;
public:
SegmentTree(vector<Type_value> v,
Type_value identity_element_st) // constructor
{
int sz = v.size();
identity_element_segmenttree = identity_element_st;
n = 1;
while (n < sz) {
n <<= 1;
}
node.resize(2 * n - 1, identity_element_segmenttree);
for (int i = 0; i < sz; ++i) {
node[i + n - 1] = v[i];
}
for (int i = n - 2; i >= 0; --i) {
node[i] = min(node[2 * i + 1], node[2 * i + 2]);
}
}
void update(int x, Type_value val) {
x += (n - 1);
node[x] = val;
while (x > 0) {
x = (x - 1) / 2;
node[x] = min(node[2 * x + 1], node[2 * x + 2]);
}
}
Type_value getmin(int a, int b, int k = 0, int l = 0,
int r = -1) // getting minimum value in [a,b)
{
// k : index of the referred node
// [l,r) : range covered by the k-th node
if (r < 0) {
r = n;
}
if (r <= a or b <= l) {
return identity_element_segmenttree;
}
if (a <= l and r <= b) {
return node[k];
}
Type_value vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
Type_value vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
return min(vl, vr);
}
};
template <typename Type_value>
struct BinaryIndexedTree // Range Sum Query (RSQ), 0-indexed
{
private:
int size_;
vector<Type_value> data;
public:
BinaryIndexedTree(int sz, Type_value identity_element_binaryindexedtree =
0.0) // constructor
{
size_ = sz;
data.resize(sz + 1, identity_element_binaryindexedtree);
}
Type_value sum(int i) // sum within [0,i)
{
if (i <= 0) {
return (Type_value)0.0;
}
if (i > size_) {
i = size_;
}
Type_value sm = 0.0;
while (i > 0) {
sm += data[i];
i -= i & -i;
}
return sm;
}
void add(int i, Type_value x) {
if (i < 0 or i >= size_) {
return;
}
++i;
while (i <= size_) {
data[i] += x;
i += i & -i;
}
}
};
struct RollingHash {
/*
10 primes near 1e9(for other mod(s)):
{
1000000007,
1000000009,
1000000021,
1000000033,
1000000087,
1000000093,
1000000097,
1000000103,
1000000123,
1000000181
}
10 primes near 1e5(for other base(s)):
{100003,
100019,
100043,
100049,
100057,
100069,
100103,
100109,
100129,
100151}
*/
private:
vector<unsigned long long> hash;
vector<unsigned long long> base_pow;
unsigned long long base, modulus;
const unsigned long long MODULUS_DEFAULT = (1ULL << 61) - 1;
const unsigned long long MASK30 = (1ULL << 30) - 1;
const unsigned long long MASK31 = (1ULL << 31) - 1;
const unsigned long long BASE_MIN = 1e7;
unsigned long long Modulus_2pow61m1(unsigned long long val) {
val = (val & MODULUS_DEFAULT) + (val >> 61);
if (MODULUS_DEFAULT < val) {
val -= MODULUS_DEFAULT;
}
return val;
}
unsigned long long Multiple_2pow61m1(unsigned long long a,
unsigned long long b) {
unsigned long long au = a >> 31;
unsigned long long ad = a & MASK31;
unsigned long long bu = b >> 31;
unsigned long long bd = b & MASK31;
unsigned long long mid = ad * bu + au * bd;
unsigned long long midu = mid >> 30;
unsigned long long midd = mid & MASK30;
return Modulus_2pow61m1(((au * bu) << 1) + midu + (midd << 31) + ad * bd);
}
void initialize(string &S) {
int N = S.size();
vector<int> s(N);
for (int i = 0; i < N; ++i) {
s[i] = S[i];
}
initialize(s);
}
void initialize(vector<int> &S) {
hash.resize(S.size() + 1);
base_pow.resize(S.size() + 1);
hash[0] = 0;
base_pow[0] = 1;
if (modulus == MODULUS_DEFAULT) {
for (int i = 1; i <= S.size(); ++i) {
hash[i] =
Modulus_2pow61m1(Multiple_2pow61m1(hash[i - 1], base) + S[i - 1]);
base_pow[i] = Multiple_2pow61m1(base_pow[i - 1], base);
}
} else {
for (int i = 1; i <= S.size(); ++i) {
hash[i] = (hash[i - 1] * base + S[i - 1]) % modulus;
base_pow[i] = (base_pow[i - 1] * base) % modulus;
}
}
}
public:
RollingHash(string S = "", unsigned long long base_ = 0,
unsigned long long modulus_ = 0) {
if (0 < modulus_) {
modulus = modulus_;
} else {
modulus = MODULUS_DEFAULT;
}
if (0 < base_) {
base = base_;
} else {
mt19937_64 mt64(static_cast<unsigned int>(time(nullptr)));
uniform_int_distribution<unsigned long long> rand_uniform(
BASE_MIN, modulus - BASE_MIN);
base = rand_uniform(mt64);
}
if (S.size() > 0) {
initialize(S);
}
}
// 0-indexed, [a, b)
unsigned long long between(int a, int b) {
if (modulus == MODULUS_DEFAULT) {
return Modulus_2pow61m1(modulus + hash[b] -
Multiple_2pow61m1(hash[a], base_pow[b - a]));
}
return (modulus + hash[b] - (hash[a] * base_pow[b - a]) % modulus) %
modulus;
}
};
/*------------------ the end of the template -----------------------*/
signed main() {
IOS; /* making cin faster */
int N;
SCAND(N);
FOR(n, 1, 10) {
if (N % n == 0) {
int m = N / n;
if (1 <= m and m <= 9) {
puts("Yes");
return 0;
}
}
}
puts("No");
}
| replace | 715 | 716 | 715 | 716 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string ans = "No\n";
for (int i = 0; i < 10; i++) {
if (N % i == 0 && N / i < 10) {
ans = "Yes\n";
break;
}
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string ans = "No\n";
for (int i = 1; i < 10; i++) {
if (N % i == 0 && N / i < 10) {
ans = "Yes\n";
break;
}
}
cout << ans;
} | replace | 6 | 7 | 6 | 7 | -8 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<bool>> name((h), vector<bool>(w));
#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v) \
cerr << "["; \
REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); } \
cerr << "]" << endl
signed main() {
int N;
cin >> N;
vector<int> v(100);
FOR1(x, 9) {
FOR1(y, 9) { v.at(x * y) = true; }
}
cout << (v.at(N) ? "Yes" : "No") << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<bool>> name((h), vector<bool>(w));
#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v) \
cerr << "["; \
REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); } \
cerr << "]" << endl
signed main() {
int N;
cin >> N;
vector<int> v(105);
FOR1(x, 9) {
FOR1(y, 9) { v.at(x * y) = true; }
}
cout << (v.at(N) ? "Yes" : "No") << endl;
}
| replace | 24 | 25 | 24 | 25 | 0 | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i, s, e) for (i = s; i < e; i++)
#define ms(arr, val) memset(arr, val, sizeof(arr))
using namespace std;
const int mxn = 2e5 + 1;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("outputs.txt", "w", stdout);
#endif
int t = 1;
// cin>>t;
int tt = 1;
while (t--) {
int n;
cin >> n;
for (int i = 1; i <= 9; i++) {
if (n % i == 0) {
int a = n / i;
if (a <= 9) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
// cout<<"Case #"<<tt<<": ";
// tt++;
}
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i, s, e) for (i = s; i < e; i++)
#define ms(arr, val) memset(arr, val, sizeof(arr))
using namespace std;
const int mxn = 2e5 + 1;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
int tt = 1;
while (t--) {
int n;
cin >> n;
for (int i = 1; i <= 9; i++) {
if (n % i == 0) {
int a = n / i;
if (a <= 9) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
// cout<<"Case #"<<tt<<": ";
// tt++;
}
return 0;
}
| replace | 16 | 20 | 16 | 17 | 0 | |
p02880 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define ll long long
#define itn int
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FFOR(i, 1, n)
#define SORT(V) sort((V).begin(), (V).end())
#define REVERSE(V) reverse((V).begin(), (V).end())
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
int main() {
int N;
cin >> N;
bool CAN = false;
for (int i = 1; i < 10; ++i) {
for (int j = 1; i < 10; ++j) {
if (i * j == N)
CAN = true;
}
}
if (CAN)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define ll long long
#define itn int
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FFOR(i, 1, n)
#define SORT(V) sort((V).begin(), (V).end())
#define REVERSE(V) reverse((V).begin(), (V).end())
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
int main() {
int N;
cin >> N;
bool CAN = false;
for (int i = 1; i < 10; ++i) {
for (int j = 1; j < 10; ++j) {
if (i * j == N)
CAN = true;
}
}
if (CAN)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| replace | 26 | 27 | 26 | 27 | TLE | |
p02880 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main(void) {
int a = 0, N;
cin >> N;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
while (N == i * j) {
a++;
}
}
}
if (a == 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
} | #include <iostream>
using namespace std;
int main(void) {
int a = 0, N;
cin >> N;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
if (N == i * j) {
a++;
}
}
}
if (a == 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
| replace | 7 | 8 | 7 | 8 | TLE | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#include <algorithm>
int main() {
int N = 81;
int a[N];
rep(i, N) {
rep(j, N) { a[N * i + j] = (i + 1) * (j + 1); }
}
int tf = 0;
int x;
cin >> x;
rep(i, N * N) {
if (x == a[i]) {
tf = 1;
}
}
if (tf == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#include <algorithm>
int main() {
int N = 9;
int a[N * N];
rep(i, N) {
rep(j, N) { a[N * i + j] = (i + 1) * (j + 1); }
}
int tf = 0;
int x;
cin >> x;
rep(i, N * N) {
if (x == a[i]) {
tf = 1;
}
}
if (tf == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| replace | 7 | 9 | 7 | 9 | -11 | |
p02880 | Python | Runtime Error | n = int(input().split())
a = []
for i in range(1, 10):
for j in range(1, 10):
a.append(i * j)
if n in a:
print("Yes")
else:
print("No")
| n = int(input())
a = []
for i in range(1, 10):
for j in range(1, 10):
a.append(i * j)
if n in a:
print("Yes")
else:
print("No")
| replace | 0 | 1 | 0 | 1 | TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02880/Python/s433972108.py", line 1, in <module>
n = int(input().split())
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
|
p02880 | Python | Runtime Error | N = int(input())
for i in range(1, 10):
if N % i == 0 and N / i <= 9:
print("Yes")
exit(1)
print("No")
| N = int(input())
for i in range(1, 10):
if N % i == 0 and N / i <= 9:
print("Yes")
exit()
print("No")
| replace | 5 | 6 | 5 | 6 | 1 | |
p02880 | Python | Runtime Error | n = int(input())
if n > 81:
print("No")
else:
is_ok = False
for x in range(1, 10):
if n % x == 0 and n // x <= 9:
is_ok = True
break
if is_ok:
print("Yes")
else:
print("No")
| n = int(input())
if n > 81:
print("No")
else:
is_ok = False
for x in range(1, 10):
if n % x == 0 and n // x <= 9:
is_ok = True
break
if is_ok:
print("Yes")
else:
print("No")
| replace | 9 | 14 | 9 | 13 | 0 | |
p02880 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
bool flag = false;
for (int i = 1; i < 100; i++) {
for (int k = 1; k < 100; i++) {
if (n == (i * k)) {
flag = true;
}
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
bool flag = false;
for (int i = 1; i < 10; i++) {
for (int k = 1; k < 10; k++) {
if (n == (i * k)) {
flag = true;
}
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | replace | 11 | 13 | 11 | 13 | TLE | |
p02880 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T> using pvector = vector<pair<T, T>>;
template <class T>
using rpriority_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr const ll dx[4] = {1, 0, -1, 0};
constexpr const ll dy[4] = {0, 1, 0, -1};
constexpr const ll MOD = 1e9 + 7;
constexpr const ll mod = 998244353;
constexpr const ll INF = 1LL << 60;
constexpr const ll inf = 1 << 30;
constexpr const char rt = '\n';
constexpr const char sp = ' ';
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define elif else if
#define all(a, v, ...) \
([&](decltype((v)) w) { return (a)(begin(w), end(w), ##__VA_ARGS__); })(v)
#define rall(a, v, ...) \
([&](decltype((v)) w) { return (a)(rbegin(w), rend(w), ##__VA_ARGS__); })(v)
#define fi first
#define se second
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
// Debug
#define debug(...) \
{ \
cerr << __LINE__ << ": " << #__VA_ARGS__ << " = "; \
for (auto &&X : {__VA_ARGS__}) \
cerr << "[" << X << "] "; \
cerr << rt; \
}
#define dump(a, h, w) \
{ \
cerr << __LINE__ << ": " << #a << " = [" << rt; \
rep(_i, h) { \
rep(_j, w) cerr << a[_i][_j] << sp; \
cerr << rt; \
} \
cerr << "]" << rt; \
}
#define vdump(a, n) \
{ \
cerr << __LINE__ << ": " << #a << " = ["; \
rep(_i, n) if (_i) cerr << sp << a[_i]; \
else cerr << a[_i]; \
cerr << "]" << rt; \
}
// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) for (ll i = 0, _##i = (n); i < _##i; ++i)
#define each(i, a) for (auto &&i : a)
// Stream
#define fout(n) cout << fixed << setprecision(n)
struct io {
io() { cin.tie(nullptr), ios::sync_with_stdio(false); }
} io;
// Speed
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// Math
inline constexpr ll gcd(const ll a, const ll b) {
return b ? gcd(b, a % b) : a;
}
inline constexpr ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
inline constexpr ll modulo(const ll n, const ll m = MOD) {
ll k = n % m;
return k + m * (k < 0);
}
inline constexpr ll chmod(ll &n, const ll m = MOD) {
n %= m;
return n += m * (n < 0);
}
inline constexpr ll mpow(ll a, ll n, const ll m = MOD) {
ll r = 1;
rep(i, 64) {
if (n & (1LL << i))
r *= a;
chmod(r, m);
a *= a;
chmod(a, m);
}
return r;
}
inline ll inv(const ll n, const ll m = MOD) {
ll a = n, b = m, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return modulo(x, m);
}
class WarshallFloyd {
private:
const ll n;
vector<vector<ll>> d;
public:
WarshallFloyd(ll _n) : n(_n), d(_n, vector<ll>(_n)) {
rep(i, n) rep(j, n) { d[i][j] = (i == j ? 0 : INF); }
}
// directed
void setDist(ll i, ll j, ll c) { d[i][j] = c; }
ll getDist(ll i, ll j) { return d[i][j]; }
void calc() {
rep(k, n) rep(i, n) rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
dump(d, n, n);
}
};
signed main() {
ll N;
cin >> N;
rep(i, 9) if (N % i == 0 and N / i < 10) return puts("Yes") & 0;
puts("No");
}
// -g -D_GLIBCXX_DEBUG -fsanitize=undefined
| #include <bits/stdc++.h>
using namespace std;
// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T> using pvector = vector<pair<T, T>>;
template <class T>
using rpriority_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr const ll dx[4] = {1, 0, -1, 0};
constexpr const ll dy[4] = {0, 1, 0, -1};
constexpr const ll MOD = 1e9 + 7;
constexpr const ll mod = 998244353;
constexpr const ll INF = 1LL << 60;
constexpr const ll inf = 1 << 30;
constexpr const char rt = '\n';
constexpr const char sp = ' ';
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define elif else if
#define all(a, v, ...) \
([&](decltype((v)) w) { return (a)(begin(w), end(w), ##__VA_ARGS__); })(v)
#define rall(a, v, ...) \
([&](decltype((v)) w) { return (a)(rbegin(w), rend(w), ##__VA_ARGS__); })(v)
#define fi first
#define se second
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
// Debug
#define debug(...) \
{ \
cerr << __LINE__ << ": " << #__VA_ARGS__ << " = "; \
for (auto &&X : {__VA_ARGS__}) \
cerr << "[" << X << "] "; \
cerr << rt; \
}
#define dump(a, h, w) \
{ \
cerr << __LINE__ << ": " << #a << " = [" << rt; \
rep(_i, h) { \
rep(_j, w) cerr << a[_i][_j] << sp; \
cerr << rt; \
} \
cerr << "]" << rt; \
}
#define vdump(a, n) \
{ \
cerr << __LINE__ << ": " << #a << " = ["; \
rep(_i, n) if (_i) cerr << sp << a[_i]; \
else cerr << a[_i]; \
cerr << "]" << rt; \
}
// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) for (ll i = 0, _##i = (n); i < _##i; ++i)
#define each(i, a) for (auto &&i : a)
// Stream
#define fout(n) cout << fixed << setprecision(n)
struct io {
io() { cin.tie(nullptr), ios::sync_with_stdio(false); }
} io;
// Speed
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// Math
inline constexpr ll gcd(const ll a, const ll b) {
return b ? gcd(b, a % b) : a;
}
inline constexpr ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
inline constexpr ll modulo(const ll n, const ll m = MOD) {
ll k = n % m;
return k + m * (k < 0);
}
inline constexpr ll chmod(ll &n, const ll m = MOD) {
n %= m;
return n += m * (n < 0);
}
inline constexpr ll mpow(ll a, ll n, const ll m = MOD) {
ll r = 1;
rep(i, 64) {
if (n & (1LL << i))
r *= a;
chmod(r, m);
a *= a;
chmod(a, m);
}
return r;
}
inline ll inv(const ll n, const ll m = MOD) {
ll a = n, b = m, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return modulo(x, m);
}
class WarshallFloyd {
private:
const ll n;
vector<vector<ll>> d;
public:
WarshallFloyd(ll _n) : n(_n), d(_n, vector<ll>(_n)) {
rep(i, n) rep(j, n) { d[i][j] = (i == j ? 0 : INF); }
}
// directed
void setDist(ll i, ll j, ll c) { d[i][j] = c; }
ll getDist(ll i, ll j) { return d[i][j]; }
void calc() {
rep(k, n) rep(i, n) rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
dump(d, n, n);
}
};
signed main() {
ll N;
cin >> N;
rep(i, 9) if (N % (i + 1) == 0 and N / (i + 1) < 10) return puts("Yes") & 0;
puts("No");
}
// -g -D_GLIBCXX_DEBUG -fsanitize=undefined
| replace | 146 | 147 | 146 | 147 | -4 | |
p02881 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(void) {
ll n;
cin >> n;
ll mn = LLONG_MAX;
for (ll i = 1; i <= n / 2; i++) {
if (n % i == 0) {
ll a = i - 1, b = n / i - 1;
mn = min(mn, a + b);
}
}
cout << mn << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(void) {
ll n;
cin >> n;
ll mn = LLONG_MAX;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ll a = i - 1, b = n / i - 1;
mn = min(mn, a + b);
}
}
cout << mn << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | TLE | |
p02881 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e12;
using namespace std;
int main() {
ll n;
cin >> n;
ll ans = INF;
for (ll i = 1; i <= n / 2; i++) {
if (n % i == 0) {
ans = min(ans, i + n / i - 2);
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e12;
using namespace std;
int main() {
ll n;
cin >> n;
ll ans = INF;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ans = min(ans, i + n / i - 2);
}
}
cout << ans << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | TLE | |
p02881 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define REP(i, s, N) for (int i = s; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;
ll ans = 0;
int main() {
ll N;
cin >> N;
REP(i, 1, N / 2 + 1) {
if (N % i == 0) {
if (N / i - i >= 0) {
ans = i + N / i - 2;
} else {
break;
}
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define REP(i, s, N) for (int i = s; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;
ll ans = 0;
int main() {
ll N;
cin >> N;
REP(i, 1, sqrt(N) + 1) {
if (N % i == 0) {
if (N / i - i >= 0) {
ans = i + N / i - 2;
} else {
break;
}
}
}
cout << ans << endl;
return 0;
} | replace | 13 | 14 | 13 | 14 | TLE | |
p02881 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main() {
long long int i, j, v, count = 1000000000000;
long long int a = 0;
cin >> v;
for (i = 1; i <= v / 2; i++) {
if (v % i == 0) {
a = 0;
a += (v / i - 1 + i - 1);
count = min(count, a);
}
}
cout << count << endl;
} | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main() {
long long int i, j, v, count = 1000000000000;
long long int a = 0;
cin >> v;
for (i = 1; i * i <= v; i++) {
if (v % i == 0) {
a = 0;
a += (v / i - 1 + i - 1);
count = min(count, a);
}
}
cout << count << endl;
} | replace | 16 | 17 | 16 | 17 | TLE | |
p02881 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
#define ll long long
const int N = 1e6 + 10;
using namespace std;
ll n;
int main() {
cin >> n;
ll ans = n + 1;
for (int i = 1; i * i < n; i++) {
if (n % i == 0) {
ans = min(ans, i + n / i - 2);
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
#define ll long long
const int N = 1e6 + 10;
using namespace std;
ll n;
int main() {
cin >> n;
ll ans = n + 1;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ans = min(ans, i + n / i - 2);
}
}
cout << ans << endl;
return 0;
} | replace | 16 | 17 | 16 | 17 | TLE | |
p02881 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = n - 1;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ans = min(ans, i + (n / i) - 2);
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = n - 1;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ans = min(ans, i + (n / i) - 2);
}
}
cout << ans << endl;
return 0;
} | replace | 22 | 23 | 22 | 23 | TLE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.