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
p02696
C++
Time Limit Exceeded
// include //------------------------------------------ #include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //------------------------------------------- template <class T> inline T sqr(T x) { return x * x; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define fore(i, a) for (auto &i : a) // constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); // clear memory #define CLR(a) memset((a), 0, sizeof(a)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; int main() { long long A, B, N; cin >> A >> B >> N; long long num = 0; for (long long i = 0; i <= N; ++i) { long long ans = (long long)floor(A * i / B) - A * floor(i / B); num = max(num, ans); } cout << num; }
// include //------------------------------------------ #include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //------------------------------------------- template <class T> inline T sqr(T x) { return x * x; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define fore(i, a) for (auto &i : a) // constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); // clear memory #define CLR(a) memset((a), 0, sizeof(a)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; int main() { long long A, B, N; cin >> A >> B >> N; long long num = 0; long long left = N; long long right = 0; long long mid = min(B - 1, N); long long ans = floor((A * mid / B)) - A * floor(mid / B); cout << ans << endl; }
replace
95
100
95
100
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i-- > 0;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define Reverse(x) reverse(all(x)) #define PQ priority_queue #define NP(x) next_permutation(all(x)) #define M_PI 3.14159265358979323846 #define popcount __builtin_popcountll using namespace std; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef unsigned long long ull; typedef vector<ull> vu; typedef vector<vu> vvu; typedef double dbl; typedef vector<dbl> vd; typedef vector<vd> vvd; typedef string str; typedef vector<str> vs; typedef vector<vs> vvs; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef map<int, int> mii; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef map<ll, ll> mll; typedef pair<dbl, dbl> pdd; typedef vector<pdd> vpdd; typedef map<dbl, dbl> mdd; typedef pair<str, str> pss; typedef vector<pss> vpss; typedef map<str, str> mss; typedef pair<int, ll> pil; typedef vector<pil> vpil; typedef map<int, ll> mil; typedef pair<ll, int> pli; typedef vector<pli> vpli; typedef map<ll, int> mli; typedef pair<dbl, int> pdi; typedef vector<pdi> vpdi; typedef map<dbl, int> mdi; template <typename T> vector<T> &operator<<(vector<T> &v, const T t) { v.push_back(t); return v; } template <typename T> multiset<T> &operator<<(multiset<T> &m, const T t) { m.insert(t); return m; } template <typename T> set<T> &operator<<(set<T> &s, const T t) { s.insert(t); return s; } template <typename T> stack<T> &operator<<(stack<T> &s, const T t) { s.push(t); return s; } template <typename T> stack<T> &operator>>(stack<T> &s, T &t) { t = s.top(); s.pop(); return s; } template <typename T> queue<T> &operator<<(queue<T> &q, const T t) { q.push(t); return q; } template <typename T> queue<T> &operator>>(queue<T> &q, T &t) { t = q.front(); q.pop(); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator<<(PQ<T, vector<T>, U> &q, const T t) { q.push(t); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator>>(PQ<T, vector<T>, U> &q, T &t) { t = q.top(); q.pop(); return q; } template <typename T, typename U> istream &operator>>(istream &s, pair<T, U> &p) { return s >> p.first >> p.second; } istream &operator>>(istream &s, _Bit_reference b) { int a; s >> a; assert(a == 0 || a == 1); b = a; return s; } template <typename T> istream &operator>>(istream &s, vector<T> &v) { fr(i, v.size()) { s >> v[i]; } return s; } template <typename T, typename U> ostream &operator<<(ostream &s, const pair<T, U> p) { return s << p.first << " " << p.second; } template <typename T> ostream &operator<<(ostream &s, const vector<T> v) { fr(i, v.size()) { i ? s << " " << v[i] : s << v[i]; } return s; } template <typename T> ostream &operator<<(ostream &s, const deque<T> d) { fr(i, d.size()) { i ? s << " " << d[i] : s << d[i]; } return s; } template <typename T> _Bit_reference operator&=(_Bit_reference b, T t) { return b = b & t; } template <typename T> _Bit_reference operator^=(_Bit_reference b, T t) { return b = b ^ t; } template <typename T> _Bit_reference operator|=(_Bit_reference b, T t) { return b = b | t; } template <typename T, typename U> pair<T, U> operator+(pair<T, U> a, pair<T, U> b) { return {a.first + b.first, a.second + b.second}; } template <typename T, typename U> pair<T, U> operator-(pair<T, U> a, pair<T, U> b) { return {a.first - b.first, a.second - b.second}; } template <typename T, typename U> pair<T, U> &operator+=(pair<T, U> &a, pair<T, U> b) { return a = a + b; } template <typename T, typename U> pair<T, U> &operator-=(pair<T, U> &a, pair<T, U> b) { return a = a - b; } void print(void) { cout << "\n"; } void Print(void) { cout << endl; } template <typename T> void print(T t) { cout << t << "\n"; } template <typename T> void Print(T t) { cout << t << endl; } template <typename T, typename... U> void print(T &&t, U &&...u) { cout << t << " "; print(forward<U>(u)...); } template <typename T, typename... U> void Print(T &&t, U &&...u) { cout << t << " "; Print(forward<U>(u)...); } bool YN(bool b) { print(b ? "YES" : "NO"); return b; } bool PI(bool b) { print(b ? "POSSIBLE" : "IMPOSSIBLE"); return b; } bool Yn(bool b) { print(b ? "Yes" : "No"); return b; } bool Pi(bool b) { print(b ? "Possible" : "Impossible"); return b; } bool yn(bool b) { print(b ? "yes" : "no"); return b; } bool pi(bool b) { print(b ? "possible" : "impossible"); return b; } const int e5 = 1e5; const int e9 = 1e9; const int MD = 1e9 + 7; const int md = 998244353; const ll e18 = 1e18; template <typename T> str to_string(const T &n) { ostringstream s; s << n; return s.str(); } template <typename T> T &chmax(T &a, T b) { return a = max(a, b); } template <typename T> T &chmin(T &a, T b) { return a = min(a, b); } template <typename T, typename U> vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> &E, const U s, const T inf) { using P = pair<T, U>; vector<P> d; fr(i, E.size()) { d << P{inf, i}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } template <typename T, typename U> map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s, const T inf) { using P = pair<T, U>; map<U, P> d; for (pair<U, vector<P>> e : E) { d[e.first] = P{inf, e.first}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } ll maxflow(vector<mil> &E, int s, int t) { ll z = 0; vi b(E.size(), -1); for (int i = 0;; ++i) { static auto dfs = [&](int v, ll f, auto &dfs) -> ll { if (v == t) return f; b[v] = i; for (auto &p : E[v]) { if (b[p.first] < i && p.second) { if (ll r = dfs(p.first, min(f, p.second), dfs)) { p.second -= r; E[p.first][v] += r; return r; } } } return 0; }; ll x = dfs(s, ll(1e18), dfs); z += x; if (x == 0) return z; } } template <typename T> T distsq(pair<T, T> a, pair<T, T> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } template <typename T> T max(const vector<T> a) { assert(a.size()); T m = a[0]; for (T e : a) { m = max(m, e); } return m; } template <typename T> T min(const vector<T> a) { assert(a.size()); T m = a[0]; for (T e : a) { m = min(m, e); } return m; } template <typename T> T gcd(const T a, const T b) { return a ? gcd(b % a, a) : b; } template <typename T> T gcd(const vector<T> a) { T g = a[0]; for (T e : a) { g = gcd(g, e); } return g; } template <typename T> vector<T> LCS(vector<T> A, vector<T> B) { int N = A.size(), M = B.size(); vector<vector<pair<int, pii>>> d(N + 1, vector<pair<int, pii>>(M + 1)); fr(i, N) { fr(j, M) { if (A[i] == B[j]) { d[i + 1][j + 1] = {d[i][j].first + 1, {i, j}}; } else { d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]); } } } vector<T> r; for (pii p = {N, M}; d[p.first][p.second].first; p = d[p.first][p.second].second) { r << A[d[p.first][p.second].second.first]; } Reverse(r); return r; } str LCS(str S, str T) { vector<char> s = LCS(vector<char>(S.begin(), S.end()), vector<char>(T.begin(), T.end())); return str(s.begin(), s.end()); } template <typename T> vector<pair<T, T>> ConvexHull(vector<pair<T, T>> V) { if (V.size() <= 3) { return V; } Sort(V); rf(i, V.size() - 1) V << V[i]; vector<pair<T, T>> r; for (pair<T, T> p : V) { int s = r.size(); while (s >= 2 && (p.second - r[s - 1].second) * (p.first - r[s - 2].first) < (p.second - r[s - 2].second) * (p.first - r[s - 1].first)) { r.pop_back(); --s; } r << p; } r.pop_back(); return r; } class UnionFind { vi p, s; void extend(int N) { foor(i, p.size(), N) { p << i; s << 1; } } public: UnionFind(void) {} UnionFind(int N) { extend(N - 1); } int find(int i) { extend(i); return p[i] = p[i] == i ? i : find(p[i]); } void unite(int a, int b) { extend(a); extend(b); if ((a = find(a)) != (b = find(b))) { if (s[a] > s[b]) { swap(a, b); } s[b] += s[a]; p[a] = b; } } void unite(pii p) { return unite(p.first, p.second); } bool same(int a, int b) { extend(a); extend(b); return find(a) == find(b); } bool same(pii p) { return same(p.first, p.second); } int size(int x) { extend(x); return s[find(x)]; } }; ll MST(vector<pair<ll, pii>> &E) { Sort(E); UnionFind uf; ll z = 0; for (auto &e : E) { if (!uf.same(e.second)) { z += e.first; uf.unite(e.second); } } return z; } ll strmod(const str &s, const int m) { ll x = 0; fr(i, s.size()) { x = (x * 10 + s[i] - 48) % m; } return x; } vvl mul(const vvl &A, const vvl &B, const int m) { vvl C; fr(y, A.size()) { C << vl(B[y].size()); } fr(y, C.size()) { fr(x, C[y].size()) { fr(i, A[0].size()) { (C[y][x] += A[y][i] * B[i][x]) %= m; } } } return C; } vvl pow(const vvl &A, const ll n, const int m) { vvl B; fr(y, A.size()) { B << vl(A.size()); } if (n == 0) { fr(i, B.size()) { B[i][i] = 1; } } elsif(n % 2) { B = mul(A, pow(A, n - 1, m), m); } else { vvl C = pow(A, n / 2, m); B = mul(C, C, m); } return B; } ll pow(const ll a, const ll n, const int m) { ll t; return n ? (n & 1 ? a >= 0 ? a % m : (m - (-a % m)) % m : 1) * (t = pow(a, n >> 1, m), t * t % m) % m : !!a; } ll inv(const ll x, const int p) { assert(x != 0); return pow(x, p - 2, p); } ll inv(const ll x) { return inv(x, MD); } vpll fact(const int n, const int p) { assert(n < p); vpll v(n + 1); v[0].first = 1; foor(i, 1, n) { v[i].first = v[i - 1].first * i % p; } v[n].second = inv(v[n].first, p); roof(i, n, 1) { v[i - 1].second = v[i].second * i % p; } return v; } class Combination { const vpll f; const int M; public: Combination(int n, int m) : f(fact(n, m)), M(m) {} Combination(int n) : Combination(n, MD) {} ll P(int n, int k) { return n < 0 || k < 0 || n < k ? 0ll : f[n].first * f[n - k].second % M; } ll C(int n, int k) { return k < 0 ? 0 : P(n, k) * f[k].second % M; } ll H(int n, int k) { return n == 0 && k == 0 ? 1ll : C(n + k - 1, k); } ll F(int n) { return n < 0 ? 0 : f[n].first; } }; ll C2(const int n) { return (ll)n * ~-n / 2; } ll sum(const vi a) { ll s = 0; for (int e : a) { s += e; } return s; } ll sum(const vl a) { ll s = 0; for (ll e : a) { s += e; } return s; } template <typename T> int MSB(T N) { int r = -1; for (; N > 0; N /= 2) { ++r; } return r; } template <typename T> class SegmentTree { vector<T> S; T (*const op)(T a, T b); const T zero; const int B; public: SegmentTree(int N, T (*f)(T a, T b), const T zero) : S(1 << MSB(N - 1) + 2, zero), op(f), zero(zero), B(1 << MSB(N - 1) + 1) {} SegmentTree(vector<T> v, T (*f)(T a, T b), const T zero) : SegmentTree(v.size(), f, zero) { fr(i, v.size()) { S[S.size() / 2 + i] = v[i]; } roof(i, S.size() / 2 - 1, 1) { S[i] = op(S[i * 2], S[i * 2 + 1]); } } T calc(int l, int r) { l += B; r += B; if (l > r) { return zero; } if (l == r) { return S[l]; } T L = S[l], R = S[r]; for (; l / 2 < r / 2; l /= 2, r /= 2) { if (l % 2 == 0) { L = op(L, S[l + 1]); } if (r % 2 == 1) { R = op(S[r - 1], R); } } return op(L, R); } void replace(int i, T x) { for (S[i += B] = x; i != 1; i /= 2) { if (i % 2) { S[i / 2] = op(S[i - 1], S[i]); } else { S[i / 2] = op(S[i], S[i + 1]); } } } void add(int i, T x) { replace(i, op(S[B + i], x)); } T top() { return S[1]; } T get(int i) { return S[i + B]; } }; ll BITsum(vl &B, int i) { ll z = 0; while (i > 0) { z += B[i]; i -= i & -i; } return z; } void BITadd(vl &B, int i, ll x) { while (i < B.size()) { B[i] += x; i += i & -i; } } ll fib(const ll n, const int m) { ll a, b, c, d, A, B, C, D; a = 1; b = 0; c = 0; d = 1; rf(i, 63) { A = a * a + b * c; B = a * b + b * d; C = c * a + d * c; D = c * b + d * d; if (n >> i & 1) { a = A; b = B; c = C; d = D; A = a + b; B = a; C = c + d; D = c; } a = A % m; b = B % m; c = C % m; d = D % m; } return b; } vi primes(int n) { vb b(n + 1); vi p; foor(i, 2, n) { if (!b[i]) { p << i; for (int j = 2 * i; j <= n; j += i) { b[j] = true; } } } return p; } vb isprime(const int n) { vb v(n + 1, true); v[0] = v[1] = false; foor(i, 2, n) { if (v[i]) { for (int j = 2 * i; j <= n; j += i) { v[j] = false; } } } return v; } class LCA { vvi par; vi dep; public: LCA(vvi &E, int root) : par(MSB(E.size()) + 1, vi(E.size())), dep(E.size()) { function<void(int, int)> dfs = [&](int i, int p) { for (int j : E[i]) if (j != p) { par[0][j] = i; dep[j] = dep[i] + 1; dfs(j, i); } }; par[0][root] = root; dfs(root, root); fr(i, par.size() - 1) { fr(j, par[0].size()) { par[i + 1][j] = par[i][par[i][j]]; } } } int operator()(int a, int b) { if (dep[a] > dep[b]) swap(a, b); for (int t = dep[b] - dep[a], i = 0; t; t >>= 1, ++i) { if (t & 1) { b = par[i][b]; } } if (a == b) return a; rf(i, par.size()) { if (par[i][a] != par[i][b]) { a = par[i][a]; b = par[i][b]; } } return par[0][a]; } int dist(int a, int b) { return dep[a] + dep[b] - 2 * dep[operator()(a, b)]; } }; vpli factor(ll N) { vpli r; for (ll i = 2; i * i <= N; ++i) { if (N % i == 0) { r << pli{i, 0}; while (N % i == 0) { N /= i; ++r.back().second; } } } if (N > 1) { r << pli{N, 1}; } return r; } vl divisors(ll n) { vl r; ll m = sqrt(n); foor(i, 1, m) if (n % i == 0) r << ll(i); rf(i, r.size() - (m * m == n)) r << n / r[i]; return r; } vi SuffixArray(str S) { int N = S.size(); vi rank(N + 1), tmp(N + 1), sa(N + 1); fr(i, N) { sa[i] = i; rank[i] = S[i]; } sa[N] = N; rank[N] = -1; int k; auto cmp = [&](int &a, int &b) -> bool { if (rank[a] != rank[b]) return rank[a] < rank[b]; return (a + k <= N ? rank[a + k] : -1) < (b + k <= N ? rank[b + k] : -1); }; for (k = 1; k <= N; k *= 2) { sort(all(sa), cmp); tmp[sa[0]] = 0; foor(i, 1, N) { tmp[sa[i]] = tmp[sa[i - 1]] + cmp(sa[i - 1], sa[i]); } rank = tmp; } return sa; }; template <typename T, typename U> void sort2(vector<T> &a, vector<U> &b) { int N = a.size(); assert(b.size() == N); vector<pair<T, U>> v; fr(i, N) { v << pair<T, U>{a[i], b[i]}; } Sort(v); fr(i, N) { a[i] = v[i].first; b[i] = v[i].second; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll A, B, N; cin >> A >> B >> N; ll z = 0; foor(x, max(0ll, N - 2000000), N) { chmax(z, A * x / B - A * (x / B)); } print(z); return 0; }
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i-- > 0;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define Reverse(x) reverse(all(x)) #define PQ priority_queue #define NP(x) next_permutation(all(x)) #define M_PI 3.14159265358979323846 #define popcount __builtin_popcountll using namespace std; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef unsigned long long ull; typedef vector<ull> vu; typedef vector<vu> vvu; typedef double dbl; typedef vector<dbl> vd; typedef vector<vd> vvd; typedef string str; typedef vector<str> vs; typedef vector<vs> vvs; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef map<int, int> mii; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef map<ll, ll> mll; typedef pair<dbl, dbl> pdd; typedef vector<pdd> vpdd; typedef map<dbl, dbl> mdd; typedef pair<str, str> pss; typedef vector<pss> vpss; typedef map<str, str> mss; typedef pair<int, ll> pil; typedef vector<pil> vpil; typedef map<int, ll> mil; typedef pair<ll, int> pli; typedef vector<pli> vpli; typedef map<ll, int> mli; typedef pair<dbl, int> pdi; typedef vector<pdi> vpdi; typedef map<dbl, int> mdi; template <typename T> vector<T> &operator<<(vector<T> &v, const T t) { v.push_back(t); return v; } template <typename T> multiset<T> &operator<<(multiset<T> &m, const T t) { m.insert(t); return m; } template <typename T> set<T> &operator<<(set<T> &s, const T t) { s.insert(t); return s; } template <typename T> stack<T> &operator<<(stack<T> &s, const T t) { s.push(t); return s; } template <typename T> stack<T> &operator>>(stack<T> &s, T &t) { t = s.top(); s.pop(); return s; } template <typename T> queue<T> &operator<<(queue<T> &q, const T t) { q.push(t); return q; } template <typename T> queue<T> &operator>>(queue<T> &q, T &t) { t = q.front(); q.pop(); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator<<(PQ<T, vector<T>, U> &q, const T t) { q.push(t); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator>>(PQ<T, vector<T>, U> &q, T &t) { t = q.top(); q.pop(); return q; } template <typename T, typename U> istream &operator>>(istream &s, pair<T, U> &p) { return s >> p.first >> p.second; } istream &operator>>(istream &s, _Bit_reference b) { int a; s >> a; assert(a == 0 || a == 1); b = a; return s; } template <typename T> istream &operator>>(istream &s, vector<T> &v) { fr(i, v.size()) { s >> v[i]; } return s; } template <typename T, typename U> ostream &operator<<(ostream &s, const pair<T, U> p) { return s << p.first << " " << p.second; } template <typename T> ostream &operator<<(ostream &s, const vector<T> v) { fr(i, v.size()) { i ? s << " " << v[i] : s << v[i]; } return s; } template <typename T> ostream &operator<<(ostream &s, const deque<T> d) { fr(i, d.size()) { i ? s << " " << d[i] : s << d[i]; } return s; } template <typename T> _Bit_reference operator&=(_Bit_reference b, T t) { return b = b & t; } template <typename T> _Bit_reference operator^=(_Bit_reference b, T t) { return b = b ^ t; } template <typename T> _Bit_reference operator|=(_Bit_reference b, T t) { return b = b | t; } template <typename T, typename U> pair<T, U> operator+(pair<T, U> a, pair<T, U> b) { return {a.first + b.first, a.second + b.second}; } template <typename T, typename U> pair<T, U> operator-(pair<T, U> a, pair<T, U> b) { return {a.first - b.first, a.second - b.second}; } template <typename T, typename U> pair<T, U> &operator+=(pair<T, U> &a, pair<T, U> b) { return a = a + b; } template <typename T, typename U> pair<T, U> &operator-=(pair<T, U> &a, pair<T, U> b) { return a = a - b; } void print(void) { cout << "\n"; } void Print(void) { cout << endl; } template <typename T> void print(T t) { cout << t << "\n"; } template <typename T> void Print(T t) { cout << t << endl; } template <typename T, typename... U> void print(T &&t, U &&...u) { cout << t << " "; print(forward<U>(u)...); } template <typename T, typename... U> void Print(T &&t, U &&...u) { cout << t << " "; Print(forward<U>(u)...); } bool YN(bool b) { print(b ? "YES" : "NO"); return b; } bool PI(bool b) { print(b ? "POSSIBLE" : "IMPOSSIBLE"); return b; } bool Yn(bool b) { print(b ? "Yes" : "No"); return b; } bool Pi(bool b) { print(b ? "Possible" : "Impossible"); return b; } bool yn(bool b) { print(b ? "yes" : "no"); return b; } bool pi(bool b) { print(b ? "possible" : "impossible"); return b; } const int e5 = 1e5; const int e9 = 1e9; const int MD = 1e9 + 7; const int md = 998244353; const ll e18 = 1e18; template <typename T> str to_string(const T &n) { ostringstream s; s << n; return s.str(); } template <typename T> T &chmax(T &a, T b) { return a = max(a, b); } template <typename T> T &chmin(T &a, T b) { return a = min(a, b); } template <typename T, typename U> vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> &E, const U s, const T inf) { using P = pair<T, U>; vector<P> d; fr(i, E.size()) { d << P{inf, i}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } template <typename T, typename U> map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s, const T inf) { using P = pair<T, U>; map<U, P> d; for (pair<U, vector<P>> e : E) { d[e.first] = P{inf, e.first}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } ll maxflow(vector<mil> &E, int s, int t) { ll z = 0; vi b(E.size(), -1); for (int i = 0;; ++i) { static auto dfs = [&](int v, ll f, auto &dfs) -> ll { if (v == t) return f; b[v] = i; for (auto &p : E[v]) { if (b[p.first] < i && p.second) { if (ll r = dfs(p.first, min(f, p.second), dfs)) { p.second -= r; E[p.first][v] += r; return r; } } } return 0; }; ll x = dfs(s, ll(1e18), dfs); z += x; if (x == 0) return z; } } template <typename T> T distsq(pair<T, T> a, pair<T, T> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } template <typename T> T max(const vector<T> a) { assert(a.size()); T m = a[0]; for (T e : a) { m = max(m, e); } return m; } template <typename T> T min(const vector<T> a) { assert(a.size()); T m = a[0]; for (T e : a) { m = min(m, e); } return m; } template <typename T> T gcd(const T a, const T b) { return a ? gcd(b % a, a) : b; } template <typename T> T gcd(const vector<T> a) { T g = a[0]; for (T e : a) { g = gcd(g, e); } return g; } template <typename T> vector<T> LCS(vector<T> A, vector<T> B) { int N = A.size(), M = B.size(); vector<vector<pair<int, pii>>> d(N + 1, vector<pair<int, pii>>(M + 1)); fr(i, N) { fr(j, M) { if (A[i] == B[j]) { d[i + 1][j + 1] = {d[i][j].first + 1, {i, j}}; } else { d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]); } } } vector<T> r; for (pii p = {N, M}; d[p.first][p.second].first; p = d[p.first][p.second].second) { r << A[d[p.first][p.second].second.first]; } Reverse(r); return r; } str LCS(str S, str T) { vector<char> s = LCS(vector<char>(S.begin(), S.end()), vector<char>(T.begin(), T.end())); return str(s.begin(), s.end()); } template <typename T> vector<pair<T, T>> ConvexHull(vector<pair<T, T>> V) { if (V.size() <= 3) { return V; } Sort(V); rf(i, V.size() - 1) V << V[i]; vector<pair<T, T>> r; for (pair<T, T> p : V) { int s = r.size(); while (s >= 2 && (p.second - r[s - 1].second) * (p.first - r[s - 2].first) < (p.second - r[s - 2].second) * (p.first - r[s - 1].first)) { r.pop_back(); --s; } r << p; } r.pop_back(); return r; } class UnionFind { vi p, s; void extend(int N) { foor(i, p.size(), N) { p << i; s << 1; } } public: UnionFind(void) {} UnionFind(int N) { extend(N - 1); } int find(int i) { extend(i); return p[i] = p[i] == i ? i : find(p[i]); } void unite(int a, int b) { extend(a); extend(b); if ((a = find(a)) != (b = find(b))) { if (s[a] > s[b]) { swap(a, b); } s[b] += s[a]; p[a] = b; } } void unite(pii p) { return unite(p.first, p.second); } bool same(int a, int b) { extend(a); extend(b); return find(a) == find(b); } bool same(pii p) { return same(p.first, p.second); } int size(int x) { extend(x); return s[find(x)]; } }; ll MST(vector<pair<ll, pii>> &E) { Sort(E); UnionFind uf; ll z = 0; for (auto &e : E) { if (!uf.same(e.second)) { z += e.first; uf.unite(e.second); } } return z; } ll strmod(const str &s, const int m) { ll x = 0; fr(i, s.size()) { x = (x * 10 + s[i] - 48) % m; } return x; } vvl mul(const vvl &A, const vvl &B, const int m) { vvl C; fr(y, A.size()) { C << vl(B[y].size()); } fr(y, C.size()) { fr(x, C[y].size()) { fr(i, A[0].size()) { (C[y][x] += A[y][i] * B[i][x]) %= m; } } } return C; } vvl pow(const vvl &A, const ll n, const int m) { vvl B; fr(y, A.size()) { B << vl(A.size()); } if (n == 0) { fr(i, B.size()) { B[i][i] = 1; } } elsif(n % 2) { B = mul(A, pow(A, n - 1, m), m); } else { vvl C = pow(A, n / 2, m); B = mul(C, C, m); } return B; } ll pow(const ll a, const ll n, const int m) { ll t; return n ? (n & 1 ? a >= 0 ? a % m : (m - (-a % m)) % m : 1) * (t = pow(a, n >> 1, m), t * t % m) % m : !!a; } ll inv(const ll x, const int p) { assert(x != 0); return pow(x, p - 2, p); } ll inv(const ll x) { return inv(x, MD); } vpll fact(const int n, const int p) { assert(n < p); vpll v(n + 1); v[0].first = 1; foor(i, 1, n) { v[i].first = v[i - 1].first * i % p; } v[n].second = inv(v[n].first, p); roof(i, n, 1) { v[i - 1].second = v[i].second * i % p; } return v; } class Combination { const vpll f; const int M; public: Combination(int n, int m) : f(fact(n, m)), M(m) {} Combination(int n) : Combination(n, MD) {} ll P(int n, int k) { return n < 0 || k < 0 || n < k ? 0ll : f[n].first * f[n - k].second % M; } ll C(int n, int k) { return k < 0 ? 0 : P(n, k) * f[k].second % M; } ll H(int n, int k) { return n == 0 && k == 0 ? 1ll : C(n + k - 1, k); } ll F(int n) { return n < 0 ? 0 : f[n].first; } }; ll C2(const int n) { return (ll)n * ~-n / 2; } ll sum(const vi a) { ll s = 0; for (int e : a) { s += e; } return s; } ll sum(const vl a) { ll s = 0; for (ll e : a) { s += e; } return s; } template <typename T> int MSB(T N) { int r = -1; for (; N > 0; N /= 2) { ++r; } return r; } template <typename T> class SegmentTree { vector<T> S; T (*const op)(T a, T b); const T zero; const int B; public: SegmentTree(int N, T (*f)(T a, T b), const T zero) : S(1 << MSB(N - 1) + 2, zero), op(f), zero(zero), B(1 << MSB(N - 1) + 1) {} SegmentTree(vector<T> v, T (*f)(T a, T b), const T zero) : SegmentTree(v.size(), f, zero) { fr(i, v.size()) { S[S.size() / 2 + i] = v[i]; } roof(i, S.size() / 2 - 1, 1) { S[i] = op(S[i * 2], S[i * 2 + 1]); } } T calc(int l, int r) { l += B; r += B; if (l > r) { return zero; } if (l == r) { return S[l]; } T L = S[l], R = S[r]; for (; l / 2 < r / 2; l /= 2, r /= 2) { if (l % 2 == 0) { L = op(L, S[l + 1]); } if (r % 2 == 1) { R = op(S[r - 1], R); } } return op(L, R); } void replace(int i, T x) { for (S[i += B] = x; i != 1; i /= 2) { if (i % 2) { S[i / 2] = op(S[i - 1], S[i]); } else { S[i / 2] = op(S[i], S[i + 1]); } } } void add(int i, T x) { replace(i, op(S[B + i], x)); } T top() { return S[1]; } T get(int i) { return S[i + B]; } }; ll BITsum(vl &B, int i) { ll z = 0; while (i > 0) { z += B[i]; i -= i & -i; } return z; } void BITadd(vl &B, int i, ll x) { while (i < B.size()) { B[i] += x; i += i & -i; } } ll fib(const ll n, const int m) { ll a, b, c, d, A, B, C, D; a = 1; b = 0; c = 0; d = 1; rf(i, 63) { A = a * a + b * c; B = a * b + b * d; C = c * a + d * c; D = c * b + d * d; if (n >> i & 1) { a = A; b = B; c = C; d = D; A = a + b; B = a; C = c + d; D = c; } a = A % m; b = B % m; c = C % m; d = D % m; } return b; } vi primes(int n) { vb b(n + 1); vi p; foor(i, 2, n) { if (!b[i]) { p << i; for (int j = 2 * i; j <= n; j += i) { b[j] = true; } } } return p; } vb isprime(const int n) { vb v(n + 1, true); v[0] = v[1] = false; foor(i, 2, n) { if (v[i]) { for (int j = 2 * i; j <= n; j += i) { v[j] = false; } } } return v; } class LCA { vvi par; vi dep; public: LCA(vvi &E, int root) : par(MSB(E.size()) + 1, vi(E.size())), dep(E.size()) { function<void(int, int)> dfs = [&](int i, int p) { for (int j : E[i]) if (j != p) { par[0][j] = i; dep[j] = dep[i] + 1; dfs(j, i); } }; par[0][root] = root; dfs(root, root); fr(i, par.size() - 1) { fr(j, par[0].size()) { par[i + 1][j] = par[i][par[i][j]]; } } } int operator()(int a, int b) { if (dep[a] > dep[b]) swap(a, b); for (int t = dep[b] - dep[a], i = 0; t; t >>= 1, ++i) { if (t & 1) { b = par[i][b]; } } if (a == b) return a; rf(i, par.size()) { if (par[i][a] != par[i][b]) { a = par[i][a]; b = par[i][b]; } } return par[0][a]; } int dist(int a, int b) { return dep[a] + dep[b] - 2 * dep[operator()(a, b)]; } }; vpli factor(ll N) { vpli r; for (ll i = 2; i * i <= N; ++i) { if (N % i == 0) { r << pli{i, 0}; while (N % i == 0) { N /= i; ++r.back().second; } } } if (N > 1) { r << pli{N, 1}; } return r; } vl divisors(ll n) { vl r; ll m = sqrt(n); foor(i, 1, m) if (n % i == 0) r << ll(i); rf(i, r.size() - (m * m == n)) r << n / r[i]; return r; } vi SuffixArray(str S) { int N = S.size(); vi rank(N + 1), tmp(N + 1), sa(N + 1); fr(i, N) { sa[i] = i; rank[i] = S[i]; } sa[N] = N; rank[N] = -1; int k; auto cmp = [&](int &a, int &b) -> bool { if (rank[a] != rank[b]) return rank[a] < rank[b]; return (a + k <= N ? rank[a + k] : -1) < (b + k <= N ? rank[b + k] : -1); }; for (k = 1; k <= N; k *= 2) { sort(all(sa), cmp); tmp[sa[0]] = 0; foor(i, 1, N) { tmp[sa[i]] = tmp[sa[i - 1]] + cmp(sa[i - 1], sa[i]); } rank = tmp; } return sa; }; template <typename T, typename U> void sort2(vector<T> &a, vector<U> &b) { int N = a.size(); assert(b.size() == N); vector<pair<T, U>> v; fr(i, N) { v << pair<T, U>{a[i], b[i]}; } Sort(v); fr(i, N) { a[i] = v[i].first; b[i] = v[i].second; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll A, B, N; cin >> A >> B >> N; print(A * min(N, B - 1) / B); return 0; }
replace
693
696
693
694
TLE
p02696
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <vector> #define ID(x, y) (((x)-1) * m + (y)) #define CL clear #define fi first #define se second #define MP make_pair #define PB push_back #define low_bit(x) ((x) & (-(x))) #define dmp(x) cerr << #x << "=" << x << "\n" #define MIN(a, b, c) min(a, min(b, c)) #define MAX(a, b, c) max(a, max(b, c)) #define SZ(x) ((int)(x.size())) #define sc scanf #define pf printf #define rep(i, a, b) for (int i = (a); i <= (b); i++) #define dep(i, a, b) for (int i = (a); i >= (b); i--) #define int long long using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; const int N = (int)1e6 + 10; const int mod = 1e9 + 7; const int inf = 1e9; const double eps = 1e-16; const double pi = acos(-1); inline int rd() { int p = 0; int f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f *= -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { p = p * 10 + ch - '0'; ch = getchar(); } return p * f; } int A, B, n; signed main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int A = rd(); int B = rd(); int n = rd(); int nx = 0; int ans = 0; for (int i = 1; i <= n; i = nx + 1) { nx = min(n, B / (B / i)); // printf("%lld\n",nx); ans = max(ans, A * nx / B - A * (nx / B)); } return printf("%lld\n", ans), 0; } /* */
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <vector> #define ID(x, y) (((x)-1) * m + (y)) #define CL clear #define fi first #define se second #define MP make_pair #define PB push_back #define low_bit(x) ((x) & (-(x))) #define dmp(x) cerr << #x << "=" << x << "\n" #define MIN(a, b, c) min(a, min(b, c)) #define MAX(a, b, c) max(a, max(b, c)) #define SZ(x) ((int)(x.size())) #define sc scanf #define pf printf #define rep(i, a, b) for (int i = (a); i <= (b); i++) #define dep(i, a, b) for (int i = (a); i >= (b); i--) #define int long long using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; const int N = (int)1e6 + 10; const int mod = 1e9 + 7; const int inf = 1e9; const double eps = 1e-16; const double pi = acos(-1); inline int rd() { int p = 0; int f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f *= -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { p = p * 10 + ch - '0'; ch = getchar(); } return p * f; } int A, B, n; signed main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int A = rd(); int B = rd(); int n = rd(); int x = (n + 1) / B; x = x * B - 1; printf("%lld\n", max((A * x / B) - A * (x / B), (A * n / B) - A * (n / B))); return 0; } /* */
replace
74
82
74
78
0
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin >> #define Z class #define ll long long #define ln cout << '\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n", a) #define mem(a) memset(a, 0, sizeof(a)) #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--) #define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define rep(i, n) REP(i, 0, n) #define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++) void pr() { ln; } template <Z A, Z... B> void pr(const A &a, const B &...b) { cout << a << ' '; pr(b...); } template <Z A> void PR(A a, ll n) { rep(i, n) { if (i) cout << ' '; cout << a[i]; } ln; } ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; } const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1}, dy[8] = {0, 1, 0, -1, -1, 1, 1, -1}; typedef pair<ll, ll> P; void Main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; rep(i, 200000000) { ll x = n - i; if (x < 0) break; ll y = a * x / b - a * (x / b); ans = max(ans, y); } pr(ans); } int main() { ios::sync_with_stdio(0); cin.tie(0); Main(); return 0; }
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define R cin >> #define Z class #define ll long long #define ln cout << '\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n", a) #define mem(a) memset(a, 0, sizeof(a)) #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--) #define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define rep(i, n) REP(i, 0, n) #define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++) void pr() { ln; } template <Z A, Z... B> void pr(const A &a, const B &...b) { cout << a << ' '; pr(b...); } template <Z A> void PR(A a, ll n) { rep(i, n) { if (i) cout << ' '; cout << a[i]; } ln; } ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; } const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1}, dy[8] = {0, 1, 0, -1, -1, 1, 1, -1}; typedef pair<ll, ll> P; void Main() { ll a, b, n; cin >> a >> b >> n; ll x = min(n, b - 1); ll ans = a * x / b - a * (x / b); pr(ans); } int main() { ios::sync_with_stdio(0); cin.tie(0); Main(); return 0; }
replace
39
47
39
41
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; // long long x = max(N, B-1); long long ans_max = -1; // cerr << (long long)((A * x) / B) << ", " << (A * (long long)(x / B)) << // endl; long long ans = (long long)((A * x) / B) - (A * (long long)(x / B)); // ans_max = max(ans, ans_max); for (long long x = 1; x <= B && x <= N; x++) { long long ans = (long long)((A * x) / B) - (A * (long long)(x / B)); ans_max = max(ans, ans_max); } cout << ans_max << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; long long x = min(B - 1, N); cout << (long long)(A * x / B) - A * (long long)(x / B) << endl; return 0; }
replace
6
19
6
8
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> #include <math.h> using namespace std; int main() { int x = 1; int max = -1; double a, b, n; cin >> a >> b >> n; long long dif; for (int i = 1; i <= n; i++) { dif = floor(a * i / b) - a * floor(i / b); if (dif > max) max = dif; } cout << max; return 0; }
#include <iostream> #include <math.h> using namespace std; int main() { int x = 1; int max = -1; double a, b, n; cin >> a >> b >> n; long long dif; dif = b - 1; if (n < b - 1) dif = n; max = floor(a * dif / b) - a * floor(dif / b); cout << max; return 0; }
replace
9
15
9
13
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, m, n) for (int i = m; i < n; i++) typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> Pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } int main() { ll A, B, N; cin >> A >> B >> N; ll ans = 0; for (ll i = B - 1; i < N + 1; i += B) { ans = max(ans, A * i / B - A * (i / B)); } ans = max(ans, (A * N) / B - A * (N / B)); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, m, n) for (int i = m; i < n; i++) typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> Pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } int main() { ll A, B, N; cin >> A >> B >> N; ll ans = 0; for (ll i = B - 1; i < N + 1; i += B) { ans = max(ans, A * i / B - A * (i / B)); if (i > (B - 1) + B * 10000000) break; } ans = max(ans, (A * N) / B - A * (N / B)); cout << ans << endl; }
insert
30
30
30
32
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { unsigned long long a, b, n; cin >> a >> b >> n; unsigned long long mx = 0; for (unsigned long long x = 1; x <= n; x++) { unsigned long long s = (unsigned long long)(a * x / b) - a * ((unsigned long long)(x / b)); if (s > mx) { mx = s; } } cout << mx << endl; return 0; }
#include <iostream> using namespace std; int main() { unsigned long long a, b, n; cin >> a >> b >> n; unsigned long long x = b - 1; if (n < x) x = n; unsigned long long s = (unsigned long long)(a * x / b) - a * ((unsigned long long)(x / b)); cout << s << endl; return 0; }
replace
6
15
6
12
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define sz(a) int((a).size()) #define forn(i, n) for (int i = 0; i < int(n); ++i) #define fore(i, l, r) for (int i = int(l); i < int(r); ++i) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define file_name(a) \ (freopen(((string)(a) + ".in").c_str(), "r", stdin), \ freopen(((string)(a) + ".out").c_str(), "w", stdout)) int nxt() { int x; cin >> x; return x; } int main() { ll a, b, n; cin >> a >> b >> n; if (b == 1) { cout << 0 << '\n'; return 0; } ll ans = 0; for (int x = min(b - 1, n); x <= n; x += b) { ans = max(ans, (a * x) / b - a * (x / b)); } cout << ans << '\n'; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define sz(a) int((a).size()) #define forn(i, n) for (int i = 0; i < int(n); ++i) #define fore(i, l, r) for (int i = int(l); i < int(r); ++i) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define file_name(a) \ (freopen(((string)(a) + ".in").c_str(), "r", stdin), \ freopen(((string)(a) + ".out").c_str(), "w", stdout)) int nxt() { int x; cin >> x; return x; } int main() { ll a, b, n; cin >> a >> b >> n; if (b == 1) { cout << 0 << '\n'; return 0; } ll ans = 0; for (ll x = min(b - 1, n); x <= n; x += b) { ans = max(ans, (a * x) / b - a * (x / b)); } cout << ans << '\n'; return 0; }
replace
38
39
38
39
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; void solve(long long A, long long B, long long N) { long long ans = 0; for (long long i = 1; i <= B - 1 && i <= N; i++) { ans = max(ans, (A * (i % B) - (A * i) % B) / B); } cout << ans << endl; } // Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You // use the default template now. You can remove this line by using your custom // template) int main() { long long A; scanf("%lld", &A); long long B; scanf("%lld", &B); long long N; scanf("%lld", &N); solve(A, B, N); return 0; }
#include <bits/stdc++.h> using namespace std; void solve(long long A, long long B, long long N) { long long x = N < B ? N : B - 1; long long ans = floor((A * (x % B)) / B); cout << ans << endl; } // Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You // use the default template now. You can remove this line by using your custom // template) int main() { long long A; scanf("%lld", &A); long long B; scanf("%lld", &B); long long N; scanf("%lld", &N); solve(A, B, N); return 0; }
replace
4
8
4
6
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (long long i = 0; i < (n); i++) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ll a, b, n; cin >> a >> b >> n; ll res = 0; if (b - 1 <= n) chmax(res, a * (b - 1) / b); for (ll i = n; (i > 0 && i % b != b - 1); i--) { chmax(res, (a * i) / b - a * (i / b)); } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (long long i = 0; i < (n); i++) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ll a, b, n; cin >> a >> b >> n; ll res = 0; if (b - 1 <= n) chmax(res, a * (b - 1) / b); chmax(res, a * n / b - a * (n / b)); cout << res << endl; return 0; }
replace
25
28
25
26
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <assert.h> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <regex> #include <set> #include <stdio.h> #include <unordered_map> #include <unordered_set> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define per(i, n) for (ll i = n - 1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define _GLIBCXX_DEBUG using namespace std; // 省略表現 using ll = long long; using P = pair<ll, ll>; using GraphEdge = vector<vector<P>>; using Graph = vector<vector<ll>>; const int mod = 1000000007; // 実行時間高速化 struct __INIT { __INIT() { cin.tie(nullptr); ios::sync_with_stdio(false); } } __init; // 辺にコストを持たせる構造体 /** struct Edge{ ll to; ll cost; Edge(ll t, ll c) : to(t), cost(c) {} }; */ // unorderd_mapのキーにpairを使えるようにするための構造体 struct HashPair { // 注意 constがいる template <class T1, class T2> size_t operator()(const pair<T1, T2> &p) const { auto hash1 = hash<T1>{}(p.first); auto hash2 = hash<T2>{}(p.second); size_t seed = 0; seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2); return seed; } }; // 最大値、最小値用のdp用の関数 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; } const long long INF = 1LL << 60; // 固定長配列の大きさ(dp用) template <typename TYPE, size_t SIZE> size_t array_length(const TYPE (&)[SIZE]) { return SIZE; } // 剰余計算 struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; // 組み合わせ(剰余付き) // combination c(n)で初期化する必要がある。(nはCの左側の数) struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; // 桁取得 ll getDigit(ll n) { ll cnt = 0; while (n != 0) { n /= 10; cnt++; } return cnt; } // 素数判定(O(sqrt(n))) // 繰り返す数がn/sqrt(n)回以下なら、こっちの素数判定の方が速いはず(k*sqrt(n)<=n) bool isPrime(ll n) { if (n == 1) return false; for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } // エラストテネスの篩(O(NloglogN)) struct Sieve { ll n; vector<ll> f, primes; Sieve(ll n = 1) : n(n), f(n + 1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i * i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } // 素数判定 bool isPrime(ll x) { return f[x] == x; } vector<ll> factorList(ll x) { vector<ll> res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } // 素因数分解 vector<P> factor(ll x) { vector<ll> fl = factorList(x); if (fl.size() == 0) return {}; vector<P> res(1, P(fl[0], 0)); for (ll p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } }; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } // ペア比較順序 typedef pair<ll, ll> pair_t; bool PSecComp(const pair_t &a, const pair_t &b) { if (a.second == b.second) return a.first > b.first; else { return a.second > b.second; } } ll a, b, n; ll f(ll x) { return (a * x) / b - a * (x / b); } int main() { cin >> a >> b >> n; ll sum = 0, maxSum = -INF; for (ll i = 0; i <= n; i++) { sum = f(i); if (f(i) - f(i - 1) < 0) break; maxSum = max(sum, maxSum); } cout << maxSum << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <assert.h> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <regex> #include <set> #include <stdio.h> #include <unordered_map> #include <unordered_set> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define per(i, n) for (ll i = n - 1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define _GLIBCXX_DEBUG using namespace std; // 省略表現 using ll = long long; using P = pair<ll, ll>; using GraphEdge = vector<vector<P>>; using Graph = vector<vector<ll>>; const int mod = 1000000007; // 実行時間高速化 struct __INIT { __INIT() { cin.tie(nullptr); ios::sync_with_stdio(false); } } __init; // 辺にコストを持たせる構造体 /** struct Edge{ ll to; ll cost; Edge(ll t, ll c) : to(t), cost(c) {} }; */ // unorderd_mapのキーにpairを使えるようにするための構造体 struct HashPair { // 注意 constがいる template <class T1, class T2> size_t operator()(const pair<T1, T2> &p) const { auto hash1 = hash<T1>{}(p.first); auto hash2 = hash<T2>{}(p.second); size_t seed = 0; seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2); return seed; } }; // 最大値、最小値用のdp用の関数 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; } const long long INF = 1LL << 60; // 固定長配列の大きさ(dp用) template <typename TYPE, size_t SIZE> size_t array_length(const TYPE (&)[SIZE]) { return SIZE; } // 剰余計算 struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; // 組み合わせ(剰余付き) // combination c(n)で初期化する必要がある。(nはCの左側の数) struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; // 桁取得 ll getDigit(ll n) { ll cnt = 0; while (n != 0) { n /= 10; cnt++; } return cnt; } // 素数判定(O(sqrt(n))) // 繰り返す数がn/sqrt(n)回以下なら、こっちの素数判定の方が速いはず(k*sqrt(n)<=n) bool isPrime(ll n) { if (n == 1) return false; for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } // エラストテネスの篩(O(NloglogN)) struct Sieve { ll n; vector<ll> f, primes; Sieve(ll n = 1) : n(n), f(n + 1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i * i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } // 素数判定 bool isPrime(ll x) { return f[x] == x; } vector<ll> factorList(ll x) { vector<ll> res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } // 素因数分解 vector<P> factor(ll x) { vector<ll> fl = factorList(x); if (fl.size() == 0) return {}; vector<P> res(1, P(fl[0], 0)); for (ll p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } }; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } // ペア比較順序 typedef pair<ll, ll> pair_t; bool PSecComp(const pair_t &a, const pair_t &b) { if (a.second == b.second) return a.first > b.first; else { return a.second > b.second; } } ll a, b, n; ll f(ll x) { return (a * x) / b - a * (x / b); } int main() { cin >> a >> b >> n; cout << f(min(b - 1, n)) << endl; }
replace
238
247
238
240
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, n, t, k, k1; cin >> a >> b >> n; if (b > n) { cout << (a * n) / b; } else { t = b - 1; k = ((a * t) / b) - (a * (t / b)); while (1) { t++; if (t > n) { break; } k1 = ((a * t) / b) - (a * (t / b)); if (k > k1) { break; } else if (k1 > k) { k = k1; } } cout << k; } }
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, n, t, k, k1; cin >> a >> b >> n; if (b > n) { cout << (a * n) / b; } else { cout << (a * (b - 1)) / b; } }
replace
8
23
8
9
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> #include <vector> #define _USE_MATH_DEFINES #include <algorithm> #include <math.h> #include <memory> #include <string> #define Rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } void swap(int &a, int &b) { int temp = a; a = b; b = temp; return; } int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; } int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; } int mod(int a, int b) { return a % b; } int main() { long double a, b, x, n; std::cin >> a >> b >> n; ll ans = 0; for (long double i = 0; i <= n; i++) { long double k = i / b; ll h = k; k = k - h; h = k * a; if (h > ans) { ans = h; } } std::cout << ans << std::endl; return 0; }
#include <iostream> #include <vector> #define _USE_MATH_DEFINES #include <algorithm> #include <math.h> #include <memory> #include <string> #define Rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } void swap(int &a, int &b) { int temp = a; a = b; b = temp; return; } int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; } int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; } int mod(int a, int b) { return a % b; } int main() { long double a, b, x, n; std::cin >> a >> b >> n; ll ans; if (b > n) { ans = n / b * a; } else { ans = (b - 1) / b * a; } std::cout << ans << std::endl; return 0; }
replace
38
47
38
43
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> #include <vector> int main() { int64_t A, B, N; std::cin >> A >> B >> N; int64_t max = 0; for (auto i = 0; i <= N; ++i) { auto score = (A * i / B) - A * (i / B); // std::cout << score << std::endl; if (max < score) max = score; } std::cout << max << std::endl; }
#include <iostream> #include <vector> int main() { int64_t A, B, N; std::cin >> A >> B >> N; auto maxX = std::min(B - 1, N); std::cout << (A * maxX / B) - A * (maxX / B) << std::endl; }
replace
7
17
7
9
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // #pragma GCC optimize("Ofast") #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ub(v, k) (upper_bound(all(v), k) - v.begin()) #define fi first #define se second #define pi M_PI #define PQ(T) priority_queue<T> #define SPQ(T) priority_queue<T, vector<T>, greater<T>> using ll = long long; using P = pair<ll, ll>; using PP = tuple<ll, ll, ll>; using S = multiset<ll>; using vi = vector<ll>; using vvi = vector<vi>; using vvvi = vector<vvi>; const ll inf = 1001001001001001; const int INF = 1001001001; const int mod = 1000000007; const double eps = 1e-10; 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; } template <class T> void out(T a) { cout << a << '\n'; } template <class T> void outp(T a) { cout << '(' << a.fi << ',' << a.se << ')' << '\n'; } template <class T> void outvp(T v) { rep(i, v.size()) cout << '(' << v[i].fi << ',' << v[i].se << ')'; cout << '\n'; } template <class T> void outv(T v) { rep(i, v.size()) { if (i) cout << ' '; cout << v[i]; } cout << '\n'; } template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); } template <class T> bool isin(T x, T l, T r) { return (l) <= (x) && (x) <= (r); } template <class T> void YesNo(T b) { if (b) out("Yes"); else out("No"); } void decimal(int x) { cout << fixed << setprecision(x); } // ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);} // ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);} ll POW(ll a, ll b) { a %= mod; if (b == 0) return 1; if (b & 1) return a * POW(a, b - 1) % mod; ll k = POW(a, b / 2); return k * k % mod; } vi calc(ll x) { vi res; while (x > 0) { res.eb(x % 10); x /= 10; } reverse(all(res)); return res; } void solve() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; REP(i, 1, min(b + 1, n + 1)) chmax(ans, (a * i) / b - a * (i / b)); out(ans); } signed main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }
#include <bits/stdc++.h> using namespace std; // #pragma GCC optimize("Ofast") #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ub(v, k) (upper_bound(all(v), k) - v.begin()) #define fi first #define se second #define pi M_PI #define PQ(T) priority_queue<T> #define SPQ(T) priority_queue<T, vector<T>, greater<T>> using ll = long long; using P = pair<ll, ll>; using PP = tuple<ll, ll, ll>; using S = multiset<ll>; using vi = vector<ll>; using vvi = vector<vi>; using vvvi = vector<vvi>; const ll inf = 1001001001001001; const int INF = 1001001001; const int mod = 1000000007; const double eps = 1e-10; 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; } template <class T> void out(T a) { cout << a << '\n'; } template <class T> void outp(T a) { cout << '(' << a.fi << ',' << a.se << ')' << '\n'; } template <class T> void outvp(T v) { rep(i, v.size()) cout << '(' << v[i].fi << ',' << v[i].se << ')'; cout << '\n'; } template <class T> void outv(T v) { rep(i, v.size()) { if (i) cout << ' '; cout << v[i]; } cout << '\n'; } template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); } template <class T> bool isin(T x, T l, T r) { return (l) <= (x) && (x) <= (r); } template <class T> void YesNo(T b) { if (b) out("Yes"); else out("No"); } void decimal(int x) { cout << fixed << setprecision(x); } // ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);} // ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);} ll POW(ll a, ll b) { a %= mod; if (b == 0) return 1; if (b & 1) return a * POW(a, b - 1) % mod; ll k = POW(a, b / 2); return k * k % mod; } vi calc(ll x) { vi res; while (x > 0) { res.eb(x % 10); x /= 10; } reverse(all(res)); return res; } void solve() { ll a, b, n; cin >> a >> b >> n; if (n < b) out((a * n) / b - a * (n / b)); else out((a * (b - 1)) / b); } signed main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }
replace
88
91
88
92
TLE
p02696
C++
Time Limit Exceeded
#include <cmath> #include <iostream> #include <limits> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; long long Y = 0; long long Ans = 0; for (int x = 0; x <= N; x++) { Y = floor(A * x / B) - A * floor(x / B); if (Ans < Y) Ans = Y; } cout << Ans << endl; return 0; }
#include <cmath> #include <iostream> #include <limits> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; long long Y = 0; long long Ans = 0; if (N >= B) Ans = floor(A * (B - 1) / B) - A * floor((B - 1) / B); else if (N < B) Ans = floor(A * (N) / B) - A * floor(N / B); cout << Ans << endl; return 0; }
replace
11
16
11
15
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <tuple>#include <iostream> #include <tuple> #include <vector> #define FOR(i, a, b) for (int i = a; i < b; i++) #define REP(i, a, b) for (int i = a; i > b; i--) #define vint vector<int> #define vvint vector<vint> #define CST(x) cout << fixed << setprecision(x) // 小数点以下の桁数指定 #define ct(a) cout << a << endl static const double pi = 3.141592653589793; using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const int INF = 1e9 + 7; ll A, B, N; ll a[51], b[51], c[51], d[51]; ll ans = 0; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cin >> A >> B >> N; FOR(i, 1, N + 1) { if (i % B == 0) break; ans = max(ans, (A * i) / B); } cout << ans << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <tuple>#include <iostream> #include <tuple> #include <vector> #define FOR(i, a, b) for (int i = a; i < b; i++) #define REP(i, a, b) for (int i = a; i > b; i--) #define vint vector<int> #define vvint vector<vint> #define CST(x) cout << fixed << setprecision(x) // 小数点以下の桁数指定 #define ct(a) cout << a << endl static const double pi = 3.141592653589793; using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const int INF = 1e9 + 7; ll A, B, N; ll a[51], b[51], c[51], d[51]; ll ans = 0; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cin >> A >> B >> N; ll u = min(B - 1, N); cout << (A * u) / B << endl; return 0; }
replace
36
42
36
38
TLE
p02696
C++
Time Limit Exceeded
#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 INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ll A, B, N; cin >> A >> B >> N; ll ans = 0; ll tmp; for (ll i = 0; i < N + 1; i++) { tmp = A * i / B - A * (i / B); ans = max(ans, tmp); } cout << ans << endl; }
#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 INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ll A, B, N; cin >> A >> B >> N; ll ans = 0; ll tmp; tmp = min(B - 1, N); ans = A * tmp / B - A * (tmp / B); cout << ans << endl; }
replace
13
17
13
15
TLE
p02696
C++
Time Limit Exceeded
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long double ld; typedef long long ll; typedef vector<int> vint; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define fcout cout << fixed << setprecision(10) #define rep(i, n) for (int i = 0; i < (int)n; i++) #define mp(a, b) make_pair(a, b) #define pb push_back #define all(x) x.begin(), x.end() const ll inf = 1e18; const ll mod = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; // mod. m での a の逆元 a^(-1) を計算する。 ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (b > n) { ll tmp = a * n / b - (n / b) * a; ans = max(ans, tmp); } for (int i = b - 1; i <= n; i += b) { ll tmp = (a * i / b) - (i / b) * a; ans = max(ans, tmp); } cout << ans << endl; }
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long double ld; typedef long long ll; typedef vector<int> vint; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define fcout cout << fixed << setprecision(10) #define rep(i, n) for (int i = 0; i < (int)n; i++) #define mp(a, b) make_pair(a, b) #define pb push_back #define all(x) x.begin(), x.end() const ll inf = 1e18; const ll mod = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; // mod. m での a の逆元 a^(-1) を計算する。 ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (b > n) { ll tmp = a * n / b - (n / b) * a; ans = max(ans, tmp); } else { ll i = b - 1; ll tmp = (a * i / b) - (i / b) * a; ans = max(ans, tmp); } cout << ans << endl; }
replace
66
68
66
68
TLE
p02696
C++
Time Limit Exceeded
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { double a, b, n; cin >> a >> b >> n; int max = 0; double temp = min(b - 1, n); for (double i = 0; i <= temp; i++) { int v = floor(a * i / b) - a * floor(i / b); if (max < v) max = v; } cout << max << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { double a, b, n; cin >> a >> b >> n; int max = 0; double temp = min(b - 1, n); // for (double i = 0; i <= temp; i++) // { int v = floor(a * temp / b) - a * floor(temp / b); // if (max < v) // max = v; // } cout << v << endl; }
replace
11
17
11
18
TLE
p02696
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll a, b, n; scanf("%lld %lld %lld", &a, &b, &n); if (n % b == 0) b--; printf("%lld\n", a * n / b - a * (n / b)); }
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll a, b, n; scanf("%lld %lld %lld", &a, &b, &n); if (b <= n) n = n / b * b - 1; printf("%lld\n", a * n / b - a * (n / b)); }
replace
8
10
8
10
0
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <set> #include <vector> #define ll long long using namespace std; int main() { ll a, b, n; ll fx; ll res = 0; cin >> a >> b >> n; for (int x = 0; x <= (n < b ? n : b); ++x) { // cout << "x = " << x << ends; fx = floor(a * x / b) - a * floor(x / b); // cout << "f(x) = " << fx << endl; res = max(res, fx); } cout << res << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <set> #include <vector> #define ll long long using namespace std; int main() { ll a, b, n; ll fx; ll res = 0; cin >> a >> b >> n; /* for (int x = 0; x <= (n<b?n:b); ++x) { cout << "x = " << x << ends; fx = floor(a * x / b) - a * floor(x / b); cout << "f(x) = " << fx << endl; res = max(res, fx); } */ if (n < b) fx = floor(a * n / b) - a * floor(n / b); else fx = floor(a * (b - 1) / b) - a * floor((b - 1) / b); cout << fx << endl; return 0; }
replace
16
23
16
28
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> using namespace std; long long a, b, n, maxn, m; int main(void) { scanf("%lld%lld%lld", &a, &b, &n); for (int i = b - 1; i <= n; i++) { m = a * i / b - a * (i / b); maxn = max(maxn, m); i += b; } m = a * n / b - a * (n / b); maxn = max(maxn, m); printf("%lld", maxn); return 0; }
#include <algorithm> #include <cstdio> using namespace std; long long a, b, n, maxn, m; int main(void) { scanf("%lld%lld%lld", &a, &b, &n); if (b - 1 <= n) maxn = a * (b - 1) / b - a * ((b - 1) / b); m = a * n / b - a * (n / b); maxn = max(maxn, m); printf("%lld", maxn); return 0; }
replace
8
13
8
10
TLE
p02696
C++
Runtime Error
// @prefix atcoder // @description atcoder template #include <bits/stdc++.h> using namespace std; #define int long long // typedef //------------------------------------------ typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef vector<PII> VP; // rep //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) (x).begin(), (x).end() #define DEBUG(x) cerr << #x << ": " << x << '\n' #define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n' int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int modinv(int a, int m) { int b = m, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long extGCD(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } int a, b, n; signed main() { cin >> a >> b >> n; int res = 0; if (b > n) { cout << (a * n) / b - a * (n / b) << endl; return 0; } int i = n / (b - 1); res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res); i--; res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res); cout << res << endl; return 0; }
// @prefix atcoder // @description atcoder template #include <bits/stdc++.h> using namespace std; #define int long long // typedef //------------------------------------------ typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef vector<PII> VP; // rep //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) (x).begin(), (x).end() #define DEBUG(x) cerr << #x << ": " << x << '\n' #define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n' int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int modinv(int a, int m) { int b = m, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long extGCD(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } int a, b, n; signed main() { cin >> a >> b >> n; int res = 0; if (b > n) { cout << (a * n) / b - a * (n / b) << endl; return 0; } if (b != 1) { int i = n / (b - 1); res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res); i--; res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res); } else { res = 0; } cout << res << endl; return 0; }
replace
62
66
62
70
0
p02696
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int A, B, N; cin >> A >> B >> N; cout << N / (abs(A - B)) << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int A, B, N; cin >> A >> B >> N; if (B > N) { cout << (A * N) / B - (A * (N / B)) << endl; return 0; } else { int x = N - (N % B) - 1; cout << (A * x) / B - (A * (x / B)) << endl; return 0; } }
replace
7
8
7
15
0
p02696
C++
Time Limit Exceeded
/*我是萌新*/ #include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> typedef long long ll; const int mod = 1e9 + 7; using namespace std; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll a, b, n; while (cin >> a >> b >> n) { ll maxn = -mod, k = 0; for (ll i = 1; i <= min(n, b); i++) { if (maxn < ((a * i) / b - a * (i / b))) { maxn = ((a * i) / b - a * (i / b)); k = i; } } cout << maxn << '\n'; } }
/*我是萌新*/ #include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> typedef long long ll; const int mod = 1e9 + 7; using namespace std; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll a, b, n; while (cin >> a >> b >> n) { ll maxn = -mod, k = 0; /*for(ll i=1;i<=min(n,b);i++) { if(maxn<((a*i)/b-a*(i/b))) { maxn=((a*i)/b-a*(i/b)); k=i; } }*/ cout << (a * min(n, b - 1)) / b - a * (min(n, b - 1) / b) << '\n'; } }
replace
19
26
19
29
TLE
p02696
C++
Time Limit Exceeded
// author: zekigurbuz (Zeki Gurbuz) 2020 #pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define mp make_pair #define pb push_back #define lb lower_bound #define all(x) begin(x), end(x) const int N = 1e5 + 10; const int M = 1e9 + 7; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } template <class T> void ckmin(T &a, T b) { a = min(a, b); } template <class T> void ckmax(T &a, T b) { a = max(a, b); } void precomp() {} ll a, b, n; ll f(ll x) { return (a * x) / b - a * (x / b); } void solve() { cin >> a >> b >> n; ll lo = 1L, hi = n; while (hi - lo > 1L) { ll left = lo + (hi - lo) / 3L, right = hi - (hi - lo) / 3L; if (f(left) < f(right)) lo = left + 1; else hi = right; } ll cr = (lo + hi) / 2L; while (f(cr + 1L) > f(cr) && cr + 1L <= n) ++cr; while (f(cr - 1L) > f(cr) && cr - 1L >= 1L) --cr; cout << f(cr) << endl; // for (ll i = 1L; i <= n; i++) cout << i << " " << f(i) << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); precomp(); int t = 1; // cin >> t; for (int i = 1; i <= t; ++i) { solve(); } return 0; }
// author: zekigurbuz (Zeki Gurbuz) 2020 #pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define mp make_pair #define pb push_back #define lb lower_bound #define all(x) begin(x), end(x) const int N = 1e5 + 10; const int M = 1e9 + 7; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } template <class T> void ckmin(T &a, T b) { a = min(a, b); } template <class T> void ckmax(T &a, T b) { a = max(a, b); } void precomp() {} ll a, b, n; ll f(ll x) { return (a * x) / b - a * (x / b); } void solve() { cin >> a >> b >> n; cout << f(min(b - 1, n)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); precomp(); int t = 1; // cin >> t; for (int i = 1; i <= t; ++i) { solve(); } return 0; }
replace
31
46
31
32
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<ll>; using vii = vector<vi>; using Pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(x) ((int)x.size()) #define pb push_back #define mp make_pair #define mt make_tuple #define F first #define S second const int MOD = 1000000007; template <class T> void print(const T &t) { cout << t << endl; } 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; } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ll num = 0; for (ll i = n; i >= 1; i--) { if (ans > a * i / b) { break; } num = a * i / b - i / b * a; chmax(ans, num); } print(ans); }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<ll>; using vii = vector<vi>; using Pll = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(x) ((int)x.size()) #define pb push_back #define mp make_pair #define mt make_tuple #define F first #define S second const int MOD = 1000000007; template <class T> void print(const T &t) { cout << t << endl; } 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; } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (n < b) { ans = a * n / b - n / b * a; } else { ans = a * (b - 1) / b; } print(ans); }
replace
35
42
35
39
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18, MOD = 1e9 + 7; const int INT_INF = 1e9, INT_MOD = 1e9 + 7; #define rep(i, N) for (int i = 0; i < N; i++) typedef pair<int, int> Pi; typedef pair<double, double> P; signed main() { ll a, b, n; cin >> a >> b >> n; ll maxa = (a * n) / b, maxb = n / b; ll tmax = maxa - a * maxb; for (ll i = n;; i--) { if ((i + 1) % b == 0) { ll tmpa = (a * i) / b, tmpb = i / b; cout << max(tmax, tmpa - a * tmpb) << endl; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18, MOD = 1e9 + 7; const int INT_INF = 1e9, INT_MOD = 1e9 + 7; #define rep(i, N) for (int i = 0; i < N; i++) typedef pair<int, int> Pi; typedef pair<double, double> P; signed main() { ll a, b, n; cin >> a >> b >> n; ll maxa = (a * n) / b, maxb = n / b; ll tmax = maxa - a * maxb; if (n % b == 0) { ll tmpa = (a * (n - 1)) / b, tmpb = (n - 1) / b; cout << tmpa - a * tmpb << endl; } else { ll tmp = (n / b) * b - 1; ll tmpa = (a * tmp) / b, tmpb = tmp / b; cout << max(tmpa - a * tmpb, tmax) << endl; } return 0; }
replace
14
20
14
21
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <iterator> #include <math.h> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; #define endl ("\n") #define pi (3.141592653589) #define mod 1000000007 #define int int64_t #define float double #define pb push_back #define mp make_pair #define ff first #define ss second #define all(c) c.begin(), c.end() #define min3(a, b, c) min(c, min(a, b)) #define min4(a, b, c, d) min(d, min(c, min(a, b))) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define rep(i, n) for (int i = 0; i < n; i++) #define fast \ ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) struct debugger { template <typename T> debugger &operator,(const T &v) { cerr << v << " "; return *this; } } dbg; int32_t main() { fast; int A, B, N; cin >> A >> B >> N; int res = floor(A * N / B) - A * floor(N / B); for (int i = N - 1; i >= N / 10; i--) { if (floor(A * i / B) - A * floor(i / B) > res) { res = floor(A * i / B) - A * floor(i / B); } } cout << res; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <iterator> #include <math.h> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; #define endl ("\n") #define pi (3.141592653589) #define mod 1000000007 #define int int64_t #define float double #define pb push_back #define mp make_pair #define ff first #define ss second #define all(c) c.begin(), c.end() #define min3(a, b, c) min(c, min(a, b)) #define min4(a, b, c, d) min(d, min(c, min(a, b))) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define rep(i, n) for (int i = 0; i < n; i++) #define fast \ ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) struct debugger { template <typename T> debugger &operator,(const T &v) { cerr << v << " "; return *this; } } dbg; int32_t main() { fast; int A, B, N; cin >> A >> B >> N; int res = A * min(N, B - 1) / B; cout << res << endl; return 0; }
replace
40
47
40
43
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <tuple> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main(int argc, char *argv[]) { ll i; ll a, b, n; ll ans = 0; ll tmp, start; cin >> a >> b >> n; start = min(n, b - 1); for (i = start; i <= n; i += b) { tmp = (a * i) / b - a * (i / b); if (tmp > ans) ans = tmp; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <tuple> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main(int argc, char *argv[]) { ll i; ll a, b, n; ll ans = 0; ll tmp, start; cin >> a >> b >> n; start = min(n, b - 1); // for (i = start; i <= n; i += b) { // tmp = (a * i) / b - a * (i / b); // if (tmp > ans) // ans = tmp; // } if (n <= b - 1) { start = n; ans = (a * start) / b; } else { ll altans; start = n - (n % b + 1); altans = (a * n) / b - a * (n / b); ans = (a * start) / b - a * (start / b); ans = max(ans, altans); } cout << ans << endl; return 0; }
replace
20
24
20
34
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <deque> // deque #include <iomanip> // setprecision #include <iostream> // cout, endl, cin #include <map> // map #include <math.h> // sqrt #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vb = vector<bool>; using vll = vector<long long>; using pii = pair<int, int>; using psi = pair<string, int>; int main() { ld A, B, N; cin >> A >> B >> N; ll ans = 0; for (ll i = 1; i < N + 1; i++) { ll ansa = floor(A * i / B) - A * floor(i / B); if (ansa < ans) { break; } ans = ansa; } cout << ans << endl; }
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <deque> // deque #include <iomanip> // setprecision #include <iostream> // cout, endl, cin #include <map> // map #include <math.h> // sqrt #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vb = vector<bool>; using vll = vector<long long>; using pii = pair<int, int>; using psi = pair<string, int>; int main() { ld A, B, N; cin >> A >> B >> N; ll x = min(B - 1, N); ll ans = floor(A * x / B) - A * floor(x / B); cout << ans << endl; }
replace
27
35
27
29
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int a; int64_t b, n; cin >> a >> b >> n; int64_t p; if (n < b) { p = n; } else { p = b - 1; } int maximum = 0; for (int i = 1; i <= p; i++) { int64_t x = a * i / b - i / b * a; maximum = max((int)x, maximum); } cout << maximum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a; int64_t b, n; cin >> a >> b >> n; int64_t p; if (n < b) { p = n; } else { p = b - 1; } cout << a * p / b << endl; }
replace
13
19
13
14
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; using LLONG = long long; const LLONG MOD = 1000000007; int main() { LLONG A, B, N; cin >> A >> B >> N; LLONG ans = 0; for (LLONG x = N - max(A, B); x <= N; ++x) { LLONG t1 = A * x / B; LLONG t2 = x / B; t2 *= A; ans = max(ans, t1 - t2); } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; using LLONG = long long; const LLONG MOD = 1000000007; int main() { LLONG A, B, N; cin >> A >> B >> N; LLONG x = min(B - 1, N); LLONG t1 = A * x / B; LLONG t2 = x / B; t2 *= A; cout << t1 - t2 << endl; }
replace
18
26
18
23
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, m, n) for (int i = (m); i < (n); i++) #define fore(i, a) for (auto &i : a) #define debug(a, b) cout << "debug : " << a << " , " << b << endl using ll = long long; const ll INF = 1LL << 60; const ll mod = 1E9 + 7; int main() { ll a, b, n; cin >> a >> b >> n; ll M = 0; if (b < INF) { for (ll k = n; k >= max(n - b, (ll)0); k--) { ll kb = k / b; if (a * k / b - a * kb > M) M = a * k / b - a * kb; } } cout << M; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, m, n) for (int i = (m); i < (n); i++) #define fore(i, a) for (auto &i : a) #define debug(a, b) cout << "debug : " << a << " , " << b << endl using ll = long long; const ll INF = 1LL << 60; const ll mod = 1E9 + 7; int main() { ll a, b, n; cin >> a >> b >> n; auto f = [&](ll x) { ll xb = x / b; return a * x / b - a * xb; }; cout << max(f(n), f(n - 1 - n % b)); }
replace
13
22
13
18
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ul unsigned long long int #define ld long double #define f(t) for (ll i = 0; i < t; i++) #define vi vector<int> #define vl vector<ll> #define pb push_back #define ff first #define ss second #define MOD 1000000007 #define inf 4e18 #define EPS 1e-3 #define PI 3.1415926535897932385 #define display(v) f(v.size()) cout << v[i] << " " const double h = 1e-6; const int MAX_ = 200005; #define all(v) v.begin(), v.end() inline ll mul(ll a, ll b) { return (a * 1ll * b) % MOD; } inline ll sub(ll a, ll b) { ll c = a - b; if (c < 0) c += MOD; return c; } inline ll add(ll a, ll b) { ll c = a + b; if (c > MOD) c -= MOD; return c; } ll sqr(ll x) { return x * x; } //////////////////////*********CODE***********///////////////////// ////////////////////////////////////////////////////////////////// ll val(ll a, ll b, ll mid) { ll res = (a * mid) / b - a * (mid / b); return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll a, b, n; cin >> a >> b >> n; ll l = 1, r = n; ll ans = 0; while (l < r) { ll mid = (l + r) / 2; ll lft = val(a, b, l); ll rgh = val(a, b, r); ll mm = val(a, b, mid); ans = max({ans, lft, rgh}); if (mm >= lft) { l = mid + 1; ans = max(mm, ans); } else if (rgh <= mm) { r = mid - 1; ans = max(ans, mm); } } ll lf = val(a, b, l); ll rr = val(a, b, r); ans = max(ans, rr); ans = max(ans, lf); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ul unsigned long long int #define ld long double #define f(t) for (ll i = 0; i < t; i++) #define vi vector<int> #define vl vector<ll> #define pb push_back #define ff first #define ss second #define MOD 1000000007 #define inf 4e18 #define EPS 1e-3 #define PI 3.1415926535897932385 #define display(v) f(v.size()) cout << v[i] << " " const double h = 1e-6; const int MAX_ = 200005; #define all(v) v.begin(), v.end() inline ll mul(ll a, ll b) { return (a * 1ll * b) % MOD; } inline ll sub(ll a, ll b) { ll c = a - b; if (c < 0) c += MOD; return c; } inline ll add(ll a, ll b) { ll c = a + b; if (c > MOD) c -= MOD; return c; } ll sqr(ll x) { return x * x; } //////////////////////*********CODE***********///////////////////// ////////////////////////////////////////////////////////////////// ll val(ll a, ll b, ll mid) { ll res = (a * mid) / b - a * (mid / b); return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll a, b, n; cin >> a >> b >> n; ll go = min(b - 1, n); cout << val(a, b, go); return 0; }
replace
47
69
47
49
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) ll func(ll a, ll b, double x) { ll ans = (ll)(a * x / b) - a * (ll)(x / b); return ans; } int main() { ll A, B, N; cin >> A >> B >> N; ll mx = 0; for (int i = 1; i <= N; i++) { mx = max(mx, func(A, B, i)); } cout << mx << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) ll func(ll a, ll b, double x) { ll ans = (ll)(a * x / b) - a * (ll)(x / b); return ans; } int main() { ll A, B, N; cin >> A >> B >> N; ll x = min(N, B - 1); ll ans = (A * (x % B) - A * (x % B) % B) / B; cout << ans << endl; return 0; }
replace
20
25
20
23
TLE
p02696
C++
Time Limit Exceeded
#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>; const ll INF = 1e18; const int MX = 2005; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ; rep(x, min(n + 1, b)) { ans = max(ans, (a * x) / b - a * (x / b)); } cout << ans << endl; }
#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>; const ll INF = 1e18; const int MX = 2005; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = min(n, b - 1) * a / b; cout << ans << endl; }
replace
12
15
12
13
TLE
p02696
C++
Time Limit Exceeded
#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() { ll a, b, n; cin >> a >> b >> n; ll cost = 0; rep(x, n + 1) cost = max(cost, ll(floor(a * x / b) - a * floor(x / b))); cout << cost << endl; return 0; }
#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() { ll a, b, n; cin >> a >> b >> n; ll x = n; if (n >= b - 1) x = b - 1; ll ans = floor(a * x / b) - a * floor(x / b); cout << ans << endl; return 0; }
replace
9
12
9
14
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; typedef long long ll; int main() { ll a, b, n; cin >> a >> b >> n; ll flag = -inf; for (ll i = 1; i <= n; i++) { ll res = (a * i) / b; ll ans = a * (i / b); flag = max(res - ans, flag); } cout << flag << endl; return 0; }
#include <bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; typedef long long ll; int main() { ll a, b, n; cin >> a >> b >> n; ll flag = -inf; /*for(ll i=1;i<=n;i++){ flag = max(res-ans,flag); } */ if (n < b) { cout << (a * n) / b << endl; return 0; } else { flag = max(a * (b - 1) / b, flag); flag = max(flag, (a * n) / b - a * (n / b)); } cout << flag << endl; return 0; }
replace
10
14
10
23
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, n; cin >> a >> b >> n; long long int ans = INT_MIN; if (n < b) { ans = (a * n) / b; } else { long long int x = b - 1; long long int t; while (x <= n) { t = (a * x) / b - a * (x / b); ans = max(ans, t); x = x + b; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, n; cin >> a >> b >> n; long long int ans = INT_MIN; if (n < b) { ans = (a * n) / b; } else { long long int x = b - 1; ans = (a * x) / b; } cout << ans; return 0; }
replace
11
17
11
12
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cstdint> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) const long long mod = 1000000007; typedef long long int ll; typedef pair<ll, ll> P; const vector<int> di = {-1, 0, 1, 0}; const vector<int> dj = {0, 1, 0, -1}; const double PI = 3.14159265358979323846; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (n < b) { ans = (a * n) / b - a * (n / b); cout << ans << endl; } else { ll cnt = n / b; ll num = 0; for (ll i = (cnt / 2); i < cnt; i++) { num = b * (i + 1) - 1; ans = max(ans, (a * num) / b - a * (num / b)); } cout << ans << endl; } return 0; }
#include <algorithm> #include <bitset> #include <cstdint> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) const long long mod = 1000000007; typedef long long int ll; typedef pair<ll, ll> P; const vector<int> di = {-1, 0, 1, 0}; const vector<int> dj = {0, 1, 0, -1}; const double PI = 3.14159265358979323846; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (n < b) { ans = (a * n) / b - a * (n / b); cout << ans << endl; } else { ll cnt = n / b; ll num = 0; for (ll i = (cnt - 1); i < cnt; i++) { num = b * (i + 1) - 1; ans = max(ans, (a * num) / b - a * (num / b)); } cout << ans << endl; } return 0; }
replace
35
36
35
36
TLE
p02696
C++
Time Limit Exceeded
#pragma GCC optimize("Ofast") #include "bits/stdc++.h" using namespace std; using ll = long long; using ull = unsigned long long; #define PI 3.141592 #define MOD7 1000000007 #define LL_INF 9000000000000000000 #define LL_MINF -9000000000000000000 #define INT_INF 2000000000 #define INT_MINF -2000000000 #define all(a) (a).begin(), (a).end() #define fi first #define se second const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main() { int A; ull B, N; cin >> A >> B >> N; ull max_x = 0; for (ull x = 1; x <= min(N, B); x++) { max_x = max(max_x, ull((A * x) / B) - (ull(x / B)) * A); } cout << max_x << endl; }
#pragma GCC optimize("Ofast") #include "bits/stdc++.h" using namespace std; using ll = long long; using ull = unsigned long long; #define PI 3.141592 #define MOD7 1000000007 #define LL_INF 9000000000000000000 #define LL_MINF -9000000000000000000 #define INT_INF 2000000000 #define INT_MINF -2000000000 #define all(a) (a).begin(), (a).end() #define fi first #define se second const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main() { int A; ull B, N; cin >> A >> B >> N; cout << A * min(B - 1, N) / B << endl; }
replace
21
26
21
23
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <climits> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; #define INF INT_MAX / 3 #define REP(i, n) for (int i = 0; i < n; i++) int main() { ll N, A, B; cin >> A >> B >> N; ll answer = 0; for (ll i = 1; i <= N; i++) { answer = max((A * i) / B - A * (i / B), answer); } cout << answer << endl; return 0; }
#include <algorithm> #include <climits> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; #define INF INT_MAX / 3 #define REP(i, n) for (int i = 0; i < n; i++) int main() { ll N, A, B; cin >> A >> B >> N; ll answer = 0; if (N >= B - 1) { answer = (A * (B - 1)) / B; } else { answer = (A * N) / B; } cout << answer << endl; return 0; }
replace
21
23
21
25
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define pb push_back #define boostup \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); typedef long long int ll; using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ll x = 0; for (x = 0; x <= n; x++) { ll d; d = floor((a * x) / b) - a * floor(x / b); if (d > ans) { ans = d; } } cout << ans << endl; }
#include <bits/stdc++.h> #define pb push_back #define boostup \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); typedef long long int ll; using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = -10000000000000; ll x = min(n, b - 1); ll d; d = floor((a * x) / b) - a * floor(x / b); cout << d << endl; }
replace
11
21
11
16
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <numeric> #include <string> #include <vector> #define roop(i, n) for (int i = 0; i < n; i++) #define DIV 1000000007 using namespace std; using ll = long long int; using ull = unsigned long long; float myPower(int a, int n) { // aのn乗の計算 float x = 1; while (n > 0) { // 全てのbitが捨てられるまで if (n & 1) { // 一番右のbitが1のとき x *= a; } a *= a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる } return x; } ll combination(ll n, ll r) { if (n < 0 || r < 0 || r > n) return -1; if (n - r < r) r = n - r; if (r == 0) return 1; if (r == 1) return n; vector<ll> num(r); vector<ll> den(r); for (ll i = 0; i < r; i++) { num[i] = n - r + i + 1; den[i] = i + 1; } for (ll p = 2; p <= r; p++) { ll pivot = den[p - 1]; if (pivot > 1) { ll offset = (n - r) % p; for (ll k = p - 1; k < r; k += p) { num[k - offset] /= pivot; den[k] /= pivot; } } } ll result = 1; for (ll k = 0; k < r; k++) { if (num[k] > 1) result *= num[k]; } return result; } int main() { ll a, b, n; cin >> a >> b >> n; ll max = 0; for (ll x = 0; x <= n; x++) { ll colc = floor((a * x) / b) - a * floor(x / b); if (max <= colc) { max = colc; } } cout << max << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <numeric> #include <string> #include <vector> #define roop(i, n) for (int i = 0; i < n; i++) #define DIV 1000000007 using namespace std; using ll = long long int; using ull = unsigned long long; float myPower(int a, int n) { // aのn乗の計算 float x = 1; while (n > 0) { // 全てのbitが捨てられるまで if (n & 1) { // 一番右のbitが1のとき x *= a; } a *= a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる } return x; } ll combination(ll n, ll r) { if (n < 0 || r < 0 || r > n) return -1; if (n - r < r) r = n - r; if (r == 0) return 1; if (r == 1) return n; vector<ll> num(r); vector<ll> den(r); for (ll i = 0; i < r; i++) { num[i] = n - r + i + 1; den[i] = i + 1; } for (ll p = 2; p <= r; p++) { ll pivot = den[p - 1]; if (pivot > 1) { ll offset = (n - r) % p; for (ll k = p - 1; k < r; k += p) { num[k - offset] /= pivot; den[k] /= pivot; } } } ll result = 1; for (ll k = 0; k < r; k++) { if (num[k] > 1) result *= num[k]; } return result; } int main() { ll a, b, n; cin >> a >> b >> n; ll max = 0; if (b <= n) { max = floor((a * (b - 1)) / b) - a * floor((b - 1) / b); } else { max = floor((a * (n)) / b) - a * floor((n) / b); } cout << max << endl; return 0; }
replace
69
74
69
73
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> int main() { unsigned long long A, B, N; std::cin >> A >> B >> N; const double dB = (double)B; const double dAB = A / dB; unsigned long long x = 0; unsigned long long max = 0; for (int i = 0; x < N; ++i) { x = B * (i + 1) - 1; x = x > N ? N : x; const unsigned long long result = (unsigned long long)(x * dAB) - A * (unsigned long long)(x / dB); if (result > max) max = result; } std::cout << max << std::endl; return 0; }
#include <iostream> int main() { unsigned long long A, B, N; std::cin >> A >> B >> N; const double dB = (double)B; const double dAB = A / dB; unsigned long long x = 0; unsigned long long max = 0; for (int i = 0; x < N; ++i) { x = B * (i + 1) - 1; x = x > N ? N : x; const unsigned long long result = (unsigned long long)(x * dAB) - A * (unsigned long long)(x / dB); if (result > max) max = result; else break; } std::cout << max << std::endl; return 0; }
insert
20
20
20
22
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n, ans = 0; cin >> a >> b >> n; for (int x = 0; x <= n; x++) { long long left = a * x / b, right = x / b; ans = max(ans, left - a * right); if (right != 0) { break; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n, ans = 0; cin >> a >> b >> n; if (n < b) ans = a * n / b; else ans = a * (b - 1) / b; cout << ans << endl; return 0; }
replace
5
12
5
9
TLE
p02696
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = 100000000; #define rep1(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, k, n) for (ll i = k; i < (n); i++) int main() { ll a, b, n; cin >> a >> b >> n; vector<ll> A(n, -1); ll ans = -1; A[0] = 0; rep2(i, 1, n) { A[i] = (a * i) / b - a * (i / b); ans = max(ans, A[i]); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = 100000000; #define rep1(i, n) for (ll i = 0; i < (n); i++) #define rep2(i, k, n) for (ll i = k; i < (n); i++) int main() { ll a, b, n; cin >> a >> b >> n; ll ans = (a * (min(n, b - 1))) / b; cout << ans << endl; }
replace
11
18
11
12
0
p02696
C++
Runtime Error
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long int #define M 1000000007 #define pb push_back #define pf push_front #define ulli unsigned long long int #define what_is(x) cerr << #x << " is " << x << endl; #define pi 2 * acos(0.0) #define F first #define S second #define endl '\n' using namespace std; using namespace __gnu_pbds; const int INF = 1e18L + 5; const int LG = 20; const int N = 1e5 + 9; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int power(int x, int y) { int res = 1; while (y > 0) { if (y % 2 == 1) res = (res * x) % M; x = (x * x) % M; y = y / 2; } return res; } bool isvowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') return true; return false; } int32_t main() { // cout.precision(15); // cout.setf(ios::fixed,ios::floatfield); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int T = 1; // cin>>T; while (T--) { int i = 0, a, b, n, x; cin >> a >> b >> n; x = b - 1; i = n / (x * b); x = max(x, i * x); x = min(x, n); cout << (a * (x) / b - a * ((x) / b)) << endl; } }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long int #define M 1000000007 #define pb push_back #define pf push_front #define ulli unsigned long long int #define what_is(x) cerr << #x << " is " << x << endl; #define pi 2 * acos(0.0) #define F first #define S second #define endl '\n' using namespace std; using namespace __gnu_pbds; const int INF = 1e18L + 5; const int LG = 20; const int N = 1e5 + 9; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int power(int x, int y) { int res = 1; while (y > 0) { if (y % 2 == 1) res = (res * x) % M; x = (x * x) % M; y = y / 2; } return res; } bool isvowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') return true; return false; } int32_t main() { // cout.precision(15); // cout.setf(ios::fixed,ios::floatfield); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int T = 1; // cin>>T; while (T--) { int i = 0, a, b, n, x; cin >> a >> b >> n; x = b - 1; if (x != 0) i = n / (x * b); x = max(x, i * x); x = min(x, n); cout << (a * (x) / b - a * ((x) / b)) << endl; } }
replace
51
52
51
53
0
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (int i = 1; i <= n; i++) { ans = max(ans, ll(floor((a * i) / b) - a * floor(i / b))); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll x = n < b ? n : b - 1; ll ans = floor((a * x) / b) - a * floor(x / b); cout << ans << endl; return 0; }
replace
9
13
9
11
TLE
p02696
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int A; int64_t B, N; cin >> A >> B >> N; int ans = 0; for (int64_t i = 1; i <= min(B, N); ++i) { int x = floor(A * i / B) - A * floor(i / B); if (x > ans) { ans = x; } } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int A; int64_t B, N; cin >> A >> B >> N; cout << floor(A * min(B - 1, N) / B) - A * floor(min(B - 1, N) / B) << endl; return 0; }
replace
8
16
8
9
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define endl '\n' #define all(s) s.begin(), s.end() #define lowbit(x) (x & -x) #define rep(i, a, n) for (int i = a; i <= n; i++) #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define mem(a, b) memset(a, b, sizeof(a)) #define fi first #define se second #define pb push_back #define PI acos(-1.0) using namespace std; typedef long long ll; typedef pair<int, int> pii; const int mod = 1e9 + 7; const double eps = 1e-8; const int inf = 0x3f3f3f3f; const int N = 2e5 + 10; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = -1; for (int i = 1; i <= n; i++) { ll now = a * i / b - i / b * a; if (now > ans) ans = now; else if (now < ans) break; } cout << ans; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define endl '\n' #define all(s) s.begin(), s.end() #define lowbit(x) (x & -x) #define rep(i, a, n) for (int i = a; i <= n; i++) #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define mem(a, b) memset(a, b, sizeof(a)) #define fi first #define se second #define pb push_back #define PI acos(-1.0) using namespace std; typedef long long ll; typedef pair<int, int> pii; const int mod = 1e9 + 7; const double eps = 1e-8; const int inf = 0x3f3f3f3f; const int N = 2e5 + 10; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = -1; // for(int i=1;i<=n;i++){ // ll now=a*i/b-i/b*a; // if(now>ans) ans=now; // else if(now<ans) // } ll pos = b - 1; if (n < pos) pos = n; ans = a * pos / b - pos / b * a; cout << ans; }
replace
34
41
34
43
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pcc = pair<char, char>; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using tuplis = array<ll, 3>; template <class T> using pq = priority_queue<T, vector<T>, greater<T>>; const ll LINF = 0x1fffffffffffffff; const ll MINF = 0x7fffffffffff; const int INF = 0x3fffffff; const int MOD = 1000000007; const int MODD = 998244353; const ld DINF = numeric_limits<ld>::infinity(); const ld EPS = 1e-9; const ld PI = 3.1415926535897932; const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; #define overload4(_1, _2, _3, _4, name, ...) name #define overload3(_1, _2, _3, name, ...) name #define rep1(n) for (ll i = 0; i < n; ++i) // n回repeat #define rep2(i, n) for (ll i = 0; i < n; ++i) // n回repeat(変数指定) #define rep3(i, a, b) for (ll i = a; i < b; ++i) // a-bまでrepeat #define rep4(i, a, b, c) \ for (ll i = a; i < b; i += c) // a-bまで公差cでrepeat(等差数列で使えそう) #define rep(...) \ overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) // repeatまとめ #define rrep1(n) for (ll i = (n); i--;) #define rrep2(i, n) for (ll i = (n); i--;) #define rrep3(i, a, b) for (ll i = (b); i-- > (a);) #define rrep4(i, a, b, c) for (ll i = a + (b - a - 1) / c * c; i >= a; i -= c) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, \ rrep1)(__VA_ARGS__) // 逆repeatまとめ #define each1(i, a) for (auto &&i : a) #define each2(x, y, a) for (auto &&[x, y] : a) #define each3(x, y, z, a) for (auto &&[x, y, z] : a) #define each(...) \ overload4(__VA_ARGS__, each3, each2, \ each1)(__VA_ARGS__) // 配列の各要素の読み出し #define all1(i) begin(i), end(i) #define all2(i, a) begin(i), begin(i) + a #define all3(i, a, b) begin(i) + a, begin(i) + b #define all(...) \ overload3(__VA_ARGS__, all3, all2, \ all1)(__VA_ARGS__) // vectorの始めと終わりの読み取り #define rall1(i) (i).rbegin(), (i).rend() #define rall2(i, k) (i).rbegin(), (i).rbegin() + k #define rall3(i, a, b) (i).rbegin() + a, (i).rbegin() + b #define rall(...) \ overload3(__VA_ARGS__, rall3, rall2, \ rall1)(__VA_ARGS__) // 逆イテレータの取得(rbegin:末尾,rend:頭) #define sum(...) accumulate(all(__VA_ARGS__), 0LL) // vectorの合計 #define dsum(...) accumulate(all(__VA_ARGS__), 0.0L) #define elif else if #define unless(a) if (!(a)) #define mp make_pair #define mt make_tuple #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) // int型標準入力受付,以下LDまで同様 #define LL(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define ULL(...) \ ull __VA_ARGS__; \ in(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define CHR(...) \ char __VA_ARGS__; \ in(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ in(__VA_ARGS__) #define LD(...) \ ld __VA_ARGS__; \ in(__VA_ARGS__) #define Sort(a) sort(all(a)) // 昇順ソート #define Rev(a) reverse(all(a)) // 降順ソート #define Uniq(a) \ sort(all(a)); \ a.erase(unique(all(a)), end(a)) #define vec(type, name, ...) vector<type> name(__VA_ARGS__) // type型vectorの定義 #define VEC(type, name, size) \ vector<type> name(size); \ in(name) // type型vector(size指定)標準入力受付 #define vv(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define VV(type, name, h, w) \ vector<vector<type>> name(h, vector<type>(w)); \ in(name) #define IV(type, name, size) \ vector<pair<int, int>> name; \ for (int i = 0; i < size; i++) { \ int a_i; \ cin >> a_i; \ name.emplace_back(a_i, i); \ } // Indexつきvector(pair型Vector,(data,index)) #define vvv(type, name, h, w, ...) \ vector<vector<vector<type>>> name( \ h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) template <class T> auto min(const T &a) { return *min_element(all(a)); } template <class T> auto max(const T &a) { return *max_element(all(a)); } inline ll popcnt(ull a) { return __builtin_popcountll(a); } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } ll intpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b /= 2; } return ans; } ll modpow(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; } template <class T, class U> bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template <class T, class U> bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } vector<ll> iota(ll n) { vector<ll> a(n); iota(a.begin(), a.end(), 0); return a; } vector<pll> factor(ull x) { vector<pll> ans; for (ull i = 2; i * i <= x; i++) if (x % i == 0) { ans.push_back({i, 1}); while ((x /= i) % i == 0) ans.back().second++; } if (x != 1) ans.push_back({x, 1}); return ans; } map<ll, ll> factor_map(ull x) { map<ll, ll> ans; for (ull i = 2; i * i <= x; i++) if (x % i == 0) { ans[i] = 1; while ((x /= i) % i == 0) ans[i]++; } if (x != 1) ans[x] = 1; return ans; } vector<ll> divisor(ull x) { vector<ll> ans; for (ull i = 1; i * i <= x; i++) if (x % i == 0) ans.push_back(i); rrep(ans.size() - (ans.back() * ans.back() == x)) ans.push_back(x / ans[i]); return ans; } template <class T> unordered_map<T, ll> press(vector<T> &a) { auto b = a; sort(all(b)); b.erase(unique(all(b)), b.end()); unordered_map<T, ll> ans; rep(b.size()) ans[b[i]] = i; each(i, a) i = ans[i]; return ans; } template <class T> map<T, ll> press_map(vector<T> &a) { auto b = a; sort(all(b)); b.erase(unique(all(b)), b.end()); map<T, ll> ans; rep(b.size()) ans[b[i]] = i; each(i, a) i = ans[i]; return ans; } int scan() { return getchar(); } void scan(int &a) { scanf("%d", &a); } void scan(unsigned &a) { scanf("%u", &a); } void scan(long &a) { scanf("%ld", &a); } void scan(long long &a) { scanf("%lld", &a); } void scan(unsigned long long &a) { scanf("%llu", &a); } void scan(char &a) { do { a = getchar(); } while (a == ' ' || a == '\n'); } void scan(float &a) { scanf("%f", &a); } void scan(double &a) { scanf("%lf", &a); } void scan(long double &a) { scanf("%Lf", &a); } void scan(vector<bool> &a) { for (unsigned i = 0; i < a.size(); i++) { int b; scan(b); a[i] = b; } } void scan(char a[]) { scanf("%s", a); } void scan(string &a) { cin >> a; } template <class T> void scan(vector<T> &); template <class T, size_t size> void scan(array<T, size> &); template <class T, class L> void scan(pair<T, L> &); template <class T, size_t size> void scan(T (&)[size]); template <class T> void scan(vector<T> &a) { for (auto &&i : a) scan(i); } template <class T> void scan(deque<T> &a) { for (auto &&i : a) scan(i); } template <class T, size_t size> void scan(array<T, size> &a) { for (auto &&i : a) scan(i); } template <class T, class L> void scan(pair<T, L> &p) { scan(p.first); scan(p.second); } template <class T, size_t size> void scan(T (&a)[size]) { for (auto &&i : a) scan(i); } template <class T> void scan(T &a) { cin >> a; } void in() {} template <class Head, class... Tail> void in(Head &head, Tail &...tail) { scan(head); in(tail...); } void print() { putchar(' '); } void print(bool a) { printf("%d", a); } void print(int a) { printf("%d", a); } void print(unsigned a) { printf("%u", a); } void print(long a) { printf("%ld", a); } void print(long long a) { printf("%lld", a); } void print(unsigned long long a) { printf("%llu", a); } void print(char a) { printf("%c", a); } void print(char a[]) { printf("%s", a); } void print(const char a[]) { printf("%s", a); } void print(float a) { printf("%.15f", a); } void print(double a) { printf("%.15f", a); } void print(long double a) { printf("%.15Lf", a); } void print(const string &a) { for (auto &&i : a) print(i); } template <class T> void print(const vector<T> &); template <class T, size_t size> void print(const array<T, size> &); template <class T, class L> void print(const pair<T, L> &p); template <class T, size_t size> void print(const T (&)[size]); template <class T> void print(const vector<T> &a) { if (a.empty()) return; print(a[0]); for (auto i = a.begin(); ++i != a.end();) { putchar(' '); print(*i); } } template <class T> void print(const deque<T> &a) { if (a.empty()) return; print(a[0]); for (auto i = a.begin(); ++i != a.end();) { putchar(' '); print(*i); } } template <class T, size_t size> void print(const array<T, size> &a) { print(a[0]); for (auto i = a.begin(); ++i != a.end();) { putchar(' '); print(*i); } } template <class T, class L> void print(const pair<T, L> &p) { print(p.first); putchar(' '); print(p.second); } template <class T, size_t size> void print(const T (&a)[size]) { print(a[0]); for (auto i = a; ++i != end(a);) { putchar(' '); print(*i); } } template <class T> void print(const T &a) { cout << a; } int out() { putchar('\n'); return 0; } template <class T> int out(const T &t) { print(t); putchar('\n'); return 0; } // cout<<t<<endl template <class Head, class... Tail> int out(const Head &head, const Tail &...tail) { print(head); putchar(' '); out(tail...); return 0; } #ifdef DEBUG inline ll __lg(ull __n) { return sizeof(ull) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } #define debug(...) \ { \ print(#__VA_ARGS__); \ print(":"); \ out(__VA_ARGS__); \ } #else #define debug(...) void(0) #endif int first(bool i = true) { return out(i ? "first" : "second"); } // iがfirstか判断,以下同様 int yes(bool i = true) { return out(i ? "yes" : "no"); } int Yes(bool i = true) { return out(i ? "Yes" : "No"); } int No() { return out("No"); } int YES(bool i = true) { return out(i ? "YES" : "NO"); } int NO() { return out("NO"); } int Yay(bool i = true) { return out(i ? "Yay!" : ":("); } int possible(bool i = true) { return out(i ? "possible" : "impossible"); } int Possible(bool i = true) { return out(i ? "Possible" : "Impossible"); } int POSSIBLE(bool i = true) { return out(i ? "POSSIBLE" : "IMPOSSIBLE"); } void Case(ll i) { printf("Case #%lld: ", i); } #define bSearch(v, k) \ binary_search(all(v), k) // ソートされた配列vの中の要素にkがあるか(boolean) #define lowB(v, k) \ lower_bound(all(v), \ k) // ソートされた配列vの中の要素のうちk以上かつ最小のイテレータ #define DLbetB(v, k) lowB(v, k) - v.begin() // 先頭からの距離 #define DLbetE(v, k) v.end() - lowB(v, k) // 末尾からの距離 #define uppB(v, k) \ upper_bound( \ all(v), \ k) // ソートされた配列vの中の要素のうちkより大きいかつ最小のイテレータ #define DUbetB(v, k) uppB(v, k) - v.begin() // 先頭からの距離 #define DUbetE(v, k) v.end() - uppB(v, k) // 末尾からの距離 #define Cnt(v, k) count(all(v), k) // 配列vの中で要素kが何個あるかを返す(size_t) #define CntIf(v, l) \ count_if(all(v), \ l) // 配列vの中で条件式(lambda式)を満たす個数を返す(ex.int num = // count_if(v.begin(), v.end(), [](int i){return i % 3 == 0;});) #define Sort2D(myVec, i) \ sort(myVec.begin(), myVec.end(), \ [](const vector<int> &alpha, const vector<int> &beta) { \ return alpha[i] < beta[i]; \ }); // i列めでソート /*ページのソースを表示->command+F->問題文 で問題文コピペする */ ll floor(ld x) { ll ans = ll(x); return ans; } signed main() { /*以下コード*/ LL(A, B, N); ll ans = -LINF; // ll x=9; if (N < B - 1) ans = floor(A * N / B) - A * floor(N / B); else rep(x, B - 1, N + 1, B) if (chmax(ans, floor(A * x / B) - A * floor(x / B))) ans = floor(A * x / B) - A * floor(x / B); out(ans); }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pcc = pair<char, char>; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using tuplis = array<ll, 3>; template <class T> using pq = priority_queue<T, vector<T>, greater<T>>; const ll LINF = 0x1fffffffffffffff; const ll MINF = 0x7fffffffffff; const int INF = 0x3fffffff; const int MOD = 1000000007; const int MODD = 998244353; const ld DINF = numeric_limits<ld>::infinity(); const ld EPS = 1e-9; const ld PI = 3.1415926535897932; const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; #define overload4(_1, _2, _3, _4, name, ...) name #define overload3(_1, _2, _3, name, ...) name #define rep1(n) for (ll i = 0; i < n; ++i) // n回repeat #define rep2(i, n) for (ll i = 0; i < n; ++i) // n回repeat(変数指定) #define rep3(i, a, b) for (ll i = a; i < b; ++i) // a-bまでrepeat #define rep4(i, a, b, c) \ for (ll i = a; i < b; i += c) // a-bまで公差cでrepeat(等差数列で使えそう) #define rep(...) \ overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) // repeatまとめ #define rrep1(n) for (ll i = (n); i--;) #define rrep2(i, n) for (ll i = (n); i--;) #define rrep3(i, a, b) for (ll i = (b); i-- > (a);) #define rrep4(i, a, b, c) for (ll i = a + (b - a - 1) / c * c; i >= a; i -= c) #define rrep(...) \ overload4(__VA_ARGS__, rrep4, rrep3, rrep2, \ rrep1)(__VA_ARGS__) // 逆repeatまとめ #define each1(i, a) for (auto &&i : a) #define each2(x, y, a) for (auto &&[x, y] : a) #define each3(x, y, z, a) for (auto &&[x, y, z] : a) #define each(...) \ overload4(__VA_ARGS__, each3, each2, \ each1)(__VA_ARGS__) // 配列の各要素の読み出し #define all1(i) begin(i), end(i) #define all2(i, a) begin(i), begin(i) + a #define all3(i, a, b) begin(i) + a, begin(i) + b #define all(...) \ overload3(__VA_ARGS__, all3, all2, \ all1)(__VA_ARGS__) // vectorの始めと終わりの読み取り #define rall1(i) (i).rbegin(), (i).rend() #define rall2(i, k) (i).rbegin(), (i).rbegin() + k #define rall3(i, a, b) (i).rbegin() + a, (i).rbegin() + b #define rall(...) \ overload3(__VA_ARGS__, rall3, rall2, \ rall1)(__VA_ARGS__) // 逆イテレータの取得(rbegin:末尾,rend:頭) #define sum(...) accumulate(all(__VA_ARGS__), 0LL) // vectorの合計 #define dsum(...) accumulate(all(__VA_ARGS__), 0.0L) #define elif else if #define unless(a) if (!(a)) #define mp make_pair #define mt make_tuple #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) // int型標準入力受付,以下LDまで同様 #define LL(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define ULL(...) \ ull __VA_ARGS__; \ in(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ in(__VA_ARGS__) #define CHR(...) \ char __VA_ARGS__; \ in(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ in(__VA_ARGS__) #define LD(...) \ ld __VA_ARGS__; \ in(__VA_ARGS__) #define Sort(a) sort(all(a)) // 昇順ソート #define Rev(a) reverse(all(a)) // 降順ソート #define Uniq(a) \ sort(all(a)); \ a.erase(unique(all(a)), end(a)) #define vec(type, name, ...) vector<type> name(__VA_ARGS__) // type型vectorの定義 #define VEC(type, name, size) \ vector<type> name(size); \ in(name) // type型vector(size指定)標準入力受付 #define vv(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define VV(type, name, h, w) \ vector<vector<type>> name(h, vector<type>(w)); \ in(name) #define IV(type, name, size) \ vector<pair<int, int>> name; \ for (int i = 0; i < size; i++) { \ int a_i; \ cin >> a_i; \ name.emplace_back(a_i, i); \ } // Indexつきvector(pair型Vector,(data,index)) #define vvv(type, name, h, w, ...) \ vector<vector<vector<type>>> name( \ h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) template <class T> auto min(const T &a) { return *min_element(all(a)); } template <class T> auto max(const T &a) { return *max_element(all(a)); } inline ll popcnt(ull a) { return __builtin_popcountll(a); } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } ll intpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b /= 2; } return ans; } ll modpow(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; } template <class T, class U> bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template <class T, class U> bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } vector<ll> iota(ll n) { vector<ll> a(n); iota(a.begin(), a.end(), 0); return a; } vector<pll> factor(ull x) { vector<pll> ans; for (ull i = 2; i * i <= x; i++) if (x % i == 0) { ans.push_back({i, 1}); while ((x /= i) % i == 0) ans.back().second++; } if (x != 1) ans.push_back({x, 1}); return ans; } map<ll, ll> factor_map(ull x) { map<ll, ll> ans; for (ull i = 2; i * i <= x; i++) if (x % i == 0) { ans[i] = 1; while ((x /= i) % i == 0) ans[i]++; } if (x != 1) ans[x] = 1; return ans; } vector<ll> divisor(ull x) { vector<ll> ans; for (ull i = 1; i * i <= x; i++) if (x % i == 0) ans.push_back(i); rrep(ans.size() - (ans.back() * ans.back() == x)) ans.push_back(x / ans[i]); return ans; } template <class T> unordered_map<T, ll> press(vector<T> &a) { auto b = a; sort(all(b)); b.erase(unique(all(b)), b.end()); unordered_map<T, ll> ans; rep(b.size()) ans[b[i]] = i; each(i, a) i = ans[i]; return ans; } template <class T> map<T, ll> press_map(vector<T> &a) { auto b = a; sort(all(b)); b.erase(unique(all(b)), b.end()); map<T, ll> ans; rep(b.size()) ans[b[i]] = i; each(i, a) i = ans[i]; return ans; } int scan() { return getchar(); } void scan(int &a) { scanf("%d", &a); } void scan(unsigned &a) { scanf("%u", &a); } void scan(long &a) { scanf("%ld", &a); } void scan(long long &a) { scanf("%lld", &a); } void scan(unsigned long long &a) { scanf("%llu", &a); } void scan(char &a) { do { a = getchar(); } while (a == ' ' || a == '\n'); } void scan(float &a) { scanf("%f", &a); } void scan(double &a) { scanf("%lf", &a); } void scan(long double &a) { scanf("%Lf", &a); } void scan(vector<bool> &a) { for (unsigned i = 0; i < a.size(); i++) { int b; scan(b); a[i] = b; } } void scan(char a[]) { scanf("%s", a); } void scan(string &a) { cin >> a; } template <class T> void scan(vector<T> &); template <class T, size_t size> void scan(array<T, size> &); template <class T, class L> void scan(pair<T, L> &); template <class T, size_t size> void scan(T (&)[size]); template <class T> void scan(vector<T> &a) { for (auto &&i : a) scan(i); } template <class T> void scan(deque<T> &a) { for (auto &&i : a) scan(i); } template <class T, size_t size> void scan(array<T, size> &a) { for (auto &&i : a) scan(i); } template <class T, class L> void scan(pair<T, L> &p) { scan(p.first); scan(p.second); } template <class T, size_t size> void scan(T (&a)[size]) { for (auto &&i : a) scan(i); } template <class T> void scan(T &a) { cin >> a; } void in() {} template <class Head, class... Tail> void in(Head &head, Tail &...tail) { scan(head); in(tail...); } void print() { putchar(' '); } void print(bool a) { printf("%d", a); } void print(int a) { printf("%d", a); } void print(unsigned a) { printf("%u", a); } void print(long a) { printf("%ld", a); } void print(long long a) { printf("%lld", a); } void print(unsigned long long a) { printf("%llu", a); } void print(char a) { printf("%c", a); } void print(char a[]) { printf("%s", a); } void print(const char a[]) { printf("%s", a); } void print(float a) { printf("%.15f", a); } void print(double a) { printf("%.15f", a); } void print(long double a) { printf("%.15Lf", a); } void print(const string &a) { for (auto &&i : a) print(i); } template <class T> void print(const vector<T> &); template <class T, size_t size> void print(const array<T, size> &); template <class T, class L> void print(const pair<T, L> &p); template <class T, size_t size> void print(const T (&)[size]); template <class T> void print(const vector<T> &a) { if (a.empty()) return; print(a[0]); for (auto i = a.begin(); ++i != a.end();) { putchar(' '); print(*i); } } template <class T> void print(const deque<T> &a) { if (a.empty()) return; print(a[0]); for (auto i = a.begin(); ++i != a.end();) { putchar(' '); print(*i); } } template <class T, size_t size> void print(const array<T, size> &a) { print(a[0]); for (auto i = a.begin(); ++i != a.end();) { putchar(' '); print(*i); } } template <class T, class L> void print(const pair<T, L> &p) { print(p.first); putchar(' '); print(p.second); } template <class T, size_t size> void print(const T (&a)[size]) { print(a[0]); for (auto i = a; ++i != end(a);) { putchar(' '); print(*i); } } template <class T> void print(const T &a) { cout << a; } int out() { putchar('\n'); return 0; } template <class T> int out(const T &t) { print(t); putchar('\n'); return 0; } // cout<<t<<endl template <class Head, class... Tail> int out(const Head &head, const Tail &...tail) { print(head); putchar(' '); out(tail...); return 0; } #ifdef DEBUG inline ll __lg(ull __n) { return sizeof(ull) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } #define debug(...) \ { \ print(#__VA_ARGS__); \ print(":"); \ out(__VA_ARGS__); \ } #else #define debug(...) void(0) #endif int first(bool i = true) { return out(i ? "first" : "second"); } // iがfirstか判断,以下同様 int yes(bool i = true) { return out(i ? "yes" : "no"); } int Yes(bool i = true) { return out(i ? "Yes" : "No"); } int No() { return out("No"); } int YES(bool i = true) { return out(i ? "YES" : "NO"); } int NO() { return out("NO"); } int Yay(bool i = true) { return out(i ? "Yay!" : ":("); } int possible(bool i = true) { return out(i ? "possible" : "impossible"); } int Possible(bool i = true) { return out(i ? "Possible" : "Impossible"); } int POSSIBLE(bool i = true) { return out(i ? "POSSIBLE" : "IMPOSSIBLE"); } void Case(ll i) { printf("Case #%lld: ", i); } #define bSearch(v, k) \ binary_search(all(v), k) // ソートされた配列vの中の要素にkがあるか(boolean) #define lowB(v, k) \ lower_bound(all(v), \ k) // ソートされた配列vの中の要素のうちk以上かつ最小のイテレータ #define DLbetB(v, k) lowB(v, k) - v.begin() // 先頭からの距離 #define DLbetE(v, k) v.end() - lowB(v, k) // 末尾からの距離 #define uppB(v, k) \ upper_bound( \ all(v), \ k) // ソートされた配列vの中の要素のうちkより大きいかつ最小のイテレータ #define DUbetB(v, k) uppB(v, k) - v.begin() // 先頭からの距離 #define DUbetE(v, k) v.end() - uppB(v, k) // 末尾からの距離 #define Cnt(v, k) count(all(v), k) // 配列vの中で要素kが何個あるかを返す(size_t) #define CntIf(v, l) \ count_if(all(v), \ l) // 配列vの中で条件式(lambda式)を満たす個数を返す(ex.int num = // count_if(v.begin(), v.end(), [](int i){return i % 3 == 0;});) #define Sort2D(myVec, i) \ sort(myVec.begin(), myVec.end(), \ [](const vector<int> &alpha, const vector<int> &beta) { \ return alpha[i] < beta[i]; \ }); // i列めでソート /*ページのソースを表示->command+F->問題文 で問題文コピペする */ ll floor(ld x) { ll ans = ll(x); return ans; } signed main() { /*以下コード*/ LL(A, B, N); ll ans = -LINF; // ll x=9; if (N < B - 1) ans = floor(A * N / B) - A * floor(N / B); else ans = floor(A * (B - 1) / B); // rep(x,B-1,N+1,B)if(chmax(ans,floor(A*x/B)-A*floor(x/B)))ans=floor(A*x/B)-A*floor(x/B); out(ans); }
replace
405
407
405
407
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (ll x = 0; x <= n; x++) { if (x % b == 0) continue; ll l = (a * x) / b; ll r = a * (x / b); ans = max(ans, l - r); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll a, b, n; cin >> a >> b >> n; ll x = min(n, b - 1); cout << a * x / b - a * (x / b) << endl; return 0; }
replace
7
18
7
10
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int64_t A, B, N, ans; cin >> A >> B >> N; ans = 0; for (int64_t i = N - B - 1; i <= N; i++) { int64_t x = A * i / B - A * (i / B); if (ans < x) { ans = x; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t A, B, N, ans; cin >> A >> B >> N; ans = 0; if (N < B) { ans = A * N / B; } else { ans = A * ((N / B * B) - 1) / B - A * (((N / B * B) - 1) / B); } cout << ans << endl; }
replace
7
12
7
11
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> // below comment for pbds #include <ext/pb_ds/assoc_container.hpp> // to use it make ordered_set #include <ext/pb_ds/tree_policy.hpp> // all set fnct + = 1. order_of_key(x); // number of #define ll long long // element strictly smaller than it; #define ld \ long double // 2. find_by_order(x),pointer el at x pos after sort use as // s.f(); #define ordered_set \ tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> using namespace std; using namespace __gnu_pbds; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.flush(); ll t = 1; ll CaseN = 1; // cin>>t; while (t--) { ll a, b, n; ll ans = 0; cin >> a >> b >> n; ll x; // ll k = (a*n)/b; // ll x = b*k/a ; // bins=ary search in n // ax = bk ; k - k/a; ll s = 0; ll e = n; // x range while (s <= e) { // cout<<"--"<<endl; ll mid = s + (e - s) / 2; ll Ex = (a * mid / b); ll p = (mid / b); Ex = Ex - (a * p); // ans = max(Ex,ans); if (mid % b == 0) // && (a*x)%b!=0; { s++; } else { if (Ex >= ans) { s = mid + 1; ans = Ex; } else { e = mid - 1; } } } // ll Ans =0; // for(ll i=0;i<=n;i++) //{ // x =i; // ll Ex = (a*x/b); // ll p = x/b; // Ex = Ex - (a*p) ; // cout<<Ex<<endl; // Ans = max(Ans,Ex); //} // cout<<"Case #"<<CaseN<<": "; CaseN++; // print your ans below; cout << ans << endl; } return 0; } // if(ans) //{ cout<<"YES"<<endl; } // else //{cout<<"NO"<<endl;}
#include <bits/stdc++.h> // below comment for pbds #include <ext/pb_ds/assoc_container.hpp> // to use it make ordered_set #include <ext/pb_ds/tree_policy.hpp> // all set fnct + = 1. order_of_key(x); // number of #define ll long long // element strictly smaller than it; #define ld \ long double // 2. find_by_order(x),pointer el at x pos after sort use as // s.f(); #define ordered_set \ tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> using namespace std; using namespace __gnu_pbds; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.flush(); ll t = 1; ll CaseN = 1; // cin>>t; while (t--) { ll a, b, n; ll ans = 0; cin >> a >> b >> n; ll x; // ll k = (a*n)/b; // ll x = b*k/a ; // bins=ary search in n // ax = bk ; k - k/a; ll s = 0; ll e = n; // x range while (s <= e) { // cout<<"--"<<endl; ll mid = s + (e - s) / 2; ll Ex = (a * mid / b); ll p = (mid / b); Ex = Ex - (a * p); // ans = max(Ex,ans); if (mid % b == 0 && (a * mid) % b != 0) { s++; } else { if (Ex >= ans) { s = mid + 1; ans = Ex; } else { e = mid - 1; } } } // ll Ans =0; // for(ll i=0;i<=n;i++) //{ // x =i; // ll Ex = (a*x/b); // ll p = x/b; // Ex = Ex - (a*p) ; // cout<<Ex<<endl; // Ans = max(Ans,Ex); //} // cout<<"Case #"<<CaseN<<": "; CaseN++; // print your ans below; cout << ans << endl; } return 0; } // if(ans) //{ cout<<"YES"<<endl; } // else //{cout<<"NO"<<endl;}
replace
40
42
40
41
TLE
p02696
C++
Time Limit Exceeded
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout << fixed << setprecision(10) #define ALL(a) (a).begin(), (a).end() #define ALLR(a) (a).rbegin(), (a).rend() #define spa << " " << #define fi first #define se second #define MP make_pair #define MT make_tuple #define PB push_back #define EB emplace_back #define rep(i, n, m) for (ll i = (n); i < (ll)(m); i++) #define rrep(i, n, m) for (ll i = (ll)(m)-1; i >= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD1 = 1e9 + 7; const ll MOD9 = 998244353; const ll INF = 1e18; using P = pair<ll, ll>; template <typename T1, typename T2> bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } else return false; } template <typename T1, typename T2> bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } else return false; } ll median(ll a, ll b, ll c) { return a + b + c - max({a, b, c}) - min({a, b, c}); } void ans1(bool x) { if (x) cout << "Yes" << endl; else cout << "No" << endl; } void ans2(bool x) { if (x) cout << "YES" << endl; else cout << "NO" << endl; } void ans3(bool x) { if (x) cout << "Yay!" << endl; else cout << ":(" << endl; } template <typename T1, typename T2> void ans(bool x, T1 y, T2 z) { if (x) cout << y << endl; else cout << z << endl; } template <typename T> void debug(vector<vector<T>> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { cout << v[i][0]; for (ll j = 1; j < w; j++) cout spa v[i][j]; cout << endl; } }; void debug(vector<string> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) cout << v[i][j]; cout << endl; } }; template <typename T> void debug(vector<T> &v, ll n) { if (n != 0) cout << v[0]; for (ll i = 1; i < n; i++) cout spa v[i]; cout << endl; }; template <typename T> vector<vector<T>> vec(ll x, ll y, T w) { vector<vector<T>> v(x, vector<T>(y, w)); return v; } ll gcd(ll x, ll y) { ll r; while (y != 0 && (r = x % y) != 0) { x = y; y = r; } return y == 0 ? x : y; } vector<ll> dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector<ll> dy = {0, 1, 0, -1, 1, -1, 1, -1}; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << " " << p.second; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ll res = 0, buf = 0; bool judge = true; ll a, b, n; cin >> a >> b >> n; ll now = 0; res = -INF; while (now <= n) { ll tmp = now / b; ll mx = b * (tmp + 1) - 1; chmin(mx, n); // cout<<now spa tmp spa mx<<endl; chmax(res, a * mx / b - a * (mx / b)); now = mx + 1; } cout << res << endl; return 0; }
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout << fixed << setprecision(10) #define ALL(a) (a).begin(), (a).end() #define ALLR(a) (a).rbegin(), (a).rend() #define spa << " " << #define fi first #define se second #define MP make_pair #define MT make_tuple #define PB push_back #define EB emplace_back #define rep(i, n, m) for (ll i = (n); i < (ll)(m); i++) #define rrep(i, n, m) for (ll i = (ll)(m)-1; i >= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD1 = 1e9 + 7; const ll MOD9 = 998244353; const ll INF = 1e18; using P = pair<ll, ll>; template <typename T1, typename T2> bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } else return false; } template <typename T1, typename T2> bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } else return false; } ll median(ll a, ll b, ll c) { return a + b + c - max({a, b, c}) - min({a, b, c}); } void ans1(bool x) { if (x) cout << "Yes" << endl; else cout << "No" << endl; } void ans2(bool x) { if (x) cout << "YES" << endl; else cout << "NO" << endl; } void ans3(bool x) { if (x) cout << "Yay!" << endl; else cout << ":(" << endl; } template <typename T1, typename T2> void ans(bool x, T1 y, T2 z) { if (x) cout << y << endl; else cout << z << endl; } template <typename T> void debug(vector<vector<T>> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { cout << v[i][0]; for (ll j = 1; j < w; j++) cout spa v[i][j]; cout << endl; } }; void debug(vector<string> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) cout << v[i][j]; cout << endl; } }; template <typename T> void debug(vector<T> &v, ll n) { if (n != 0) cout << v[0]; for (ll i = 1; i < n; i++) cout spa v[i]; cout << endl; }; template <typename T> vector<vector<T>> vec(ll x, ll y, T w) { vector<vector<T>> v(x, vector<T>(y, w)); return v; } ll gcd(ll x, ll y) { ll r; while (y != 0 && (r = x % y) != 0) { x = y; y = r; } return y == 0 ? x : y; } vector<ll> dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector<ll> dy = {0, 1, 0, -1, 1, -1, 1, -1}; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << " " << p.second; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ll res = 0, buf = 0; bool judge = true; ll a, b, n; cin >> a >> b >> n; ll now = 0; res = -INF; while (now <= n) { ll tmp = now / b; ll mx = b * (tmp + 1) - 1; chmin(mx, n); // cout<<now spa tmp spa mx<<endl; chmax(res, a * mx / b - a * (mx / b)); now = mx + 1; buf++; if (buf >= 1000000) break; } cout << res << endl; return 0; }
insert
127
127
127
130
TLE
p02696
C++
Time Limit Exceeded
/* auth - @sportykush */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // #define mp make_pair #define bug(v) cerr << #v << " = " << (v) << endl; #define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end()) #define pb emplace_back #define vii vector<int> #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define pll pair<ll, ll> #define pii pair<int, int> #define pq priority_queue<int> #define khtm "\n" #define F first #define S second #define fr(i, a, n) for (i = a; i < n; i++) #define mem(arr, l) memset(arr, l, sizeof arr) #define ALL(x) x.begin(), x.end() #define frr(i, a, n) for (i = n - 1; i >= a; i--) #define fast \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define testcase \ ll T; \ cin >> T; \ while (T--) const int MAX = 1e6 + 2; const ll inf = 1e18; const int N = 1010; // const ll mod = 998244353 ; const ll mod = 1e9 + 7; inline ll add(ll a, ll b) { a += b; if (a >= mod) a -= mod; return a; } inline ll mul(ll a, ll b) { return ((a % mod) * 1ll * b) % mod; } inline ll power(ll a, ll b) { ll rt = 1; while (b > 0) { if (b & 1) rt = mul(rt, a); a = mul(a, a); b >>= 1; } return rt; } /* important builtin functions __gcd(value1, value2) __builtin_ffs(x) Number of leading zeroes: __builtin_clz(x) Number of trailing zeroes : __builtin_ctz(x) Number of set bits: __builtin_popcount(x) */ ll i, j, k, l, m, r, n; ll a[MAX], b[MAX]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // cout << setprecision(15) << fixed; fast cin >> l >> r >> n; ll ans = 0; frr(i, sqrt(n), n + 1) { ll tmp1 = (l * i) / r; ll tmp2 = i / r; k = (tmp1 - l * tmp2); ans = max(k, ans); // bug(k) } cout << ans; #ifndef ONLINE_JUDGE cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s"; #endif return 0; }
/* auth - @sportykush */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // #define mp make_pair #define bug(v) cerr << #v << " = " << (v) << endl; #define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end()) #define pb emplace_back #define vii vector<int> #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define pll pair<ll, ll> #define pii pair<int, int> #define pq priority_queue<int> #define khtm "\n" #define F first #define S second #define fr(i, a, n) for (i = a; i < n; i++) #define mem(arr, l) memset(arr, l, sizeof arr) #define ALL(x) x.begin(), x.end() #define frr(i, a, n) for (i = n - 1; i >= a; i--) #define fast \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define testcase \ ll T; \ cin >> T; \ while (T--) const int MAX = 1e6 + 2; const ll inf = 1e18; const int N = 1010; // const ll mod = 998244353 ; const ll mod = 1e9 + 7; inline ll add(ll a, ll b) { a += b; if (a >= mod) a -= mod; return a; } inline ll mul(ll a, ll b) { return ((a % mod) * 1ll * b) % mod; } inline ll power(ll a, ll b) { ll rt = 1; while (b > 0) { if (b & 1) rt = mul(rt, a); a = mul(a, a); b >>= 1; } return rt; } /* important builtin functions __gcd(value1, value2) __builtin_ffs(x) Number of leading zeroes: __builtin_clz(x) Number of trailing zeroes : __builtin_ctz(x) Number of set bits: __builtin_popcount(x) */ ll i, j, k, l, m, r, n; ll a[MAX], b[MAX]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // cout << setprecision(15) << fixed; fast cin >> l >> r >> n; ll ans = 0; if (r > n) { ll tmp1 = (l * n) / r; ll tmp2 = n / r; ans = (tmp1 - l * tmp2); } else { n = r - 1; ll tmp1 = (l * n) / r; ll tmp2 = n / r; ans = (tmp1 - l * tmp2); } cout << ans; #ifndef ONLINE_JUDGE cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s"; #endif return 0; }
replace
90
96
90
101
TLE
p02696
C++
Time Limit Exceeded
#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() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; rep(i, n + 1) { ans = max(ans, a * i / b - a * (i / b)); } cout << ans << endl; return 0; }
#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() { ll a, b, n; cin >> a >> b >> n; double low = 0; // 右側 double high = n + 1; auto f = [&](ll i) { return a * i / b - a * (i / b); }; int cnt = 10000; while (--cnt) { double c1 = (low * 2 + high) / 3; double c2 = (low + high * 2) / 3; if (f(c1) <= f(c2)) low = c1; else high = c2; } cout << fixed << setprecision(20) << f(low) << endl; return 0; }
replace
10
13
10
25
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) typedef long long ll; typedef pair<int, int> P; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { ll A, B, N; cin >> A >> B >> N; ll mx = 0; ll j = N; j -= B + 1; if (j < 0) { j = 1; } for (ll i = j; i <= N; i++) { if (A * i % B == 1 && i % B == B - 1) { cout << floor(A * i / B) - A * floor(i / B); return 0; } chmax(mx, (ll)(floor(A * i / B) - A * floor(i / B))); } cout << mx << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) typedef long long ll; typedef pair<int, int> P; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { ll A, B, N; cin >> A >> B >> N; ll x = min(N, B - 1); cout << floor(A * x / B) - A * floor(x / B) << endl; }
replace
19
35
19
21
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <limits> #define ll long long #define F first #define S second #define pb push_back #define oo (1LL << 63 - 1) #define endl '\n' #define si size() #define all(v) v.begin(), v.end() #define FASTIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define Matrix vector<vector<long long>> using namespace std; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; const long double Pi = acos(-1), e = 2.718; const int N = 2e5 + 10, mod = 1e9 + 7; int main() { FASTIO ll a, b, n; cin >> a >> b >> n; ll ans = 0; ll st = max(0ll, (ll)(n - 2e8 + 5e7)); for (ll i = st; i <= n; i++) { ans = max(ans, (a * i) / b - a * (i / b)); } cout << ans << endl; return 0; } /** */
#include <bits/stdc++.h> #include <limits> #define ll long long #define F first #define S second #define pb push_back #define oo (1LL << 63 - 1) #define endl '\n' #define si size() #define all(v) v.begin(), v.end() #define FASTIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define Matrix vector<vector<long long>> using namespace std; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; const long double Pi = acos(-1), e = 2.718; const int N = 2e5 + 10, mod = 1e9 + 7; int main() { FASTIO ll a, b, n; cin >> a >> b >> n; ll x = min(n, b - 1); cout << (a * x) / b - a * (x / b) << endl; return 0; } /** */
replace
25
31
25
27
TLE
p02696
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; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); ll A, B, N; cin >> A >> B >> N; // A*x/B - x/B の最大値は? // xが大きい方がよさそぅ if (B == 1) cout << 0 << endl; else if (B - 1 > N) cout << A * N / B - A * (N / B) << endl; else { ll ok = 0, ng = 1000000000001; ll m = (ok + ng) / 2; while (abs(ok - ng) > 1) { assert(m * B - 1 >= -1); if (m * B - 1 <= N) ok = m; else ng = m; m = (ok + ng) / 2; } ll x = ok * B - 1; cout << A * x / B - A * (x / B) << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); ll A, B, N; cin >> A >> B >> N; // A*x/B - x/B の最大値は? // xが大きい方がよさそぅ if (B == 1) cout << 0 << endl; else if (B - 1 > N) cout << A * N / B - A * (N / B) << endl; else { ll ok = (N + 1) / B; ll x = ok * B - 1; cout << A * x / B - A * (x / B) << endl; } return 0; }
replace
24
34
24
25
0
p02696
C++
Time Limit Exceeded
// https://atcoder.jp/contests/abc165/tasks/abc165_d // 2020-05-02 #include <algorithm> #include <array> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; long long ans = 0; if (N < B) { ans = ((A * N) / B) - A * (N / B); } else { long long tmp = B - 1; while (tmp <= N) { long long tmp = ((N / B) * B) - 1; ans = (A * tmp) / B - A * (tmp / B); } } cout << ans << endl; return 0; }
// https://atcoder.jp/contests/abc165/tasks/abc165_d // 2020-05-02 #include <algorithm> #include <array> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; long long ans = 0; if (N < B) { ans = ((A * N) / B) - A * (N / B); } else { long long tmp = ((N / B) * B) - 1; ans = (A * tmp) / B - A * (tmp / B); } cout << ans << endl; return 0; }
replace
23
28
23
25
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; ll A, B, N; int main(void) { cin >> A >> B >> N; ll ans = 0; for (ll k = 0; k <= N; k++) { ll aa = (A * k) / B; ll ab = k / B; ll m = aa - A * ab; ans = max(ans, m); } cout << ans << endl; }
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; ll A, B, N; int main(void) { cin >> A >> B >> N; ll ans = 0; ll m = min(B - 1, N); ans = (A * m) / B - A * (m / B); cout << ans << endl; }
replace
15
21
15
17
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const long long INF = 1LL << 60; const int mod = 1000000007; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (int x = 0; x <= n; ++x) { ll X = a * x / b; ll Y = x / b * a; ans = max(ans, X - Y); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const long long INF = 1LL << 60; const int mod = 1000000007; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = min((b - 1), n) * a / b - a * (min((b - 1), n) / b); cout << ans << endl; }
replace
28
34
28
29
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans = 0; long long k = 0; while (k * (b - 1) <= n) { long long x = k * (b - 1); ans = max(ans, (a * x / b) - a * (x / b)); k++; } ans = max(ans, (a * n / b) - a * (n / b)); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans = 0; // long long k = 0; // while(k*(b-1)<=n) { // long long x = k*(b-1); // ans = max(ans, (a*x/b)-a*(x/b)); // k++; // } long long k = n / b; long long x = k * (b - 1); ans = max(ans, (a * x / b) - a * (x / b)); ans = max(ans, (a * n / b) - a * (n / b)); cout << ans << endl; return 0; }
replace
10
16
10
20
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define RREP0(i, n) for (int i = (n)-1; i >= 0; --i) #define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define RREP1(i, n) for (int i = (n); i >= 1; --i) #define pow10(n) int(1e##n + n) typedef long long LL; typedef pair<int, int> P; const int INTINF = int(1e9) + 1; const LL LLINF = LL(1e18) + 1; long double eps = 1.0E-14; void solve() { LL A, B, N; cin >> A >> B >> N; LL ans = 0; LL AmB = A % B; for (int x = 1; x <= min(N, B - 1); x++) { ans = max(ans, (A * x - (x * AmB) % B) / B); } std::cout << ans << endl; } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define RREP0(i, n) for (int i = (n)-1; i >= 0; --i) #define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define RREP1(i, n) for (int i = (n); i >= 1; --i) #define pow10(n) int(1e##n + n) typedef long long LL; typedef pair<int, int> P; const int INTINF = int(1e9) + 1; const LL LLINF = LL(1e18) + 1; long double eps = 1.0E-14; void solve() { LL A, B, N; cin >> A >> B >> N; LL x = min(N, B - 1); LL ans = (A * x) / B - A * (x / B); std::cout << ans << endl; } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); solve(); return 0; }
replace
20
25
20
23
TLE
p02696
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using namespace placeholders; using LL = long long; using ULL = unsigned long long; using VI = vector<int>; using VVI = vector<vector<int>>; using VS = vector<string>; using ISS = istringstream; using OSS = ostringstream; using PII = pair<int, int>; using VPII = vector<pair<int, int>>; template <typename T = int> using VT = vector<T>; template <typename T = int> using VVT = vector<vector<T>>; template <typename T = int> using LIM = numeric_limits<T>; template <typename T> inline istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) { s >> t; } return s; } template <typename T> inline ostream &operator<<(ostream &s, const vector<T> &v) { for (int i = 0; i < int(v.size()); ++i) { s << (" " + !i) << v[i]; } return s; } void in_impl(){}; template <typename T, typename... TS> void in_impl(T &head, TS &...tail) { cin >> head; in_impl(tail...); } #define IN(T, ...) \ T __VA_ARGS__; \ in_impl(__VA_ARGS__); template <typename T> inline T fromString(const string &s) { T res; istringstream iss(s); iss >> res; return res; } template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); } #define NUMBERED(name, number) NUMBERED2(name, number) #define NUMBERED2(name, number) name##_##number #define REP1(n) REP2(NUMBERED(REP_COUNTER, __LINE__), n) #define REP2(i, n) REP3(i, 0, n) #define REP3(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define GET_REP(a, b, c, F, ...) F #define REP(...) GET_REP(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__) #define FOR(e, c) for (auto &&e : c) #define ALL(c) begin(c), end(c) #define AALL(a) \ (remove_all_extents<decltype(a)>::type *)a, \ (remove_all_extents<decltype(a)>::type *)a + \ sizeof(a) / sizeof(remove_all_extents<decltype(a)>::type) #define SZ(v) ((int)(v).size()) #define EXISTS(c, e) ((c).find(e) != (c).end()) template <typename T> inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template <typename T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } #define PB push_back #define EM emplace #define EB emplace_back #define BI back_inserter #define MP make_pair #define fst first #define snd second #define DUMP(x) cerr << #x << " = " << (x) << endl // void experience( const LL A, const LL B, const LL N ) // { // REP( i, 100 ) // { // DUMP( ( A * i / B ) - ( A * ( i / B ) ) ); // } // return; // } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(12) << fixed; IN(LL, A, B, N); // experience( A, B, N ); assert(A % B); const LL x = min(B - 1, N % B); cout << ((A * x / B) - (A * (x / B))) << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using namespace placeholders; using LL = long long; using ULL = unsigned long long; using VI = vector<int>; using VVI = vector<vector<int>>; using VS = vector<string>; using ISS = istringstream; using OSS = ostringstream; using PII = pair<int, int>; using VPII = vector<pair<int, int>>; template <typename T = int> using VT = vector<T>; template <typename T = int> using VVT = vector<vector<T>>; template <typename T = int> using LIM = numeric_limits<T>; template <typename T> inline istream &operator>>(istream &s, vector<T> &v) { for (T &t : v) { s >> t; } return s; } template <typename T> inline ostream &operator<<(ostream &s, const vector<T> &v) { for (int i = 0; i < int(v.size()); ++i) { s << (" " + !i) << v[i]; } return s; } void in_impl(){}; template <typename T, typename... TS> void in_impl(T &head, TS &...tail) { cin >> head; in_impl(tail...); } #define IN(T, ...) \ T __VA_ARGS__; \ in_impl(__VA_ARGS__); template <typename T> inline T fromString(const string &s) { T res; istringstream iss(s); iss >> res; return res; } template <typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); } #define NUMBERED(name, number) NUMBERED2(name, number) #define NUMBERED2(name, number) name##_##number #define REP1(n) REP2(NUMBERED(REP_COUNTER, __LINE__), n) #define REP2(i, n) REP3(i, 0, n) #define REP3(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define GET_REP(a, b, c, F, ...) F #define REP(...) GET_REP(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__) #define FOR(e, c) for (auto &&e : c) #define ALL(c) begin(c), end(c) #define AALL(a) \ (remove_all_extents<decltype(a)>::type *)a, \ (remove_all_extents<decltype(a)>::type *)a + \ sizeof(a) / sizeof(remove_all_extents<decltype(a)>::type) #define SZ(v) ((int)(v).size()) #define EXISTS(c, e) ((c).find(e) != (c).end()) template <typename T> inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template <typename T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } #define PB push_back #define EM emplace #define EB emplace_back #define BI back_inserter #define MP make_pair #define fst first #define snd second #define DUMP(x) cerr << #x << " = " << (x) << endl // void experience( const LL A, const LL B, const LL N ) // { // REP( i, 100 ) // { // DUMP( ( A * i / B ) - ( A * ( i / B ) ) ); // } // return; // } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(12) << fixed; IN(LL, A, B, N); // experience( A, B, N ); const LL x = min(B - 1, N); cout << ((A * x / B) - (A * (x / B))) << endl; return 0; }
replace
134
137
134
135
0
p02696
Python
Time Limit Exceeded
a, b, n = map(int, input().split()) ans = 0 # floor(a * x / b) # = floor(a * floor(x / b) + a * (x / b - floor(x / b))) # = a * floor(x / b) + floor(a * (x / b - floor(x / b)))) for i in range(min(b, n + 1)): ans = max(ans, int(a * i / b)) print(ans)
a, b, n = map(int, input().split()) ans = 0 # floor(a * x / b) # = floor(a * floor(x / b) + a * (x / b - floor(x / b))) # = a * floor(x / b) + floor(a * (x / b - floor(x / b)))) print(int(a * min(b - 1, n) / b))
replace
5
8
5
6
TLE
p02696
Python
Time Limit Exceeded
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline a, b, n = map(int, input().split()) ans = 0 for x in range(min(b, n + 1)): ans = max(int(a * x / b) - a * int(x / b), ans) print(ans) if __name__ == "__main__": setrecursionlimit(10000) main()
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline a, b, n = map(int, input().split()) ans = 0 x = min(b - 1, n) ans = max(int(a * x / b) - a * int(x / b), ans) print(ans) if __name__ == "__main__": setrecursionlimit(10000) main()
replace
9
11
9
11
TLE
p02696
Python
Runtime Error
def m(): a, b, n = map(int, input().split()) def calc(x): return int((a * x) / b) - (a * int(x / b)) if calc(1) < calc(n // 2): return max([calc(i) for i in range(n // 2, n + 1)]) else: return max([calc(i) for i in range(1, n // 2 + 1)]) print(m())
def m(): a, b, n = map(int, input().split()) def calc(x): return int((a * x) / b) - (a * int(x / b)) return calc(min(n, b - 1)) print(m())
replace
6
10
6
7
0
p02696
Python
Time Limit Exceeded
def main(): a, b, n = [int(x) for x in input().split()] gen = (a * x // b - x // b * a for x in range(min(b, n) + 1)) return max(gen) if __name__ == "__main__": print(main())
def main(): a, b, n = [int(x) for x in input().split()] # gen = (a * x // b - x // b * a for x in range(min(b, n) + 1)) if n >= b - 1: x = b - 1 else: x = n return a * x // b - x // b * a if __name__ == "__main__": print(main())
replace
2
4
2
10
TLE
p02696
Python
Time Limit Exceeded
A, B, N = map(int, input().split()) ans = 0 for i in range(1, N + 1): tmp = (A * i) // B - A * (i // B) ans = max(ans, tmp) print(ans)
A, B, N = map(int, input().split()) x = min(B - 1, N) ans = (A * x) // B - A * (x // B) print(ans)
replace
2
8
2
4
TLE
p02696
Python
Time Limit Exceeded
# def main(): a, b, n = map(int, input().split(" ")) fac = 0 for i in range(n + 1): j = i // b if j == 0: if fac < i: fac = i else: break ans = a * fac // b - a * (fac // b) print(ans) if __name__ == "__main__": main()
# def main(): a, b, n = map(int, input().split(" ")) fac = 0 start = min(b, n) if b <= n: fac = start - 1 else: fac = start ans = a * fac // b - a * (fac // b) print(ans) if __name__ == "__main__": main()
replace
6
13
6
11
TLE
p02696
Python
Runtime Error
a, b, n = map(int, input().split()) x = min(b.n) print(int(a * x / b))
a, b, n = map(int, input().split()) x = min(b - 1, n) ans = int(a * x / b) # if a == 1 or b == 1 or b == n: # print(0) # else: print(ans)
replace
2
4
2
9
AttributeError: 'int' object has no attribute 'n'
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02696/Python/s868471996.py", line 3, in <module> x = min(b. n) AttributeError: 'int' object has no attribute 'n'
p02696
Python
Time Limit Exceeded
def f(x): return (a * x) // b - a * (x // b) a, b, n = map(int, input().split()) k = (n + 1) // b ans = 0 for x in range(max(0, k * b - 1), n + 1): ans = max(ans, f(x)) print(ans)
def f(x): return (a * x) // b - a * (x // b) a, b, n = map(int, input().split()) k = (n + 1) // b x = max(k * b - 1, 0) ans = f(x) ans = max(ans, f(n)) print(ans)
replace
8
12
8
11
TLE
p02696
Python
Time Limit Exceeded
import math A, B, N = map(int, input().split(" ")) ans = 0 for x in range(min(B, N + 1)): res = math.floor((A * x) / B) - A * (math.floor(x / B)) ans = max(res, ans) print(int(ans))
import math A, B, N = map(int, input().split(" ")) ans = 0 x = min(B, N + 1) - 1 ans = math.floor((A * x) / B) - A * (math.floor(x / B)) print(int(ans))
replace
4
7
4
6
TLE
p02696
Python
Time Limit Exceeded
a, b, n = map(int, input().split()) ans = 0 if b > n: x = n ans = int(a * x // b) - int(a * (x // b)) else: m = 0 for i in range(b): if int(a * (n - i) // b) - int(a * ((n - i) // b)) > m: m = int(a * (n - i) // b) - int(a * ((n - i) // b)) ans = m print(ans)
a, b, n = map(int, input().split()) ans = 0 if b > n: x = n ans = int(a * x // b) - int(a * (x // b)) else: x = n ans1 = int(a * x // b) - int(a * (x // b)) x = (n // b) * b - 1 ans2 = int(a * x // b) - int(a * (x // b)) ans = max(ans1, ans2) print(ans)
replace
7
12
7
12
TLE
p02696
Python
Runtime Error
from math import floor A, B, N = list(map(int, input().split())) # print(A, B, N) x = None if N < B: x = N answer = floor(A * x / B) - A * floor(x / B) print(answer)
from math import floor A, B, N = list(map(int, input().split())) # print(A, B, N) x = None if N < B: x = N else: x = B x = B - 1 # max_diff = 0 # for _x in range(B, N + 1): # diff = (x / B) - floor(x / B) # if max_diff <= diff: # max_diff = diff # x = _x answer = floor(A * x / B) - A * floor(x / B) print(answer)
insert
8
8
8
17
0
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, n, i, m = 0, d; cin >> a >> b >> n; for (i = 1; i <= n; i++) { c = ((a * i) / b) - (a * (i / b)); if (m <= c) { m = c; d = i; } } cout << m << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, n, i, m = 0, d; cin >> a >> b >> n; m = min(b - 1, n); d = (a * m) / b - (a * (m / b)); cout << d << endl; }
replace
5
13
5
8
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long max = 0; for (int i = 1; i < b && i <= n; i++) { long k = a * i / b; if (max < k) max = k; } cout << max << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long i = min(b - 1, n); long long max = a * i / b; cout << max << endl; }
replace
5
11
5
7
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (ll i = ll(a); i <= ll(b); ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) using namespace std; using ll = long long; int main() { ll a, b, n; cin >> a >> b >> n; ll max = 0; if (b < n) { repi(x, 1, b) { ll t = ((a * x) / b) - (a * (x / b)); if (t > max) { max = t; } } } else { repi(x, 1, n) { ll t = ((a * x) / b) - (a * (x / b)); if (t > max) { max = t; } } } cout << max << endl; return 0; }
#include <iostream> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (ll i = ll(a); i <= ll(b); ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) using namespace std; using ll = long long; int main() { ll a, b, n; cin >> a >> b >> n; ll max = 0; ll x = (n >= b) ? b - 1 : n; max = ((a * x) / b) - a * (x / b); // repi(x,1,b-1){ // // if((a*x)%b != 0) continue; // ll t =((a * x)/b) - (a * (x/b)); // printf("t:%d\n",t); // if(t > max){ // max = t; // } // } cout << max << endl; return 0; }
replace
15
32
15
25
TLE
p02696
C++
Time Limit Exceeded
// #include <bits/stdc++.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string.h> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define ff first #define ss second #define ll long long #define mod 998244353 using namespace std; ll a, b, n, ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a >> b >> n; for (ll i = 1; i <= n; i++) { ll cur = a * i / b - a * (i / b); // cout<<i<<" "<<cur<<endl; if (cur < ans) break; ans = max(ans, cur); } cout << ans; } /* 2 1 1 1 0 1 1 1 1 */
// #include <bits/stdc++.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string.h> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define ff first #define ss second #define ll long long #define mod 998244353 using namespace std; ll a, b, n, ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a >> b >> n; ll x = min(b - 1, n); ans = a * x / b - a * (x / b); cout << ans; } /* 2 1 1 1 0 1 1 1 1 */
replace
37
44
37
39
TLE
p02696
C++
Time Limit Exceeded
/* !!!!!! !!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!! !!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!! !!!!!!!!!!!!!!!!!!! !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!! !!!!!! !!!! */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define MAXN 200005 #define mod 998244353 #define inf LLONG_MAX / 3 #define pb push_back using namespace std; /* * author : vivekcrux */ typedef long long ll; typedef pair<ll, ll> pll; ll power(ll x, ll y, ll m = mod) { ll ans = 1; while (y > 0) { if (y & 1) { ans = (ans * x) % m; } x = (x * x) % m; y /= 2; } return ans % m; } ll modInverse(ll a, ll m = mod) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { // q is quotient ll q = a / m; ll t = m; // m is remainder now, process same as // Euclid's algo m = a % m, a = t; t = y; // Update y and x y = x - q * y; x = t; } // Make x positive if (x < 0) x += m0; return x; } 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 T = 1; // cin>>T; while (T--) { ll n, k, i, j, ans = 0; ll a, b; cin >> a >> b >> n; for (i = 0; i <= min(n, b); i++) { ans = max(ans, ((a * i) / b) - (a * (i / b))); } cout << ans; } return 0; }
/* !!!!!! !!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!! !!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!! !!!!!!!!!!!!!!!!!!! !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! !!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!! !!!!!!!! !!!!!! !!!! */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define MAXN 200005 #define mod 998244353 #define inf LLONG_MAX / 3 #define pb push_back using namespace std; /* * author : vivekcrux */ typedef long long ll; typedef pair<ll, ll> pll; ll power(ll x, ll y, ll m = mod) { ll ans = 1; while (y > 0) { if (y & 1) { ans = (ans * x) % m; } x = (x * x) % m; y /= 2; } return ans % m; } ll modInverse(ll a, ll m = mod) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { // q is quotient ll q = a / m; ll t = m; // m is remainder now, process same as // Euclid's algo m = a % m, a = t; t = y; // Update y and x y = x - q * y; x = t; } // Make x positive if (x < 0) x += m0; return x; } 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 T = 1; // cin>>T; while (T--) { ll n, k, i, j, ans = 0; ll a, b; cin >> a >> b >> n; i = min(b - 1, n); ans = max(ans, ((a * i) / b) - (a * (i / b))); // cout<<((a*i)/b)-(a*(i/b))<<" "; cout << ans; } return 0; }
replace
119
122
119
122
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<string> vs; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; #define rep(i, n) for (int i = 0; i < n; i++) #define repll(i, n) for (long long int i = 0; i < n; i++) #define fin(ans) cout << (ans) << endl #define P 1000000007 #define STI(s) atoi(s.c_str()) // string to int #define mp(p, q) make_pair(p, q) #define Sort(a) sort(a.begin(), a.end()) 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; } const int INF = INT_MAX; const long long LLINF = 1LL << 60; template <typename T_char> char ToUpper(char cX) { return toupper(cX); } // g++ -std=c++1z temp.cpp //./a.exe ll digit(ll a) { ll count = 0; for (ll i = 0; i < a; i++) { if (a == 0) { break; } else { a = a / 10; count++; } } return count; } uintmax_t comb(unsigned int n, unsigned int r) { if (r * 2 > n) r = n - r; uintmax_t dividend = 1; uintmax_t divisor = 1; for (unsigned int i = 1; i <= r; ++i) { dividend *= (n - i + 1); divisor *= i; } return dividend / divisor; } // 桁数のカウント // pow(x,n) == x^n // sum = accumulate(v.begin(),v.end(),0); ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } unsigned GetDigit(unsigned num) { return log10(num) + 1; } int binary(int bina) { int ans = 0; for (int i = 0; bina > 0; i++) { ans = ans + (bina % 2) * pow(10, i); bina = bina / 2; } return ans; } int main(void) { ios::sync_with_stdio(false); cin.tie(0); ///////////////////////////////////////////////////// ll a, b, c, ans = 0, x; cin >> a >> b >> c; rep(i, b + 100) { ll x = c - i; if (x < 0) break; ans = max(ans, (ll)(floorl(a * x / b) - a * floorl(x / b))); } cout << ans << endl; ////////////////////////////////////////////////////// return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<string> vs; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; #define rep(i, n) for (int i = 0; i < n; i++) #define repll(i, n) for (long long int i = 0; i < n; i++) #define fin(ans) cout << (ans) << endl #define P 1000000007 #define STI(s) atoi(s.c_str()) // string to int #define mp(p, q) make_pair(p, q) #define Sort(a) sort(a.begin(), a.end()) 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; } const int INF = INT_MAX; const long long LLINF = 1LL << 60; template <typename T_char> char ToUpper(char cX) { return toupper(cX); } // g++ -std=c++1z temp.cpp //./a.exe ll digit(ll a) { ll count = 0; for (ll i = 0; i < a; i++) { if (a == 0) { break; } else { a = a / 10; count++; } } return count; } uintmax_t comb(unsigned int n, unsigned int r) { if (r * 2 > n) r = n - r; uintmax_t dividend = 1; uintmax_t divisor = 1; for (unsigned int i = 1; i <= r; ++i) { dividend *= (n - i + 1); divisor *= i; } return dividend / divisor; } // 桁数のカウント // pow(x,n) == x^n // sum = accumulate(v.begin(),v.end(),0); ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } unsigned GetDigit(unsigned num) { return log10(num) + 1; } int binary(int bina) { int ans = 0; for (int i = 0; bina > 0; i++) { ans = ans + (bina % 2) * pow(10, i); bina = bina / 2; } return ans; } int main(void) { ios::sync_with_stdio(false); cin.tie(0); ///////////////////////////////////////////////////// ll a, b, c, ans = 0, x; cin >> a >> b >> c; if (c < b) ans = (ll)floorl(a * c / b); else ans = (ll)floor(a * (b - 1) / b); cout << ans << endl; ////////////////////////////////////////////////////// return 0; }
replace
102
108
102
106
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int64_t A, B, N; cin >> A >> B >> N; int64_t ans = -999999999; for (int i = 1; i <= N; i++) { int64_t x = floor(A * i / B) - A * floor(i / B); ans = max(ans, x); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int64_t A, B, N; cin >> A >> B >> N; int64_t x = min(B - 1, N); int64_t ans = floor(A * x / B); cout << ans << endl; }
replace
7
12
7
9
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #define mp make_pair #define pb push_back #define ll long long int #define ld long double #define fi first #define se second #define mod 1000000007 #define test \ long long int t; \ cin >> t; \ while (t-- > 0) #define fIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define loop(n) for (long long int i = 0; i < n; i++) #define loopr(n) for (long long int i = n - 1; i >= 0; i--) #define lrp(a, b) for (long long int i = a; i <= b; i++) #define lrn(a, b) for (long long int i = b; i >= a; i--) #define endl '\n' #define ivec vector<ll> #define ivecp vector<pair<ll, ll>> #define imap map<ll, ll> #define uimap unordered_map<ll, ll> #define iset set<ll> #define cvec vector<char> #define civecp vector<pair<char, ll>> #define cimap map<char, ll> #define ucimap unordered_map<char, ll> #define cset set<char> #define rr return 0 using namespace std; // Declaration const ll N = 5e5 + 5; vector<ll> adj[N]; // bool visited[N]={false}; ll parent[N]; ll rnk[N]; ll degree[N]; vector<ll> ax; // Function call bool isprime(ll n); bool ispalin(ll num); ll lcm(ll a, ll b); ll power(ll x, unsigned ll y); ll gcd(ll a, ll b); ll sumofdigits(ll n); void sorts(string &str); bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b); bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b); void countSort(ll arr[], ll n, ll exp); void radixsort(ll arr[], ll n); void print(ll arr[], ll n); void make(ll a); ll find(ll a); void Union(ll a, ll b); ll mins(ll arr[], ll n, set<pair<ll, ll>> st); // solve void solve() { ll a, b, n; cin >> a >> b >> n; ll maxi = 0; for (ll i = min(n, b) / 2; i <= min(n, b); i++) { ll x = floor((a * i) / b) - a * (floor(i / b)); if (x > maxi) { maxi = x; } } cout << maxi; } //--------------------------------------------------------------------------------------------------// // Functions ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); } ll power(ll x, unsigned ll y) { ll temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else return x * temp * temp; } bool isPrime(ll num) { bool flag = true; for (ll i = 2; i <= num / 2; i++) { if (num % i == 0) { flag = false; break; } } return flag; } bool isPalin(ll num) { bool flag = false; ll digit, rev = 0, n = num; do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; } while (num != 0); if (rev == n) flag = true; return flag; } ll sumofdigits(ll n) { ll c = 0; while (n > 0) { c++; n /= 10; } return c; } bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.first > b.first); } bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second < b.second); } string sortString(string &str) { sort(str.begin(), str.end()); return str; } void countSort(ll arr[], ll n, ll exp) { ll output[n]; ll i, count[10] = {0}; for (i = 0; i < n; i++) count[(arr[i] / exp) % 10]++; for (i = 1; i < 10; i++) count[i] += count[i - 1]; for (i = n - 1; i >= 0; i--) { output[count[(arr[i] / exp) % 10] - 1] = arr[i]; count[(arr[i] / exp) % 10]--; } for (i = 0; i < n; i++) arr[i] = output[i]; } void radixsort(ll arr[], ll n) { ll mx = arr[0]; for (ll i = 1; i < n; i++) if (arr[i] > mx) mx = arr[i]; ll m = mx; for (ll exp = 1; m / exp > 0; exp *= 10) countSort(arr, n, exp); } void print(ll arr[], ll n) { for (ll i = 0; i < n; i++) cout << arr[i] << " "; } // DSU// void make(ll a) { parent[a] = a; rnk[a] = 1; } ll find(ll a) { if (parent[a] == a) return a; return parent[a] = find(parent[a]); } void Union(ll a, ll b) { a = find(a); b = find(b); if (a == b) return; if (rnk[a] > rnk[b]) { parent[b] = a; rnk[a] += rnk[b]; } else { parent[a] = b; rnk[b] += rnk[a]; } } // Driver Code int main() { fIO solve(); rr; }
#include <algorithm> #include <bits/stdc++.h> #define mp make_pair #define pb push_back #define ll long long int #define ld long double #define fi first #define se second #define mod 1000000007 #define test \ long long int t; \ cin >> t; \ while (t-- > 0) #define fIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define loop(n) for (long long int i = 0; i < n; i++) #define loopr(n) for (long long int i = n - 1; i >= 0; i--) #define lrp(a, b) for (long long int i = a; i <= b; i++) #define lrn(a, b) for (long long int i = b; i >= a; i--) #define endl '\n' #define ivec vector<ll> #define ivecp vector<pair<ll, ll>> #define imap map<ll, ll> #define uimap unordered_map<ll, ll> #define iset set<ll> #define cvec vector<char> #define civecp vector<pair<char, ll>> #define cimap map<char, ll> #define ucimap unordered_map<char, ll> #define cset set<char> #define rr return 0 using namespace std; // Declaration const ll N = 5e5 + 5; vector<ll> adj[N]; // bool visited[N]={false}; ll parent[N]; ll rnk[N]; ll degree[N]; vector<ll> ax; // Function call bool isprime(ll n); bool ispalin(ll num); ll lcm(ll a, ll b); ll power(ll x, unsigned ll y); ll gcd(ll a, ll b); ll sumofdigits(ll n); void sorts(string &str); bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b); bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b); void countSort(ll arr[], ll n, ll exp); void radixsort(ll arr[], ll n); void print(ll arr[], ll n); void make(ll a); ll find(ll a); void Union(ll a, ll b); ll mins(ll arr[], ll n, set<pair<ll, ll>> st); // solve void solve() { ll a, b, n; cin >> a >> b >> n; ll maxi = 0; ll j = min(n, b); ll c = 0; for (ll i = j; i >= 0; i--) { c++; if (c == 1000000) break; ll x = floor((a * i) / b) - a * (floor(i / b)); if (x > maxi) { maxi = x; } } cout << maxi; } //--------------------------------------------------------------------------------------------------// // Functions ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); } ll power(ll x, unsigned ll y) { ll temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else return x * temp * temp; } bool isPrime(ll num) { bool flag = true; for (ll i = 2; i <= num / 2; i++) { if (num % i == 0) { flag = false; break; } } return flag; } bool isPalin(ll num) { bool flag = false; ll digit, rev = 0, n = num; do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; } while (num != 0); if (rev == n) flag = true; return flag; } ll sumofdigits(ll n) { ll c = 0; while (n > 0) { c++; n /= 10; } return c; } bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.first > b.first); } bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second < b.second); } string sortString(string &str) { sort(str.begin(), str.end()); return str; } void countSort(ll arr[], ll n, ll exp) { ll output[n]; ll i, count[10] = {0}; for (i = 0; i < n; i++) count[(arr[i] / exp) % 10]++; for (i = 1; i < 10; i++) count[i] += count[i - 1]; for (i = n - 1; i >= 0; i--) { output[count[(arr[i] / exp) % 10] - 1] = arr[i]; count[(arr[i] / exp) % 10]--; } for (i = 0; i < n; i++) arr[i] = output[i]; } void radixsort(ll arr[], ll n) { ll mx = arr[0]; for (ll i = 1; i < n; i++) if (arr[i] > mx) mx = arr[i]; ll m = mx; for (ll exp = 1; m / exp > 0; exp *= 10) countSort(arr, n, exp); } void print(ll arr[], ll n) { for (ll i = 0; i < n; i++) cout << arr[i] << " "; } // DSU// void make(ll a) { parent[a] = a; rnk[a] = 1; } ll find(ll a) { if (parent[a] == a) return a; return parent[a] = find(parent[a]); } void Union(ll a, ll b) { a = find(a); b = find(b); if (a == b) return; if (rnk[a] > rnk[b]) { parent[b] = a; rnk[a] += rnk[b]; } else { parent[a] = b; rnk[b] += rnk[a]; } } // Driver Code int main() { fIO solve(); rr; }
replace
65
66
65
71
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> long long int a; long long int b; long long int n; using namespace std; int main() { cin >> a; cin >> b; cin >> n; long long int m = 0; for (long long int x = 0; x <= n; x++) { long long int t = ((a * x) / b) - a * (x / b); if (t > m) { m = t; } } cout << m; }
#include <bits/stdc++.h> long long int a; long long int b; long long int n; using namespace std; int main() { cin >> a; cin >> b; cin >> n; long long int m = 0; /* for(long long int x=0;x<=n;x++){ long long int t=((a*x)/b)-a*(x/b); if(t>m){ m=t; } }*/ if (b <= n) { long long int x = b - 1; cout << ((a * x) / b) - a * (x / b); } else { long long int x = n; cout << ((a * x) / b) - a * (x / b); /* for (long long int i = 0; x < n; i++) { x = b * n - 1; if (x > n) { break; } long long int t = ((a * x) / b) - a * (x / b); if (t > m) { m = t; } }*/ } return 0; long long int x = 0; for (long long int i = 0; x < n; i++) { x = b * n - 1; if (x > n) { break; } long long int t = ((a * x) / b) - a * (x / b); if (t > m) { m = t; } } cout << m; }
replace
12
13
12
47
TLE
p02696
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define double long double #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) \ int n; \ cin >> n; #define sc(s) \ string s; \ cin >> s; #define mod 1000000007 #define inf 1000000000000000007 #define f first #define s second #define mini(c, a, b) *min_element(c + a, c + b) #define maxi(c, a, b) *max_element(c + a, c + b) #define pi 3.141592653589793238462643383279 #define e_ 2.718281828459045235360287471352 #define P pair<int, int> // printf("%.12Lf\n",); int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } bool p(int x) { if (x == 1) return false; rep(2, i, sqrt(x) + 1) { if (x % i == 0 && x != i) { return false; } } return true; } int max(int a, int b) { if (a >= b) return a; else return b; } string maxst(string s, string t) { int n = s.size(); int m = t.size(); if (n > m) return s; else if (n < m) return t; else { rep(0, i, n) { if (s[i] > t[i]) return s; if (s[i] < t[i]) return t; } return s; } } int min(int a, int b) { if (a >= b) return b; else return a; } int n2[41]; int nis[41]; int nia[41]; int mody[41]; int nn; int com(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int bunsi = 1, bunbo = 1; rep(0, i, y) bunsi = (bunsi * (n - i)) % mod; rep(0, i, y) bunbo = (bunbo * (i + 1)) % mod; mody[0] = bunbo; rep(1, i, 41) { bunbo = (bunbo * bunbo) % mod; mody[i] = bunbo; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { bunsi = (bunsi * mody[i]) % mod; } } return bunsi; } int gyakugen(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } mody[0] = y; rep(1, i, 41) { y = (y * y) % mod; mody[i] = y; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { n = (n * mody[i]) % mod; } } return n; } int yakuwa(int n) { int sum = 0; rep(1, i, sqrt(n + 1)) { if (n % i == 0) sum += i + n / i; if (i * i == n) sum -= i; } return sum; } bool integer(double n) { if (n == long(n)) return true; else return false; } int poow(int y, int n) { if (n == 0) return 1; n -= 1; int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int yy = y; mody[0] = yy; rep(1, i, 41) { yy = (yy * yy) % mod; mody[i] = yy; } rep(0, i, 41) nis[i] = 0; nn = n; for (int i = 40; i >= 0; i -= 1) { if (nn >= n2[i]) { nis[i]++; nn -= n2[i]; } } rep(0, i, 41) { if (nis[i] == 1) { y = (y * mody[i]) % mod; } } return y; } int minpow(int x, int y) { int sum = 1; rep(0, i, y) sum *= x; return sum; } int ketawa(int x, int sinsuu) { int sum = 0; rep(0, i, 100) sum += (x % poow(sinsuu, i + 1)) / (poow(sinsuu, i)); return sum; } int sankaku(int a) { return a * (a + 1) / 2; } bool search(int x) { int n; int a[n]; int l = 0, r = n; while (r - l >= 1) { int i = (l + r) / 2; if (a[i] == x) return true; else if (a[i] < x) l = i + 1; else r = i; } return false; } /*using Graph=vector<vector<int>>; int oya[114514]; int depth[114514]; void dfs(const Graph &G, int v, int p, int d) { depth[v] = d; oya[v]=p; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d+1); // d を 1 増やして子ノードへ } }*/ /*int H=10,W=10; char field[10][10]; char memo[10][10]; void dfs(int h, int w) { memo[h][w] = 'x'; // 八方向を探索 for (int dh = -1; dh <= 1; ++dh) { for (int dw = -1; dw <= 1; ++dw) { if(abs(0-dh)+abs(0-dw)==2)continue; int nh = h + dh, nw = w + dw; // 場外アウトしたり、0 だったりはスルー if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue; if (memo[nh][nw] == 'x') continue; // 再帰的に探索 dfs(nh, nw); } } }*/ int XOR(int a, int b) { int ni = 1; rep(0, i, 41) { n2[i] = ni; ni *= 2; } rep(0, i, 41) nis[i] = 0; for (int i = 40; i >= 0; i -= 1) { if (a >= n2[i]) { nis[i]++; a -= n2[i]; } if (b >= n2[i]) { nis[i]++; b -= n2[i]; } } int sum = 0; rep(0, i, 41) sum += (nis[i] % 2 * n2[i]); return sum; } // int ma[1024577][21]; // for(int bit=0;bit<(1<<n);bit++)rep(0,i,n)if(bit&(1<<i))ma[bit][i]=1; int a[114514], b[114514]; signed main() { ic(n) ic(m) ic(k) int t = max(0, k / (m - 1) * m - 1); c(max(n * t / m - n * (t / m), n * k / m - n * (k / m))) }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define double long double #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) \ int n; \ cin >> n; #define sc(s) \ string s; \ cin >> s; #define mod 1000000007 #define inf 1000000000000000007 #define f first #define s second #define mini(c, a, b) *min_element(c + a, c + b) #define maxi(c, a, b) *max_element(c + a, c + b) #define pi 3.141592653589793238462643383279 #define e_ 2.718281828459045235360287471352 #define P pair<int, int> // printf("%.12Lf\n",); int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } bool p(int x) { if (x == 1) return false; rep(2, i, sqrt(x) + 1) { if (x % i == 0 && x != i) { return false; } } return true; } int max(int a, int b) { if (a >= b) return a; else return b; } string maxst(string s, string t) { int n = s.size(); int m = t.size(); if (n > m) return s; else if (n < m) return t; else { rep(0, i, n) { if (s[i] > t[i]) return s; if (s[i] < t[i]) return t; } return s; } } int min(int a, int b) { if (a >= b) return b; else return a; } int n2[41]; int nis[41]; int nia[41]; int mody[41]; int nn; int com(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int bunsi = 1, bunbo = 1; rep(0, i, y) bunsi = (bunsi * (n - i)) % mod; rep(0, i, y) bunbo = (bunbo * (i + 1)) % mod; mody[0] = bunbo; rep(1, i, 41) { bunbo = (bunbo * bunbo) % mod; mody[i] = bunbo; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { bunsi = (bunsi * mody[i]) % mod; } } return bunsi; } int gyakugen(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } mody[0] = y; rep(1, i, 41) { y = (y * y) % mod; mody[i] = y; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { n = (n * mody[i]) % mod; } } return n; } int yakuwa(int n) { int sum = 0; rep(1, i, sqrt(n + 1)) { if (n % i == 0) sum += i + n / i; if (i * i == n) sum -= i; } return sum; } bool integer(double n) { if (n == long(n)) return true; else return false; } int poow(int y, int n) { if (n == 0) return 1; n -= 1; int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int yy = y; mody[0] = yy; rep(1, i, 41) { yy = (yy * yy) % mod; mody[i] = yy; } rep(0, i, 41) nis[i] = 0; nn = n; for (int i = 40; i >= 0; i -= 1) { if (nn >= n2[i]) { nis[i]++; nn -= n2[i]; } } rep(0, i, 41) { if (nis[i] == 1) { y = (y * mody[i]) % mod; } } return y; } int minpow(int x, int y) { int sum = 1; rep(0, i, y) sum *= x; return sum; } int ketawa(int x, int sinsuu) { int sum = 0; rep(0, i, 100) sum += (x % poow(sinsuu, i + 1)) / (poow(sinsuu, i)); return sum; } int sankaku(int a) { return a * (a + 1) / 2; } bool search(int x) { int n; int a[n]; int l = 0, r = n; while (r - l >= 1) { int i = (l + r) / 2; if (a[i] == x) return true; else if (a[i] < x) l = i + 1; else r = i; } return false; } /*using Graph=vector<vector<int>>; int oya[114514]; int depth[114514]; void dfs(const Graph &G, int v, int p, int d) { depth[v] = d; oya[v]=p; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d+1); // d を 1 増やして子ノードへ } }*/ /*int H=10,W=10; char field[10][10]; char memo[10][10]; void dfs(int h, int w) { memo[h][w] = 'x'; // 八方向を探索 for (int dh = -1; dh <= 1; ++dh) { for (int dw = -1; dw <= 1; ++dw) { if(abs(0-dh)+abs(0-dw)==2)continue; int nh = h + dh, nw = w + dw; // 場外アウトしたり、0 だったりはスルー if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue; if (memo[nh][nw] == 'x') continue; // 再帰的に探索 dfs(nh, nw); } } }*/ int XOR(int a, int b) { int ni = 1; rep(0, i, 41) { n2[i] = ni; ni *= 2; } rep(0, i, 41) nis[i] = 0; for (int i = 40; i >= 0; i -= 1) { if (a >= n2[i]) { nis[i]++; a -= n2[i]; } if (b >= n2[i]) { nis[i]++; b -= n2[i]; } } int sum = 0; rep(0, i, 41) sum += (nis[i] % 2 * n2[i]); return sum; } // int ma[1024577][21]; // for(int bit=0;bit<(1<<n);bit++)rep(0,i,n)if(bit&(1<<i))ma[bit][i]=1; int a[114514], b[114514]; signed main() { ic(n) ic(m) ic(k) if (m == 1) { c(0) return 0; } int t = max(0, k / (m - 1) * m - 1); c(max(n * t / m - n * (t / m), n * k / m - n * (k / m))) }
replace
293
294
293
295
0
p02696
C++
Time Limit Exceeded
#include "bits/stdc++.h" #include <math.h> #include <time.h> using namespace std; const long long mod = 1000000007; #define ll long long #define P pair<int, int> #define dump(x) \ if (dbg) { \ cout << #x << " = " << (x) << endl; \ } bool dbg = false; long long gcd(long long a, long long b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } //--------------------------------------------------------------------------------------------------- /*ここからいじる*/ //--------------------------------------------------------------------------------------------------- void solve() {} int main() { ll a, b, n; cin >> a >> b >> n; int memo = 0; ll i = b - 1; if (n <= 100000000) { for (int i = 1; i <= n; i++) { memo = max(memo, int(floor(a * i / b) - a * floor(i / b))); } } else if (n < b) { memo = max(memo, int(floor(a * n / b) - a * floor(n / b))); } else { while (n >= i) { memo = max(memo, int(floor(a * i / b) - a * floor(i / b))); i += b; } } cout << memo << endl; solve(); return 0; }
#include "bits/stdc++.h" #include <math.h> #include <time.h> using namespace std; const long long mod = 1000000007; #define ll long long #define P pair<int, int> #define dump(x) \ if (dbg) { \ cout << #x << " = " << (x) << endl; \ } bool dbg = false; long long gcd(long long a, long long b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } //--------------------------------------------------------------------------------------------------- /*ここからいじる*/ //--------------------------------------------------------------------------------------------------- void solve() {} int main() { ll a, b, n; cin >> a >> b >> n; ll memo; memo = min(b - 1, n); memo = floor(a * memo / b) - a * floor(memo / b); cout << memo << endl; solve(); return 0; }
replace
28
42
28
31
TLE
p02696
Python
Time Limit Exceeded
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): A, B, N = map(int, input().split()) def func(x): res = (A * x) // B - A * (x // B) return res M = 0 for i in range(N, max(0, N - 10**7), -1): tmp = func(i) if tmp > M: M = tmp print(M) if __name__ == "__main__": main()
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): A, B, N = map(int, input().split()) def func(x): res = (A * x) // B - A * (x // B) return res print(func(min(N, B - 1))) if __name__ == "__main__": main()
replace
19
26
19
20
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; long long a, b, n; int main() { cin >> a >> b >> n; n = min(n, b); long long bsr = 0; for (int i = 1; i <= n; i++) { bsr = max(bsr, (a * i) / b - a * (i / b)); } cout << bsr << endl; }
#include <bits/stdc++.h> using namespace std; long long a, b, n; int main() { cin >> a >> b >> n; if (n < b) cout << (a * n) / b << endl; else cout << (a * (b - 1)) / b << endl; }
replace
7
13
7
11
TLE
p02696
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> #define REP(i, n) for ((i) = 0; (i) < (int)(n); (i)++) #define ll long long using namespace std; ll i, j, k; const ll MOD = 1000000000 + 7; ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ll term = b / gcd(a, b); vector<ll> A; if (n < term) { REP(i, n) { ll tmp = (i + 1) * a / b - a * ((i + 1) / b); A.push_back(tmp); } ans = *max_element(A.begin(), A.end()); } else { REP(i, term) { ll tmp = (i + 1) * a / b - a * ((i + 1) / b); A.push_back(tmp); } if (A[0] < A.back()) { ans = *max_element(A.begin(), A.end()) * (n / term) + *max_element(A.begin(), A.begin() + n % term); } else { ans = *max_element(A.begin(), A.end()); } } cout << ans << '\n'; return 0; }
#include <algorithm> #include <iostream> #include <vector> #define REP(i, n) for ((i) = 0; (i) < (int)(n); (i)++) #define ll long long using namespace std; ll i, j, k; const ll MOD = 1000000000 + 7; ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ans = a * min(b - 1, n) / b; cout << ans << '\n'; return 0; }
replace
24
45
24
25
0
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> using namespace std; void Main() { // input u_int64_t A, B, N; cin >> A >> B >> N; // translate u_int64_t ans = 0; if (N < B) { cout << (A * N) / B << endl; return; } for (u_int64_t x = B - 1; x <= N; x += B) { u_int64_t num = (A * x) / B - A * (x / B); ans = max(ans, num); } // output cout << ans << endl; } int main() { std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
#include <algorithm> #include <iomanip> #include <iostream> using namespace std; void Main() { // input u_int64_t A, B, N; cin >> A >> B >> N; // translate u_int64_t ans = 0; if (B == 1) { cout << 0 << endl; return; } if (N < B) { cout << (A * N) / B << endl; return; } for (u_int64_t x = B - 1; x <= N; x += B) { u_int64_t num = (A * x) / B - A * (x / B); ans = max(ans, num); } // output cout << ans << endl; } int main() { std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
insert
13
13
13
18
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long max = 0; for (long long x = 1; x <= n; x++) { long long v = ((a * x) / b) - (a * (x / b)); if (v > max) { max = v; } } cout << max; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long x = n < b - 1 ? n : b - 1; cout << (a * x) / b - a * (x / b); return 0; }
replace
7
16
7
9
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // #include <boost/multiprecision/cpp_dec_float.hpp> // #include <boost/multiprecision/cpp_int.hpp> /////////////////////////////////////////////////////////////// // namespace /////////////////////////////////////////////////////////////// using namespace std; // namespace mp = boost::multiprecision; /////////////////////////////////////////////////////////////// // types /////////////////////////////////////////////////////////////// using ll = long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; // using mpi = mp::cpp_int; // using mpf = mp::number<mp::cpp_dec_float<1024>>; /////////////////////////////////////////////////////////////// // mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a /////////////////////////////////////////////////////////////// ll mod(ll val, ll MOD) { long long res = val % MOD; if (res < 0) res += MOD; return res; } ll modinv(ll a, ll MOD) { ll b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MOD; if (u < 0) u += MOD; return u; } // const int MAX = -1; // ll fac[MAX], finv[MAX], inv[MAX]; // void com_init() { // initialize nCk table with O(N) // fac[0] = fac[1] = 1; // finv[0] = finv[1] = 1; // inv[1] = 1; // for (int i = 2; i < MAX; i++){ // fac[i] = fac[i - 1] * i % MOD; // inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; // finv[i] = finv[i - 1] * inv[i] % MOD; // } // } // ll com(int n, int k){ // nCk // if (n < k) return 0; // if (n < 0 || k < 0) return 0; // return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; // } ll f(ll a, ll b, ll x) { return floor(a * x / b) - a * floor(x / b); } int main() { ll a, b, n; cin >> a >> b >> n; unordered_set<ll> s; ll ans = 0; for (int x = 0; x <= n; ++x) { ll y = a * x % b; if (s.find(y) != s.end()) break; ans = max(ans, f(a, b, x)); } cout << ans << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // #include <boost/multiprecision/cpp_dec_float.hpp> // #include <boost/multiprecision/cpp_int.hpp> /////////////////////////////////////////////////////////////// // namespace /////////////////////////////////////////////////////////////// using namespace std; // namespace mp = boost::multiprecision; /////////////////////////////////////////////////////////////// // types /////////////////////////////////////////////////////////////// using ll = long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; // using mpi = mp::cpp_int; // using mpf = mp::number<mp::cpp_dec_float<1024>>; /////////////////////////////////////////////////////////////// // mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a /////////////////////////////////////////////////////////////// ll mod(ll val, ll MOD) { long long res = val % MOD; if (res < 0) res += MOD; return res; } ll modinv(ll a, ll MOD) { ll b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MOD; if (u < 0) u += MOD; return u; } // const int MAX = -1; // ll fac[MAX], finv[MAX], inv[MAX]; // void com_init() { // initialize nCk table with O(N) // fac[0] = fac[1] = 1; // finv[0] = finv[1] = 1; // inv[1] = 1; // for (int i = 2; i < MAX; i++){ // fac[i] = fac[i - 1] * i % MOD; // inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; // finv[i] = finv[i - 1] * inv[i] % MOD; // } // } // ll com(int n, int k){ // nCk // if (n < k) return 0; // if (n < 0 || k < 0) return 0; // return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; // } ll f(ll a, ll b, ll x) { return floor(a * x / b) - a * floor(x / b); } int main() { ll a, b, n; cin >> a >> b >> n; cout << f(a, b, min(n, b - 1)) << endl; return 0; }
replace
83
92
83
84
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++) using ll = long long; int main() { long long int a, b, n; cin >> a >> b >> n; int maxv = 0; if (n <= b) { long long int A, B; for (int i = 1; i <= n; i++) { A = int(a * i / b); B = int(i / b); maxv = max(maxv, int(A - B * a)); } cout << maxv << endl; } else { double A, B; long long int i = b - 1; A = double(a * i / b); B = double(i / b); maxv = max(maxv, int(floor(A) - floor(B) * a)); cout << maxv << endl; } } /* floor は x=nb+m とおくとnによらずmのみで決定する またmが大きい時差が最大になる */
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++) using ll = long long; int main() { long long int a, b, n; cin >> a >> b >> n; int maxv = 0; if (n < b) { // n<=bってことは[x/b]=0こていなのでAxがクソでかいほうがいいのでは? /*long long int A,B; for(int i=1;i<=n;i++){ A = int(a*i/b); B = int(i/b); maxv = max(maxv, int(A-B*a) ); }*/ double A; A = double(a * n / b); maxv = floor(A); cout << maxv << endl; } else { double A, B; long long int i = b - 1; A = double(a * i / b); B = double(i / b); maxv = max(maxv, int(floor(A) - floor(B) * a)); cout << maxv << endl; } } /* floor は x=nb+m とおくとnによらずmのみで決定する またmが大きい時差が最大になる */
replace
12
19
12
23
TLE
p02696
C++
Time Limit Exceeded
#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() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (int i = 1; i <= n; ++i) { ans = max(ans, ll(floor(a * i / b) - a * floor(i / b))); } cout << ans << endl; return 0; }
#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() { ll a, b, n; cin >> a >> b >> n; ll i = min(b - 1, n); ll ans = ll(floor(a * i / b) - a * floor(i / b)); cout << ans << endl; return 0; }
replace
9
13
9
11
TLE