QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#228274 | #7642. Integer Half-Sum | ucup-team088# | AC ✓ | 5ms | 11864kb | C++17 | 6.4kb | 2023-10-28 13:16:22 | 2023-10-28 13:16:23 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
#include<chrono>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
//ll mod = 1;
constexpr ll mod = 998244353;
//constexpr ll mod = 1000000007;
const int mod17 = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
using ld = double;
typedef pair<ld, ld> LDP;
const ld eps = 1e-10;
const ld pi = acosl(-1.0);
template<typename T>
void chmin(T& a, T b) {
a = min(a, b);
}
template<typename T>
void chmax(T& a, T b) {
a = max(a, b);
}
template<typename T>
vector<T> vmerge(vector<T>& a, vector<T>& b) {
vector<T> res;
int ida = 0, idb = 0;
while (ida < a.size() || idb < b.size()) {
if (idb == b.size()) {
res.push_back(a[ida]); ida++;
}
else if (ida == a.size()) {
res.push_back(b[idb]); idb++;
}
else {
if (a[ida] < b[idb]) {
res.push_back(a[ida]); ida++;
}
else {
res.push_back(b[idb]); idb++;
}
}
}
return res;
}
template<typename T>
void cinarray(vector<T>& v) {
rep(i, v.size())cin >> v[i];
}
template<typename T>
void coutarray(vector<T>& v) {
rep(i, v.size()) {
if (i > 0)cout << " "; cout << v[i];
}
cout << "\n";
}
ll mod_pow(ll x, ll n, ll m = mod) {
if (n < 0) {
ll res = mod_pow(x, -n, m);
return mod_pow(res, m - 2, m);
}
if (abs(x) >= m)x %= m;
if (x < 0)x += m;
//if (x == 0)return 0;
ll res = 1;
while (n) {
if (n & 1)res = res * x % m;
x = x * x % m; n >>= 1;
}
return res;
}
//mod should be <2^31
struct modint {
int n;
modint() :n(0) { ; }
modint(ll m) {
if (m < 0 || mod <= m) {
m %= mod; if (m < 0)m += mod;
}
n = m;
}
operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
bool operator<(modint a, modint b) { return a.n < b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= (int)mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += (int)mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
if (n == 0)return modint(1);
modint res = (a * a) ^ (n / 2);
if (n % 2)res = res * a;
return res;
}
ll inv(ll a, ll p) {
return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
fact[0] = modint(1);
for (int i = 0; i < max_n - 1; i++) {
fact[i + 1] = fact[i] * modint(i + 1);
}
factinv[max_n - 1] = modint(1) / fact[max_n - 1];
for (int i = max_n - 2; i >= 0; i--) {
factinv[i] = factinv[i + 1] * modint(i + 1);
}
}
modint comb(int a, int b) {
if (a < 0 || b < 0 || a < b)return 0;
return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
if (a < 0 || b < 0 || a < b)return 0;
return fact[a] * factinv[a - b];
}
ll gcd(ll a, ll b) {
a = abs(a); b = abs(b);
if (a < b)swap(a, b);
while (b) {
ll r = a % b; a = b; b = r;
}
return a;
}
template<typename T>
void addv(vector<T>& v, int loc, T val) {
if (loc >= v.size())v.resize(loc + 1, 0);
v[loc] += val;
}
/*const int mn = 2000005;
bool isp[mn];
vector<int> ps;
void init() {
fill(isp + 2, isp + mn, true);
for (int i = 2; i < mn; i++) {
if (!isp[i])continue;
ps.push_back(i);
for (int j = 2 * i; j < mn; j += i) {
isp[j] = false;
}
}
}*/
//[,val)
template<typename T>
auto prev_itr(set<T>& st, T val) {
auto res = st.lower_bound(val);
if (res == st.begin())return st.end();
res--; return res;
}
//[val,)
template<typename T>
auto next_itr(set<T>& st, T val) {
auto res = st.lower_bound(val);
return res;
}
using mP = pair<modint, modint>;
mP operator+(mP a, mP b) {
return { a.first + b.first,a.second + b.second };
}
mP operator+=(mP& a, mP b) {
a = a + b; return a;
}
mP operator-(mP a, mP b) {
return { a.first - b.first,a.second - b.second };
}
mP operator-=(mP& a, mP b) {
a = a - b; return a;
}
LP operator+(LP a, LP b) {
return { a.first + b.first,a.second + b.second };
}
LP operator+=(LP& a, LP b) {
a = a + b; return a;
}
LP operator-(LP a, LP b) {
return { a.first - b.first,a.second - b.second };
}
LP operator-=(LP& a, LP b) {
a = a - b; return a;
}
mt19937 mt(time(0));
const string drul = "DRUL";
string senw = "SENW";
//DRUL,or SENW
//int dx[4] = { 1,0,-1,0 };
//int dy[4] = { 0,1,0,-1 };
//------------------------------------
void solve() {
int l, r; cin >> l >> r;
if (l == r) {
cout << r << '\n';
}
else if (l + 1 == r) {
cout << -1 << "\n";
}
else {
cout << r - 1 << "\n";
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
//cout << fixed<<setprecision(10);
//init_f();
//init();
//init2();
//while(true)
//expr();
//int t; cin >> t; rep(i, t)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 11724kb
input:
2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 5ms
memory: 11684kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 5ms
memory: 11864kb
input:
1 2
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 5ms
memory: 11844kb
input:
100 100
output:
100
result:
ok 1 number(s): "100"
Test #5:
score: 0
Accepted
time: 5ms
memory: 11680kb
input:
99 100
output:
-1
result:
ok 1 number(s): "-1"
Test #6:
score: 0
Accepted
time: 5ms
memory: 11736kb
input:
3 3
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 5ms
memory: 11836kb
input:
2 3
output:
-1
result:
ok 1 number(s): "-1"
Test #8:
score: 0
Accepted
time: 5ms
memory: 11672kb
input:
1 3
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 2ms
memory: 11672kb
input:
2 5
output:
4
result:
ok 1 number(s): "4"
Test #10:
score: 0
Accepted
time: 0ms
memory: 11640kb
input:
3 7
output:
6
result:
ok 1 number(s): "6"
Test #11:
score: 0
Accepted
time: 5ms
memory: 11688kb
input:
3 8
output:
7
result:
ok 1 number(s): "7"
Test #12:
score: 0
Accepted
time: 0ms
memory: 11860kb
input:
4 10
output:
9
result:
ok 1 number(s): "9"
Test #13:
score: 0
Accepted
time: 5ms
memory: 11640kb
input:
35 37
output:
36
result:
ok 1 number(s): "36"
Test #14:
score: 0
Accepted
time: 2ms
memory: 11672kb
input:
43 46
output:
45
result:
ok 1 number(s): "45"
Test #15:
score: 0
Accepted
time: 0ms
memory: 11676kb
input:
82 86
output:
85
result:
ok 1 number(s): "85"
Test #16:
score: 0
Accepted
time: 5ms
memory: 11676kb
input:
55 60
output:
59
result:
ok 1 number(s): "59"
Test #17:
score: 0
Accepted
time: 5ms
memory: 11852kb
input:
25 31
output:
30
result:
ok 1 number(s): "30"
Test #18:
score: 0
Accepted
time: 5ms
memory: 11692kb
input:
37 44
output:
43
result:
ok 1 number(s): "43"
Test #19:
score: 0
Accepted
time: 5ms
memory: 11620kb
input:
75 83
output:
82
result:
ok 1 number(s): "82"
Test #20:
score: 0
Accepted
time: 0ms
memory: 11684kb
input:
74 83
output:
82
result:
ok 1 number(s): "82"
Test #21:
score: 0
Accepted
time: 0ms
memory: 11848kb
input:
88 98
output:
97
result:
ok 1 number(s): "97"
Test #22:
score: 0
Accepted
time: 5ms
memory: 11684kb
input:
75 86
output:
85
result:
ok 1 number(s): "85"
Test #23:
score: 0
Accepted
time: 5ms
memory: 11704kb
input:
1 100
output:
99
result:
ok 1 number(s): "99"
Test #24:
score: 0
Accepted
time: 0ms
memory: 11848kb
input:
1 50
output:
49
result:
ok 1 number(s): "49"
Test #25:
score: 0
Accepted
time: 5ms
memory: 11696kb
input:
50 100
output:
99
result:
ok 1 number(s): "99"
Test #26:
score: 0
Accepted
time: 0ms
memory: 11688kb
input:
7 35
output:
34
result:
ok 1 number(s): "34"
Test #27:
score: 0
Accepted
time: 0ms
memory: 11796kb
input:
87 95
output:
94
result:
ok 1 number(s): "94"
Test #28:
score: 0
Accepted
time: 0ms
memory: 11692kb
input:
11 30
output:
29
result:
ok 1 number(s): "29"
Test #29:
score: 0
Accepted
time: 4ms
memory: 11692kb
input:
47 69
output:
68
result:
ok 1 number(s): "68"
Test #30:
score: 0
Accepted
time: 0ms
memory: 11684kb
input:
11 48
output:
47
result:
ok 1 number(s): "47"
Test #31:
score: 0
Accepted
time: 2ms
memory: 11676kb
input:
71 85
output:
84
result:
ok 1 number(s): "84"
Test #32:
score: 0
Accepted
time: 0ms
memory: 11852kb
input:
84 89
output:
88
result:
ok 1 number(s): "88"
Test #33:
score: 0
Accepted
time: 0ms
memory: 11736kb
input:
22 56
output:
55
result:
ok 1 number(s): "55"
Test #34:
score: 0
Accepted
time: 5ms
memory: 11620kb
input:
2 72
output:
71
result:
ok 1 number(s): "71"
Test #35:
score: 0
Accepted
time: 2ms
memory: 11644kb
input:
18 55
output:
54
result:
ok 1 number(s): "54"
Test #36:
score: 0
Accepted
time: 5ms
memory: 11700kb
input:
4 11
output:
10
result:
ok 1 number(s): "10"
Test #37:
score: 0
Accepted
time: 5ms
memory: 11728kb
input:
42 59
output:
58
result:
ok 1 number(s): "58"
Test #38:
score: 0
Accepted
time: 2ms
memory: 11672kb
input:
52 79
output:
78
result:
ok 1 number(s): "78"
Test #39:
score: 0
Accepted
time: 5ms
memory: 11700kb
input:
11 48
output:
47
result:
ok 1 number(s): "47"
Test #40:
score: 0
Accepted
time: 2ms
memory: 11676kb
input:
4 51
output:
50
result:
ok 1 number(s): "50"
Test #41:
score: 0
Accepted
time: 0ms
memory: 11684kb
input:
3 60
output:
59
result:
ok 1 number(s): "59"
Test #42:
score: 0
Accepted
time: 5ms
memory: 11740kb
input:
21 88
output:
87
result:
ok 1 number(s): "87"
Test #43:
score: 0
Accepted
time: 2ms
memory: 11676kb
input:
17 94
output:
93
result:
ok 1 number(s): "93"
Test #44:
score: 0
Accepted
time: 0ms
memory: 11620kb
input:
11 98
output:
97
result:
ok 1 number(s): "97"
Test #45:
score: 0
Accepted
time: 0ms
memory: 11704kb
input:
2 99
output:
98
result:
ok 1 number(s): "98"
Extra Test:
score: 0
Extra Test Passed