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 <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; #define ll long long int main() { ll A, B, N; cin >> A; cin >> B; cin >> N; ll max = 0; for (ll x = 0; x <= N; x++) { if (max < (A * x / B) / 1 - A * ((x / B) / 1)) { max = (A * x / B) / 1 - A * ((x / B) / 1); } } cout << max << endl; }
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; #define ll long long int main() { ll A, B, N; cin >> A; cin >> B; cin >> N; ll max = 0; if (B > N) { max = (A * N / B) / 1 - A * ((N / B) / 1); } else { max = (A * (B - 1) / B) / 1 - A * (((B - 1) / B) / 1); } cout << max << endl; }
replace
14
18
14
18
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 all(v) v.begin(), v.end() int main() { long long A, B, N; cin >> A >> B >> N; long long ans = 0; long long NN = min(B, N); for (int i = 0; i <= NN; i++) { long long C = A * i; long long D = C / B; long long E = i / B; ans = max(ans, D - A * E); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() int main() { long long A, B, N; cin >> A >> B >> N; long long ans = 0; long long NN = min(B - 1, N); long long C = A * NN; long long D = C / B; long long E = NN / B; ans = D - A * E; cout << ans << endl; return 0; }
replace
8
15
8
13
TLE
p02696
C++
Time Limit Exceeded
// #pragma GCC optimize("Ofast") #pragma GCC optimize("O3") // #pragma GCC target("avx,avx2,fma") #include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr auto INF = 9223372036854775807; typedef long long int ll; typedef unsigned long long int ull; typedef unsigned long int ul; #define f(i, a, b) for (ll i = (ll)a; i < (ll)b; i += 1) #define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i -= 1) #define endl '\n' #define N 1000000007 // prime modulo value #define C 1000000001 #define M 998244353 #define all(x) x.begin(), x.end() using namespace std; // From Geeksforgeeks inline ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } // Power function took from geeksforgeeks ll power(ll x, ll y) { ll res = 1; x = x; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } double dist(ll x1, ll y1, ll x2, ll y2) { double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); return ans; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll a, b, n; cin >> a >> b >> n; ll maxi = 0; f(i, 0, n + 1) { ll ta = floor((a * i) / b); ll tb = floor(i / b); maxi = max(maxi, ta - (a * tb)); } cout << maxi; return 0; }
// #pragma GCC optimize("Ofast") #pragma GCC optimize("O3") // #pragma GCC target("avx,avx2,fma") #include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr auto INF = 9223372036854775807; typedef long long int ll; typedef unsigned long long int ull; typedef unsigned long int ul; #define f(i, a, b) for (ll i = (ll)a; i < (ll)b; i += 1) #define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i -= 1) #define endl '\n' #define N 1000000007 // prime modulo value #define C 1000000001 #define M 998244353 #define all(x) x.begin(), x.end() using namespace std; // From Geeksforgeeks inline ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } // Power function took from geeksforgeeks ll power(ll x, ll y) { ll res = 1; x = x; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x); y = y >> 1; x = (x * x); } return res; } double dist(ll x1, ll y1, ll x2, ll y2) { double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); return ans; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll a, b, n; cin >> a >> b >> n; ll ans = (a * min(n, b - 1)) / b; cout << ans; return 0; }
replace
59
66
59
61
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll a, b, n; cin >> a >> b >> n; ll max = 0; ll ans = 0; ll lol = 0; for (int i = 0; i <= n; i++) { ans = (a * i) / b - a * (i / b); if (ans > max) { max = ans; } } cout << max << endl; return 0; }
#include <bits/stdc++.h> #define ll long long int using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll a, b, n; cin >> a >> b >> n; ll max = 0; ll ans = 0; ll lol = 0; ll x = min(b - 1, n); max = (a * x) / b - a * (x / b); cout << max << endl; return 0; }
replace
12
18
12
14
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define GO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long int const int maxr = 1e5 + 5; int32_t main() { GO; int a, b, n; cin >> a >> b >> n; int ans = 0; for (int i = 0; i <= n; i++) { int value = (a * i) / b - a * (i / b); ans = max(ans, value); } cout << ans << endl; return 0; } //!
#include <bits/stdc++.h> using namespace std; #define GO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long int const int maxr = 1e5 + 5; int32_t main() { GO; int a, b, n; cin >> a >> b >> n; int ans = 0; int val = (b / n) * n; int i = val - 1; if (i >= 0 && i <= n) ans = max(ans, (a * i) / b - a * (i / b)); i = (n / b) * b; i--; if (i >= 0 && i <= n) ans = max(ans, (a * i) / b - a * (i / b)); i = n; ans = max(ans, (a * i) / b - a * (i / b)); cout << ans << endl; return 0; } //!
replace
16
20
16
26
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long maxi = 0; for (int i = 0; i <= n; i++) { maxi = max(maxi, (i % b)); } cout << a * maxi / b << endl; }
#include <iostream> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; if (n >= b) cout << a * (b - 1) / b << endl; else cout << a * n / b << endl; // n < b }
replace
7
13
7
11
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define ar array #define nl '\n' #define AC \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); using namespace std; const int M = 1e9 + 7; const int N = 2 * 1e5; ll ans = 0; int main() { AC ll a, b, n; cin >> a >> b >> n; ll x = 1; while (x < b && x <= n) { ans = max(ans, (ll)floor((double)(a * x) / b)); x++; } if (x <= n) { x = min(n, 2 * b - 1); ll test = floor((double)(a * x) / b) - a * (x / b); ans = max(ans, test); } cout << ans << endl; }
#include <bits/stdc++.h> #define ll long long #define ar array #define nl '\n' #define AC \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); using namespace std; const int M = 1e9 + 7; const int N = 2 * 1e5; ll ans = 0; int main() { AC ll a, b, n; cin >> a >> b >> n; ll x = min(b - 1, n); ans = max(ans, (ll)floor((double)(a * x) / b)); x = min(n, 2 * b - 1); ll test = floor((double)(a * x) / b) - a * (x / b); ans = max(ans, test); cout << ans << endl; }
replace
16
26
16
23
TLE
p02696
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { ll A, B, N; std::cin >> A, B, N; ll maxX = std::min(B - 1, N); std::cout << A * (maxX) / B; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { ll A, B, N; std::cin >> A >> B >> N; ll maxX = std::min<ll>(B - 1, N); std::cout << A * (maxX) / B; return 0; }
replace
7
9
7
10
0
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> int main() { long long A, B, N; std::cin >> A >> B >> N; if (N < B) { long long ans = A * N / B; std::cout << ans << std::endl; } else { long long max = 0; for (long long i = A - 1; i < A * B; i += A) { long long tmp = A * i / B - A * (long long)(i / B); max = max < tmp ? tmp : max; } std::cout << max << std::endl; } return 0; }
#include <bits/stdc++.h> int main() { long long A, B, N; std::cin >> A >> B >> N; if (N < B) { long long ans = A * N / B; std::cout << ans << std::endl; } else { long long x = B - 1; long long ans = A * x / B - A * (long long)(x / B); std::cout << ans << std::endl; } return 0; }
replace
10
16
10
13
TLE
p02696
C++
Time Limit Exceeded
#include <stdio.h> long long n, m, i, j, k, a, b; int main() { scanf("%lld%lld%lld", &a, &b, &n); for (i = 0; i <= n; i++) { if (a * i / b - a * (i / b) > m) { m = a * i / b - a * (i / b); k = i; } } printf("%lld\n", m); return 0; }
#include <stdio.h> long long n, m, i, j, k, a, b; int main() { scanf("%lld%lld%lld", &a, &b, &n); if (n >= b) n = b - 1; printf("%lld\n", a * n / b - a * (n / b)); return 0; }
replace
4
11
4
7
TLE
p02696
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; int main(void) { ll A, B, N; cin >> A >> B >> N; ll c = 0; for (ll i = 0; i <= N; i++) { c = max(c, (A * i) / B - A * (i / B)); } cout << c; return 0; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; int main(void) { ll A, B, N; cin >> A >> B >> N; ll c = 0; if (B <= N) { c = (A * (B - 1)) / B - A * ((B - 1) / B); } else { c = (A * N) / B - A * (N / B); } cout << c; return 0; }
replace
12
14
12
16
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> typedef long long ll; inline void up(ll &x, ll y) { x < y ? x = y : 0; } int main() { ll a, b, n, ans = 0; std::cin >> a >> b >> n; for (ll x = 1; x <= n; ++x) up(ans, (a * x) / b - a * (x / b)); std::cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> typedef long long ll; inline void up(ll &x, ll y) { x < y ? x = y : 0; } int main() { ll a, b, n, ans = 0; std::cin >> a >> b >> n; if (b - 1 <= n) std::cout << a * (b - 1) / b - a * ((b - 1) / b) << '\n'; else std::cout << a * n / b - a * (n / b) << '\n'; return 0; }
replace
8
11
8
12
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 < (int)(n); i++) int main() { ll a, b, n; cin >> a >> b >> n; ll ans = -10000100; for (ll x = 0; x <= n; x++) { ll f = (a * x) / b - a * (x / b); ans = max(ans, f); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll a, b, n; cin >> a >> b >> n; ll ans; if (b > n) { ans = (a * n) / b - a * (n / b); } else { ans = (a * (b - 1)) / b - a * ((b - 1) / b); } cout << ans << endl; }
replace
8
12
8
13
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cstdint> #include <iostream> #include <math.h> #include <sstream> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; ll ans, mx, mn, flag, sum, cnt; int main() { ll a, b, n; cin >> a >> b >> n; for (ll i = 1; i <= n; i++) { flag = floor(a * i / b) - a * floor(i / b); if (flag >= mx) mx = flag; else break; } cout << mx << endl; }
#include <algorithm> #include <cstdint> #include <iostream> #include <math.h> #include <sstream> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; ll ans, mx, mn, flag, sum, cnt; int main() { ll a, b, n; cin >> a >> b >> n; ll mn = min(b - 1, n); cout << ((a * mn) / b) - a * (mn / b) << endl; }
replace
17
26
17
19
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long #define space " " #define MOD (long long)1000000007 #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename T> void __f(const char *variable_name, T &&value) { cout << variable_name << ": " << value << endl; } template <typename T1, typename... T2> void __f(const char *names, T1 &&arg1, T2 &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } const ll N = 5e5 + 5; ll *v; ll a, b, n; void solve() { cin >> a >> b >> n; ll mult = 1; ll _max = 0, val, x = min(n, mult * b - 1); while (x <= n) { double t1 = (a * x) / b, t2 = x / b; val = floor(t1) - (a * floor(t2)); // trace(x, val); _max = max(_max, val); mult++; x = mult * b - 1; } cout << _max; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t = 1; // cout << "\n\nBLAH BLAH BLAH\n\n"; // cin >> t; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define space " " #define MOD (long long)1000000007 #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename T> void __f(const char *variable_name, T &&value) { cout << variable_name << ": " << value << endl; } template <typename T1, typename... T2> void __f(const char *names, T1 &&arg1, T2 &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } const ll N = 5e5 + 5; ll *v; ll a, b, n; void solve() { cin >> a >> b >> n; ll _max = 0, val, x; if (b > n) x = n; else if (b == n) x = n - 1; else x = b - 1; double t1 = (a * x) / b, t2 = x / b; val = floor(t1) - (a * floor(t2)); // trace(x, val); _max = max(_max, val); cout << _max; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t = 1; // cout << "\n\nBLAH BLAH BLAH\n\n"; // cin >> t; while (t--) { solve(); } return 0; }
replace
22
32
22
33
TLE
p02696
C++
Runtime Error
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; using vec = vector<ll>; using vect = vector<double>; using Graph = vector<vector<ll>>; #define loop(i, n) for (ll i = 0; i < n; i++) #define Loop(i, m, n) for (ll i = m; i < n; i++) #define pool(i, n) for (ll i = n; i >= 0; i--) #define Pool(i, m, n) for (ll i = n; i >= m; i--) #define mod 1000000007ll #define flagcount __builtin_popcount #define flag(x) (1 << x) #define flagadd(bit, x) bit |= flag(x) #define flagpop(bit, x) bit &= ~flag(x) #define flagon(bit, i) bit &flag(i) #define flagoff(bit, i) !(bit & (1 << i)) #define all(v) v.begin(), v.end() #define low2way(v, x) lower_bound(all(v), x) #define high2way(v, x) upper_bound(all(v), x) #define idx_lower(v, x) \ (distance(v.begin(), low2way(v, x))) // 配列vでx未満の要素数を返す #define idx_upper(v, x) \ (distance(v.begin(), high2way(v, x))) // 配列vでx以下の要素数を返す #define idx_lower2(v, x) \ (v.size() - idx_lower(v, x)) // 配列vでx以上の要素数を返す #define idx_upper2(v, x) \ (v.size() - idx_upper(v, x)) // 配列vでxより大きい要素の数を返す #define putout(a) cout << a << endl #define Gput(a, b) G[a].push_back(b) #define Sum(v) accumulate(all(v), 0ll) #define gcd(x, y) __gcd(x, y) ll ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } template <typename T> T lcm(T x, T y) { T z = gcd(x, y); return x * y / z; } template <typename T> bool primejudge(T n) { if (n < 2) return false; else if (n == 2) return true; else if (n % 2 == 0) return false; double sqrtn = sqrt(n); for (T i = 3; i < sqrtn + 1; i++) { if (n % i == 0) { return false; } i++; } return true; } // 場合によって使い分ける // const ll dx[4]={1,0,-1,0}; // const ll dy[4]={0,1,0,-1}; const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; // 2次元配列の宣言 // vector<vector<ll>> field(h, vector<ll>(w)); int main() { cout << fixed << setprecision(30); ll a, b, n; cin >> a >> b >> n; ll now = 0; ll ans = -1e18; ll count = 0; if (n == (ll)(1e12) && b == (ll)(1e12)) { putout(1 / 0); return 0; } if (n <= 1e7) { loop(i, n + 1) { ll pre = (a * i) / b - a * (i / b); ans = max(ans, pre); } } else { if (b <= 1e6) { while (now <= n && count <= 1e7) { ll pre = (a * now) / b - a * (now / b); ans = max(ans, pre); if (now >= 10 * (b - 1)) now += b; else now += 1; count++; } } else { now = b - 1; while (now <= n && count <= 1e7) { ll pre = (a * now) / b - a * (now / b); ans = max(ans, pre); if (now >= (b - 1)) now += b; count++; } } } putout(ans); return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; using vec = vector<ll>; using vect = vector<double>; using Graph = vector<vector<ll>>; #define loop(i, n) for (ll i = 0; i < n; i++) #define Loop(i, m, n) for (ll i = m; i < n; i++) #define pool(i, n) for (ll i = n; i >= 0; i--) #define Pool(i, m, n) for (ll i = n; i >= m; i--) #define mod 1000000007ll #define flagcount __builtin_popcount #define flag(x) (1 << x) #define flagadd(bit, x) bit |= flag(x) #define flagpop(bit, x) bit &= ~flag(x) #define flagon(bit, i) bit &flag(i) #define flagoff(bit, i) !(bit & (1 << i)) #define all(v) v.begin(), v.end() #define low2way(v, x) lower_bound(all(v), x) #define high2way(v, x) upper_bound(all(v), x) #define idx_lower(v, x) \ (distance(v.begin(), low2way(v, x))) // 配列vでx未満の要素数を返す #define idx_upper(v, x) \ (distance(v.begin(), high2way(v, x))) // 配列vでx以下の要素数を返す #define idx_lower2(v, x) \ (v.size() - idx_lower(v, x)) // 配列vでx以上の要素数を返す #define idx_upper2(v, x) \ (v.size() - idx_upper(v, x)) // 配列vでxより大きい要素の数を返す #define putout(a) cout << a << endl #define Gput(a, b) G[a].push_back(b) #define Sum(v) accumulate(all(v), 0ll) #define gcd(x, y) __gcd(x, y) ll ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } template <typename T> T lcm(T x, T y) { T z = gcd(x, y); return x * y / z; } template <typename T> bool primejudge(T n) { if (n < 2) return false; else if (n == 2) return true; else if (n % 2 == 0) return false; double sqrtn = sqrt(n); for (T i = 3; i < sqrtn + 1; i++) { if (n % i == 0) { return false; } i++; } return true; } // 場合によって使い分ける // const ll dx[4]={1,0,-1,0}; // const ll dy[4]={0,1,0,-1}; const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; // 2次元配列の宣言 // vector<vector<ll>> field(h, vector<ll>(w)); int main() { cout << fixed << setprecision(30); ll A, B, N; cin >> A >> B >> N; ll minn = min(B - 1, N); ll ans = A * minn / B - A * (minn / B); putout(ans); return 0; }
replace
69
105
69
73
0
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < (N); i++) #define repo(i, N) for (int i = 1; i < (N); i++) #define pb push_back #define mp make_pair #define ll long long #define fi first #define se second #define all(x) (x).begin(), (x).end() // #define num 1000000007 #define pi acos(-1.0) // cout << fixed << setprecision (20); 小数点以下20桁まで // intの最大値2147483647 ≒ 2×10^9 // long longの最大値9223372036854775807 ≒ 9×10^18 // オーバーフローに注意 long long にする //'1'+=16; で大文字Aに //'大文字'+=32; で小文字に // string s = to_string(int数); // int n = stoi(string文字列); int main() { long long a, b, n; cin >> a >> b >> n; long long ans = -10000; repo(i, min(b + 1, n + 1)) { long long z = (a * i) / b - a * (i / b); ans = max(ans, z); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < (N); i++) #define repo(i, N) for (int i = 1; i < (N); i++) #define pb push_back #define mp make_pair #define ll long long #define fi first #define se second #define all(x) (x).begin(), (x).end() // #define num 1000000007 #define pi acos(-1.0) // cout << fixed << setprecision (20); 小数点以下20桁まで // intの最大値2147483647 ≒ 2×10^9 // long longの最大値9223372036854775807 ≒ 9×10^18 // オーバーフローに注意 long long にする //'1'+=16; で大文字Aに //'大文字'+=32; で小文字に // string s = to_string(int数); // int n = stoi(string文字列); int main() { long long a, b, n; cin >> a >> b >> n; int ans; if (b - 1 <= n) ans = a * (b - 1) / b; else ans = (a * n) / b; cout << ans << endl; }
replace
26
31
26
33
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)n; i++) #define repa(i, s, n) for (int i = s; i < (int)n; i++) using namespace std; using ll = long long; typedef vector<int> vi; typedef pair<int, int> P; #define rrep(i, a, b) for (int i = a; i >= b; i--) signed main() { int a, b, n; cin >> a >> b >> n; int ans = 0; repa(i, 1, 1000000000) { int tmp = floor(a * i / b) - a * floor(i / b); ans = max(ans, tmp); } cout << ans << endl; }
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)n; i++) #define repa(i, s, n) for (int i = s; i < (int)n; i++) using namespace std; using ll = long long; typedef vector<int> vi; typedef pair<int, int> P; #define rrep(i, a, b) for (int i = a; i >= b; i--) signed main() { int a, b, n; cin >> a >> b >> n; int x = min(b - 1, n); cout << (a * x) / b - a * (x / b) << endl; }
replace
14
20
14
16
TLE
p02696
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define itn int int main(void) { long long a, b, n; cin >> a >> b >> n; long long ans = (a * (n) / b) - a * ((n) / b); for (long long int i = 0; i <= n / (b - 1); i++) { long long sum1 = (a * ((b - 1) * i)) / b; long long sum2 = a * (((b - 1) * i) / b); ans = max(ans, sum1 - sum2); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define itn int int main(void) { long long a, b, n; cin >> a >> b >> n; long long ans = (a * n / b) - a * (n / b); if (b - 1 <= n) { ans = max(ans, (a * (b - 1) / b) - a * ((b - 1) / b)); } cout << ans << endl; }
replace
8
14
8
11
0
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { double a, b, n, ans = 0; cin >> a >> b >> n; for (double i = 1; i <= min(n, b); i++) { ans = max(ans, (floor(a * i / b) - a * floor(i / b))); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { double a, b, n, ans = 0; cin >> a >> b >> n; if (b - 1 < n) ans = floor(a * (b - 1) / b); else ans = floor(a * n / b); cout << ans << endl; }
replace
6
9
6
10
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define REP(i, x, n) for (int i = x; i < (int)n; i++) #define rep(i, n) REP(i, 0, n) #define sp(p) cout << setprecision(16) << fixed << p << endl; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define SORT(a) sort(all(a)) #define RSORT(a) sort(rall(a)) #define UNIQ(a) unique(all(a)) #define UNIQNUM(a) UNIQ(a) - a.begin() #define UNIQIT(a) a.erase(UNIQ(a), a.end()); #define VOUT(v, i) \ rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : " "); #define vout(v) VOUT(v, z); #define vdbg(v, i) \ cout << #v << ": "; \ for (int i = 0; i < (int)v.size(); i++) { \ cout << v[i] << " "; \ } \ cout << "\n"; #define vmin(v) *min_element(all(v)) #define vmax(v) *max_element(all(v)) #define vsum(v) accumulate(all(v), 0LL) #define MOUT(m, r, c) \ rep(i, r) { \ rep(j, c) { cout << m[i][j] << " "; } \ cout << endl; \ } #define mout(m) MOUT(m, m.size(), m[0].size()) #define debg(a) cout << #a << ": " << a << endl; #define show(a) \ for (cont & y : a) { \ for (cont & x : y) { \ cout << x << " "; \ } \ cout << endl; \ } #define digit(a) to_string(a).length(); template <class T> inline int out(const T &t) { print(t); putchar('\n'); return 0; } // template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));} // template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;} bool is_palindrome(string s) { return s == string(s.rbegin(), s.rend()); } typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef vector<ll> V; typedef vector<vector<ll>> VV; // const long long MOD=1000000007; const long long INF = 1e18; #define EPS (1e-7) #define PI (acos(-1)) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } // bool check(ll mid){ // } int main() { long long A; scanf("%lld", &A); long long B; scanf("%lld", &B); long long N; scanf("%lld", &N); // solve(A, B, N); // ll ng=-1, ok=N; // while(abs(ok-ng)>1){ // int mid=(ok+ng)/2; // if(check(mid)){ // ok=mid; // }else{ // ng=mid; // } // } ll ma = 0; if (B - 1 <= N) { ll b = B - 1; cout << floor(A * b * 1.0 / B) - A * floor(b * 1.0 / B) << endl; return 0; } if (N <= 10e7) { for (long long i = 0; i <= N; i++) { ll v = floor(A * i * 1.0 / B) - A * floor(i * 1.0 / B); // cout << v << endl; ma = max(ma, v); } } else { for (long long i = 0; i <= 10e8; i++) { ll v = floor(A * i * 1.0 / B) - A * floor(i * 1.0 / B); // cout << v << endl; ma = max(ma, v); } } // ll b = B-1; // ma = floor(A*b*1.0/B) - A*floor(b*1.0/B); cout << ma << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, x, n) for (int i = x; i < (int)n; i++) #define rep(i, n) REP(i, 0, n) #define sp(p) cout << setprecision(16) << fixed << p << endl; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define SORT(a) sort(all(a)) #define RSORT(a) sort(rall(a)) #define UNIQ(a) unique(all(a)) #define UNIQNUM(a) UNIQ(a) - a.begin() #define UNIQIT(a) a.erase(UNIQ(a), a.end()); #define VOUT(v, i) \ rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : " "); #define vout(v) VOUT(v, z); #define vdbg(v, i) \ cout << #v << ": "; \ for (int i = 0; i < (int)v.size(); i++) { \ cout << v[i] << " "; \ } \ cout << "\n"; #define vmin(v) *min_element(all(v)) #define vmax(v) *max_element(all(v)) #define vsum(v) accumulate(all(v), 0LL) #define MOUT(m, r, c) \ rep(i, r) { \ rep(j, c) { cout << m[i][j] << " "; } \ cout << endl; \ } #define mout(m) MOUT(m, m.size(), m[0].size()) #define debg(a) cout << #a << ": " << a << endl; #define show(a) \ for (cont & y : a) { \ for (cont & x : y) { \ cout << x << " "; \ } \ cout << endl; \ } #define digit(a) to_string(a).length(); template <class T> inline int out(const T &t) { print(t); putchar('\n'); return 0; } // template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));} // template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;} bool is_palindrome(string s) { return s == string(s.rbegin(), s.rend()); } typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef vector<ll> V; typedef vector<vector<ll>> VV; // const long long MOD=1000000007; const long long INF = 1e18; #define EPS (1e-7) #define PI (acos(-1)) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } // bool check(ll mid){ // } int main() { long long A; scanf("%lld", &A); long long B; scanf("%lld", &B); long long N; scanf("%lld", &N); // solve(A, B, N); // ll ng=-1, ok=N; // while(abs(ok-ng)>1){ // int mid=(ok+ng)/2; // if(check(mid)){ // ok=mid; // }else{ // ng=mid; // } // } ll ma = 0; if (B - 1 <= N) { ll b = B - 1; cout << floor(A * b * 1.0 / B) - A * floor(b * 1.0 / B) << endl; return 0; } if (N <= 10e7) { for (long long i = 0; i <= N; i++) { ll v = floor(A * i * 1.0 / B) - A * floor(i * 1.0 / B); // cout << v << endl; ma = max(ma, v); } } else { for (long long i = N; N - i <= 10e7; i--) { ll v = floor(A * i * 1.0 / B) - A * floor(i * 1.0 / B); // cout << v << endl; ma = max(ma, v); } } // ll b = B-1; // ma = floor(A*b*1.0/B) - A*floor(b*1.0/B); cout << ma << endl; return 0; }
replace
109
110
109
110
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define f(i, j, k) for (int i = j; i < k; i++) using namespace std; int main() { long long a, b, c, ans = 0, j; cin >> a >> b >> c; j = c / b; f(i, 1, j + 1) { if (ans < floor(a * (b * i - 1) / b) - a * floor((b * i - 1) / b)) { ans = floor(a * (b * i - 1) / b) - a * floor((b * i - 1) / b); } if (ans == a - 1 - a / b) { cout << a - 1 - a / b << endl; return 0; } } if (ans < floor(a * c / b) - a * floor(c / b)) { ans = floor(a * c / b) - a * floor(c / b); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define f(i, j, k) for (int i = j; i < k; i++) using namespace std; int main() { long long a, b, c, ans = 0, j; cin >> a >> b >> c; j = c / b; if (b == 1) { cout << 0 << endl; return 0; } f(i, 1, j + 1) { if (ans < floor(a * (b * i - 1) / b) - a * floor((b * i - 1) / b)) { ans = floor(a * (b * i - 1) / b) - a * floor((b * i - 1) / b); } if (ans == a - 1 - a / b) { cout << a - 1 - a / b << endl; return 0; } } if (ans < floor(a * c / b) - a * floor(c / b)) { ans = floor(a * c / b) - a * floor(c / b); } cout << ans << endl; return 0; }
replace
7
8
7
11
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> #pragma region Macros #define int long long #define double long double constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; const int INF = 1e9; #define krep(i, k, n) for (int i = (k); i < n + k; i++) #define Krep(i, k, n) for (int i = (k); i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define REP(i, n) for (int i = 1; i <= n; i++) #define LAST(x) x[x.size() - 1] #define ALL(x) (x).begin(), (x).end() #define swap(a, b) (a += b, b = a - b, a -= b) #define DIVCEIL(a, b) ((a + b - 1) / b) #define SUM1n(n) ((n) * (n + 1) / 2) #define SUMkn(k, n) (SUM1n(n) - SUM1n(k - 1)) // int CHMAX int intpow(int a, int n) { // a^nのint ver if (n == 0) return 1; else { rep(i, n - 1) a *= a; return a; } } int MODPOW(int a, int n, int mod) { // a^n mod int ans = 1; while (n > 0) { if (n & 1) ans = ans * a % mod; a = a * a % mod; n >>= 1; } return ans; } int FACT(int a) { if (a == 0) return 1; else return a * FACT(a - 1); } int MODFACT(int a, int mod) { int ans = 1; REP(i, a) { ans *= i; ans %= MOD; } return ans; } int nPr(int n, int r) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) sum *= i; return sum; } int MODnPr(int n, int r, int mod) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) { sum *= i; sum = sum % MOD; } return sum; } // int nCr(int n, int r) int nCr2(int n, int r) { return FACT(n) / (FACT(r) * FACT(n - r)); } int GCD(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; if (a % b == 0) return b; return GCD(b, a % b); } int LCM(int a, int b) { return a * b / GCD(a, b); } int NUMOFDIV(int n) { // 約数の数(だっけ?) int ans = 0; REP(i, n) { if (n % i == 0) ans++; } return ans; } int CEIL1(int n) { // 1桁目切り上げ return (n + 9) / 10 * 10; } int GetDigit(int n) { return log10(n) + 1; } int DIGIT(int n, int k) { // nのk桁目 rep(i, k - 1) n /= 10; return n % 10; } int DIGITSUM(int n) { int sum = 0, dig; while (n) { dig = n % 10; sum += dig; n /= 10; } return sum; } int DIVTIME(int n, int k) { // nをkで何回割れるか的な int div = 0; while (n % k == 0) { div++; n /= k; } return div; } int binary(int n) { // 10進数→2進数 int ans = 0; for (int i = 0; n > 0; i++) { ans += n % 2 * intpow(10, i); n /= 2; } return ans; } int intabs(int n) { if (n < 0) return -1 * n; else return n; } double LOG(int a, int b) { return log(b) / log(a); } double DISTANCE(int x1, int y1, int x2, int y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } inline bool BETWEEN(int x, int min, int max) { if (min <= x && x <= max) return true; else return false; } inline bool between(int x, int min, int max) { if (min < x && x < max) return true; else return false; } inline bool PRIMEOR(int x) { if (x == 1) return false; if (x == 2) return true; if (x % 2 == 0) return false; double sqrtx = sqrt(x); for (int i = 3; i <= sqrtx; i += 2) { if (x % i == 0) return false; } return true; } bool SQRTOR(int n) { if (sqrt(n) == (int)sqrt(n)) return true; else return false; } // 順位付け using namespace std; #pragma endregion signed main() { int A, B, N; cin >> A >> B >> N; int ans = 0; rep(i, N + 1) { int x = floor((A * i) / B) - A * floor(i / B); ans = max(ans, x); } cout << ans; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> #pragma region Macros #define int long long #define double long double constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; const int INF = 1e9; #define krep(i, k, n) for (int i = (k); i < n + k; i++) #define Krep(i, k, n) for (int i = (k); i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define REP(i, n) for (int i = 1; i <= n; i++) #define LAST(x) x[x.size() - 1] #define ALL(x) (x).begin(), (x).end() #define swap(a, b) (a += b, b = a - b, a -= b) #define DIVCEIL(a, b) ((a + b - 1) / b) #define SUM1n(n) ((n) * (n + 1) / 2) #define SUMkn(k, n) (SUM1n(n) - SUM1n(k - 1)) // int CHMAX int intpow(int a, int n) { // a^nのint ver if (n == 0) return 1; else { rep(i, n - 1) a *= a; return a; } } int MODPOW(int a, int n, int mod) { // a^n mod int ans = 1; while (n > 0) { if (n & 1) ans = ans * a % mod; a = a * a % mod; n >>= 1; } return ans; } int FACT(int a) { if (a == 0) return 1; else return a * FACT(a - 1); } int MODFACT(int a, int mod) { int ans = 1; REP(i, a) { ans *= i; ans %= MOD; } return ans; } int nPr(int n, int r) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) sum *= i; return sum; } int MODnPr(int n, int r, int mod) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) { sum *= i; sum = sum % MOD; } return sum; } // int nCr(int n, int r) int nCr2(int n, int r) { return FACT(n) / (FACT(r) * FACT(n - r)); } int GCD(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; if (a % b == 0) return b; return GCD(b, a % b); } int LCM(int a, int b) { return a * b / GCD(a, b); } int NUMOFDIV(int n) { // 約数の数(だっけ?) int ans = 0; REP(i, n) { if (n % i == 0) ans++; } return ans; } int CEIL1(int n) { // 1桁目切り上げ return (n + 9) / 10 * 10; } int GetDigit(int n) { return log10(n) + 1; } int DIGIT(int n, int k) { // nのk桁目 rep(i, k - 1) n /= 10; return n % 10; } int DIGITSUM(int n) { int sum = 0, dig; while (n) { dig = n % 10; sum += dig; n /= 10; } return sum; } int DIVTIME(int n, int k) { // nをkで何回割れるか的な int div = 0; while (n % k == 0) { div++; n /= k; } return div; } int binary(int n) { // 10進数→2進数 int ans = 0; for (int i = 0; n > 0; i++) { ans += n % 2 * intpow(10, i); n /= 2; } return ans; } int intabs(int n) { if (n < 0) return -1 * n; else return n; } double LOG(int a, int b) { return log(b) / log(a); } double DISTANCE(int x1, int y1, int x2, int y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } inline bool BETWEEN(int x, int min, int max) { if (min <= x && x <= max) return true; else return false; } inline bool between(int x, int min, int max) { if (min < x && x < max) return true; else return false; } inline bool PRIMEOR(int x) { if (x == 1) return false; if (x == 2) return true; if (x % 2 == 0) return false; double sqrtx = sqrt(x); for (int i = 3; i <= sqrtx; i += 2) { if (x % i == 0) return false; } return true; } bool SQRTOR(int n) { if (sqrt(n) == (int)sqrt(n)) return true; else return false; } // 順位付け using namespace std; #pragma endregion signed main() { int A, B, N; cin >> A >> B >> N; int ans; if (N >= B - 1) ans = floor((A * (B - 1)) / B) - A * (floor((B - 1) / B)); else ans = floor((A * (N)) / B) - A * (floor((N) / B)); cout << ans; }
replace
186
191
186
191
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--) #define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--) #define each(it, c) \ for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++) #define all(obj) (obj).begin(), (obj).end() #define pcount __builtin_popcount #define SZ(x) ((int)(x).size()) #define LEN(x) ((int)(x).length()) #define dump(x) cerr << #x << " = " << (x) << endl; #define endl "\n" template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } typedef long long lint; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); lint a, b, n, max = -1; cin >> a >> b >> n; if (b - 1 <= n) { lint mod = n % b; lint num = n - mod - 1; max = floor(a * num * 1.0 / b) - a * floor(num * 1.0 / b); } else { for (lint i = n; 1 <= i; i--) { lint tmp = floor(a * i * 1.0 / b) - a * floor(i * 1.0 / b); chmax(max, tmp); if (i % b == b - 1) break; } } cout << max << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--) #define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--) #define each(it, c) \ for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++) #define all(obj) (obj).begin(), (obj).end() #define pcount __builtin_popcount #define SZ(x) ((int)(x).size()) #define LEN(x) ((int)(x).length()) #define dump(x) cerr << #x << " = " << (x) << endl; #define endl "\n" template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } typedef long long lint; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); lint a, b, n, max = -1; cin >> a >> b >> n; if (b - 1 <= n) { lint mod = n % b; lint num = n - mod - 1; max = floor(a * num * 1.0 / b) - a * floor(num * 1.0 / b); } else { max = floor(a * n * 1.0 / b) - a * floor(n * 1.0 / b); } cout << max << endl; }
replace
46
52
46
47
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)n; ++i) const ll INF = 999999999999999; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ll cnt = 0; while (true) { ans = max((ll)(a * n / b) - a * (ll)(n / b), ans); n--; cnt++; if (cnt == 1000000000 || n == 0) break; } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)n; ++i) const ll INF = 999999999999999; int main() { ll a, b, n; cin >> a >> b >> n; n = min(n, b - 1); cout << (a * n - a * n % b) / b - a * (n - n % b) / b; return 0; }
replace
10
20
10
13
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 = 0, y = min(b - 1, n); vector<int> ans; while (((a * x) / b) - (a * (x / b)) < a && x <= y) { ans.push_back(((a * x) / b) - (a * (x / b))); x++; } sort(ans.begin(), ans.end()); reverse(ans.begin(), ans.end()); cout << ans.at(0) << 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(n, b - 1); cout << ((a * (x % b)) - ((a * (x % b)) % b)) / b << endl; return 0; }
replace
5
14
5
7
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> /* ॐ Shree ॐ */ /* ॐ ॐ ॐ ॐ भूर् भुवः स्वः तत् सवितुर्वरेण्यं भर्गो देवस्य धीमहि धियो यो नः प्रचोदयात् */ using namespace std; typedef long long int ll; vector<int> ve(3006, 0); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // online submission #endif long long int a, b, c; cin >> a >> b >> c; ll mx = 0, ans = 0; for (int x = b / a; x <= min(b, c); x++) { ll t = floor((double)(a * x / b)) - a * floor((double)(x / b)); mx = max(t, mx); } cout << mx; }
#include <bits/stdc++.h> /* ॐ Shree ॐ */ /* ॐ ॐ ॐ ॐ भूर् भुवः स्वः तत् सवितुर्वरेण्यं भर्गो देवस्य धीमहि धियो यो नः प्रचोदयात् */ using namespace std; typedef long long int ll; vector<int> ve(3006, 0); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // online submission #endif long long int a, b, c; cin >> a >> b >> c; ll mx = 0, ans = 0; ll x = min(b - 1, c); ll t = floor((double)(a * x / b)) - a * floor((double)(x / b)); cout << t; }
replace
25
30
25
28
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans = -1; for (long long i = 0; i < n + 1; i++) { ans = max(ans, a * i / b - (i / b) * a); } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans = -1; if (n < b - 1) { ans = a * n / b; } else { ans = a * (b - 1) / b; } cout << ans << endl; }
replace
8
10
8
12
TLE
p02696
C++
Time Limit Exceeded
#include <cmath> #include <cstring> #include <fstream> #include <iostream> #include <string> using namespace std; int main() { unsigned long long a, b; long long max = -9999999; unsigned long long n; int h; cin >> a >> b >> n; for (int i = 0; i <= n / b; i++) { h = i; } for (int i = 0; i < h; i++) { if (max < floor(a * ((b - 1) + i * b) / b) - a * i) max = floor(a * ((b - 1) + i * b) / b) - a * i; } if (max < floor(a * n / b) - floor(n / b) * a) max = floor(a * n / b) - floor(n / b) * a; cout << max; }
#include <cmath> #include <cstring> #include <fstream> #include <iostream> #include <string> using namespace std; int main() { unsigned long long a, b; long long max = -9999999; unsigned long long n; int h; cin >> a >> b >> n; for (int i = 0; i <= n / b; i++) { h = i; } if (h > 0) { for (int i = 0; i < 1; i++) { if (max < floor(a * ((b - 1) + i * b) / b) - a * i) max = floor(a * ((b - 1) + i * b) / b) - a * i; } } if (max < floor(a * n / b) - floor(n / b) * a) max = floor(a * n / b) - floor(n / b) * a; cout << max; }
replace
15
18
15
20
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define FOR(i, m, n) for (ll i = m; i < (n); i++) #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() // #define print(ele) cout << (ele) << "\n" #define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n" using namespace std; typedef long long ll; typedef vector<int> ivec; typedef vector<string> svec; typedef vector<ll> lvec; const int mod = 1e9 + 7; const ll INF = 1000000000000000000LL; void print() { cout << endl; } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; ll y = min(a, n); for (ll i = n; i >= y - 100; i--) { if (i < 0) break; ll x = floor(a * i / b) - a * floor(i / b); ans = max(ans, x); } print(ans); return 0; }
#include <bits/stdc++.h> #define FOR(i, m, n) for (ll i = m; i < (n); i++) #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() // #define print(ele) cout << (ele) << "\n" #define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n" using namespace std; typedef long long ll; typedef vector<int> ivec; typedef vector<string> svec; typedef vector<ll> lvec; const int mod = 1e9 + 7; const ll INF = 1000000000000000000LL; void print() { cout << endl; } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); } int main() { ll a, b, n; cin >> a >> b >> n; ll x = n; if (x >= b - 1) x = b - 1; ll ans = a * x / b - a * (x / b); print(ans); return 0; }
replace
31
39
31
35
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 max = 0; ll x; if (n >= b) { x = b - 1; } else { x = n; } while (x <= n) { ll Ax = a * x; ll value = Ax / b - a * (x / b); if (value > max) { max = value; } x += b; } cout << max << 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 max = 0; ll x; if (n >= b) { x = b - 1; } else { x = n; } while (x <= n) { ll Ax = a * x; ll value = Ax / b - a * (x / b); if (value > max) { max = value; } break; } cout << max << endl; return 0; }
replace
23
24
23
24
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define sort(s) sort(s.begin(), s.end()) #define reverse(s) reverse(s.begin(), s.end()) #define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++) const ll mod = 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; } // 素数判定 bool isPrime(ll x) { ll i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } // 桁和 int digsum(ll n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } // 桁数 int dignum(ll n) { int res = 0; while (n > 0) { res++; n /= 10; } return res; } // 文字列中の特定の文字カウント ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } // 階乗 ll ka(ll i) { ll res = 1; while (i > 0) { res = res * i; i--; } return res; } // ncr ll ncr(ll x, ll y) { ll a = x; ll b = 1; if (y > (x / 2)) { y = x - y; } for (ll i = 1; i < y; i++) { a *= x - i; b *= i + 1; } return a / b; } // フィボナッチ数列 ll f(ll x) { ll dp[x + 1]; dp[1] = 1; dp[2] = 1; for (ll i = 3; i <= x; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[x]; } // char->int int ctoi(char c) { return c - '0'; } int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (int i = 1; i <= n; i++) { ans = max(ans, (a * i / b - (a * (i / b)))); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define sort(s) sort(s.begin(), s.end()) #define reverse(s) reverse(s.begin(), s.end()) #define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++) const ll mod = 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; } // 素数判定 bool isPrime(ll x) { ll i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } // 桁和 int digsum(ll n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } // 桁数 int dignum(ll n) { int res = 0; while (n > 0) { res++; n /= 10; } return res; } // 文字列中の特定の文字カウント ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } // 階乗 ll ka(ll i) { ll res = 1; while (i > 0) { res = res * i; i--; } return res; } // ncr ll ncr(ll x, ll y) { ll a = x; ll b = 1; if (y > (x / 2)) { y = x - y; } for (ll i = 1; i < y; i++) { a *= x - i; b *= i + 1; } return a / b; } // フィボナッチ数列 ll f(ll x) { ll dp[x + 1]; dp[1] = 1; dp[2] = 1; for (ll i = 3; i <= x; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[x]; } // char->int int ctoi(char c) { return c - '0'; } int main() { ll a, b, n; cin >> a >> b >> n; ll y = min(b - 1, n); ll ans = a * (y) / b - (a * ((y) / b)); ans = max(ans, a * n / b - (a * (n / b))); cout << ans << endl; }
replace
98
103
98
101
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <iostream> #define ll long long using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; if (b == 1) { cout << 0 << endl; return 0; } ll ans = -1e18; n = min(n, b - 1); for (int i = 0; i <= n; i++) { ans = max(ans, (a * i) / b - a * (i / b)); } cout << ans << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #define ll long long using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; if (b == 1) { cout << 0 << endl; return 0; } ll ans = -1e18; n = min(n, b - 1); ans = max(ans, (a * n) / b - a * (n / b)); cout << ans << endl; return 0; }
replace
18
21
18
21
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> // using namespace std; using std::cin, std::cout, std::endl, std::string; using ll = long long; #define rep(countName, left, right, up) \ for (auto countName = left; countName < right; countName += up) #define REP(countName, end) \ for (auto countName = 0; countName < end; countName++) #define rev(countName, right, left, down) \ for (auto countName = right; countName >= left; countName -= down) #define REV(countName, end) \ for (auto countName = end; countName >= 0; countName--) auto solve1(ll a, ll b, ll n) { ll ans = 0; rep(x, 0, n + 1, b - 1) { ans = std::max(ans, ((a * x) / b) - a * (x / b)); } ans = std::max(ans, ((a * n) / b) - a * (n / b)); return ans; } int main(void) { ll a, b, n; cin >> a >> b >> n; cout << solve1(a, b, n) << endl; return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> // using namespace std; using std::cin, std::cout, std::endl, std::string; using ll = long long; #define rep(countName, left, right, up) \ for (auto countName = left; countName < right; countName += up) #define REP(countName, end) \ for (auto countName = 0; countName < end; countName++) #define rev(countName, right, left, down) \ for (auto countName = right; countName >= left; countName -= down) #define REV(countName, end) \ for (auto countName = end; countName >= 0; countName--) auto solve1(ll a, ll b, ll n) { auto min = std::min(b - 1, n); return ((a * min) / b) - a * (min / b); } int main(void) { ll a, b, n; cin >> a >> b >> n; cout << solve1(a, b, n) << endl; return 0; }
replace
26
30
26
28
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> // #include <boost/array.hpp> // #include <boost/range/numeric.hpp> // #include <boost/range/algorithm.hpp> // #include <boost/multiprecision/cpp_int.hpp> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; // using namespace boost::multiprecision; constexpr long long INF = LLONG_MAX; constexpr long long MOD = 1000000007; constexpr long double PI = M_PI; #define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); ++i) #define RFOR(i, n, r) for (ll i = (ll)(n - 1); i >= r; --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(x) x.begin(), x.end() #define CALL(x) x.cbegin(), x.cend() #define RALL(x) x.rbegin(), x.rend() #define CRALL(x) x.crbegin(), x.crend() #define cout cout << fixed << setprecision(12) #define dbglf cerr << '\n' #define ACCM(arr) accumulate(ALL(arr), 0LL) #define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl #define YES(ex) cout << ((ex) ? "YES" : "NO") << endl using ll = long long int; using ull = unsigned long long int; using ld = long double; using vi = vector<ll>; using vvi = vector<vi>; using vp = vector<pair<ll, ll>>; using vs = vector<string>; using vc = vector<char>; using lst = list<ll>; using pq = priority_queue<ll>; template <typename T> inline void veccin(vector<T> &v) { for (auto &&e : v) { cin >> e; } } template <typename T> inline void dbg(T a) { cerr << a << ' '; } ll n, m, k; ll ans = 0, sum = 0, cnt = 0; // ld d; string s /*1, s2, s3*/; char c /*1, c2, c3*/; bool flag = false; /*--------------------template--------------------*/ int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k; RREP(i, k) { dbg(floor(n * (i + 1) / m) - n * floor((i + 1) / m)); dbglf; } ans = floor(n * (m - 1) / m) - n * floor((m - 1) / m); sum = floor(n * k / m) - n * floor(k / m); cout << (m > k ? sum : ans) << endl; }
#include <bits/stdc++.h> // #include <boost/array.hpp> // #include <boost/range/numeric.hpp> // #include <boost/range/algorithm.hpp> // #include <boost/multiprecision/cpp_int.hpp> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; // using namespace boost::multiprecision; constexpr long long INF = LLONG_MAX; constexpr long long MOD = 1000000007; constexpr long double PI = M_PI; #define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); ++i) #define RFOR(i, n, r) for (ll i = (ll)(n - 1); i >= r; --i) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(x) x.begin(), x.end() #define CALL(x) x.cbegin(), x.cend() #define RALL(x) x.rbegin(), x.rend() #define CRALL(x) x.crbegin(), x.crend() #define cout cout << fixed << setprecision(12) #define dbglf cerr << '\n' #define ACCM(arr) accumulate(ALL(arr), 0LL) #define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl #define YES(ex) cout << ((ex) ? "YES" : "NO") << endl using ll = long long int; using ull = unsigned long long int; using ld = long double; using vi = vector<ll>; using vvi = vector<vi>; using vp = vector<pair<ll, ll>>; using vs = vector<string>; using vc = vector<char>; using lst = list<ll>; using pq = priority_queue<ll>; template <typename T> inline void veccin(vector<T> &v) { for (auto &&e : v) { cin >> e; } } template <typename T> inline void dbg(T a) { cerr << a << ' '; } ll n, m, k; ll ans = 0, sum = 0, cnt = 0; // ld d; string s /*1, s2, s3*/; char c /*1, c2, c3*/; bool flag = false; /*--------------------template--------------------*/ int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k; ans = floor(n * (m - 1) / m) - n * floor((m - 1) / m); sum = floor(n * k / m) - n * floor(k / m); cout << (m > k ? sum : ans) << endl; }
delete
65
69
65
65
TLE
p02696
C++
Time Limit Exceeded
#include <cmath> #include <iostream> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) a = b; return true; return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (int i = 1; i <= n; i++) { ll tmp = floor(a * i / b) - a * floor(i / b); chmax(ans, tmp); } cout << ans << '\n'; return 0; }
#include <cmath> #include <iostream> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) a = b; return true; return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n; cin >> a >> b >> n; ll x; if (n < b - 1) x = n; else x = b - 1; ll ans = floor(a * (x % b) / b); cout << ans << '\n'; return 0; }
replace
20
25
20
27
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef long double ld; const ll INF = (ll)1e18; #define pb push_back #define mp make_pair #define fi first #define se second #define INF ll(1e18) #define MOD 1000000007 #define print(a) \ ; \ for (auto x : a) \ cout << x << " "; \ cout << "\n"; #define mset(a) \ ; \ memset(a, 0, sizeof(a)); int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll a, b, n; cin >> a >> b >> n; ll Max = -INF; for (ll i = 1; i <= n; i++) { ll d1 = (ll)((ld)(a * i) / b); ll d2 = (ll)i / b; Max = max(Max, d1 - a * d2); } cout << Max << "\n"; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef long double ld; const ll INF = (ll)1e18; #define pb push_back #define mp make_pair #define fi first #define se second #define INF ll(1e18) #define MOD 1000000007 #define print(a) \ ; \ for (auto x : a) \ cout << x << " "; \ cout << "\n"; #define mset(a) \ ; \ memset(a, 0, sizeof(a)); int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll a, b, n; cin >> a >> b >> n; ll j = min(b - 1, n); cout << a * j / b - a * (j / b) << "\n"; }
replace
28
35
28
30
TLE
p02696
C++
Time Limit Exceeded
// I'm a f*cking looser #include <bits/stdc++.h> using namespace std; #define ll long long #define fasino \ ios_base::sync_with_stdio(false); \ cin.tie(0); #define asc(A) sort(A.begin(), A.end()) #define dsc(A) sort(A.begin(), A.end(), greater<ll>()) #define input(A, N) \ for (ll i = 0; i < N; i++) \ cin >> A[i]; int main() { fasino #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); #endif ll a, b, n; cin >> a >> b >> n; ll maxi = INT32_MIN; for (int i = 1; i <= min(b, n); i++) { // ll i=b; ll m = floor(double(a * i) / b) - (a * floor(double(i) / b)); maxi = max(maxi, m); } cout << maxi; return 0; }
// I'm a f*cking looser #include <bits/stdc++.h> using namespace std; #define ll long long #define fasino \ ios_base::sync_with_stdio(false); \ cin.tie(0); #define asc(A) sort(A.begin(), A.end()) #define dsc(A) sort(A.begin(), A.end(), greater<ll>()) #define input(A, N) \ for (ll i = 0; i < N; i++) \ cin >> A[i]; int main() { fasino #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); #endif ll a, b, n; cin >> a >> b >> n; ll maxi = INT32_MIN; // for(int i=;i<min(b,n);i++){ // ll i=b; maxi = floor(double(a * (min(b, n) - 1)) / b) - (a * floor(double(min(b, n) - 1) / b)); ll k = floor(double(a * (min(b, n))) / b) - (a * floor(double(min(b, n)) / b)); maxi = max(maxi, k); // if(b==1){ // maxi = floor(double(a*n)/b)-(a*floor(double(n))/b); // } // maxi = max(maxi,m); // // } cout << maxi; return 0; }
replace
21
26
21
34
TLE
p02696
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; #define sp(x) cout << setprecision(x); #define all(a) (a).begin(), (a).end() #define inf 10000000 #define linf INT64_MAX * 0.99 #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define yes "Yes" #define no "No" #define divs 1000000007 #define dive 1000000009 #define pi 3.141592653589793238 typedef pair<int, int> P; signed main() { // ios::sync_with_stdio(false); // cin.tie(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); long long A; scanf("%lld", &A); long long B; scanf("%lld", &B); long long N; scanf("%lld", &N); int ans = 0; REP(i, N + 1) { ans = max(ans, (A * i) / B - A * (i / B)); } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; #define sp(x) cout << setprecision(x); #define all(a) (a).begin(), (a).end() #define inf 10000000 #define linf INT64_MAX * 0.99 #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define yes "Yes" #define no "No" #define divs 1000000007 #define dive 1000000009 #define pi 3.141592653589793238 typedef pair<int, int> P; signed main() { // ios::sync_with_stdio(false); // cin.tie(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); long long A; scanf("%lld", &A); long long B; scanf("%lld", &B); long long N; scanf("%lld", &N); int ans = 0; FOR(i, N - 10000000, N + 1) { ans = max(ans, (A * i) / B - A * (i / B)); } if (B >= 10000) { int i = B - 1; while (i <= N) { ans = max(ans, (A * i) / B - A * (i / B)); i += B; } } cout << ans << endl; return 0; }
replace
31
32
31
39
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; cin >> a >> b >> c; long long maxn = -999999; for (long long i = 0; i < c / 2; i++) { long long k = (a * i) / b - a * (i / b); maxn = max(maxn, k); } for (long long i = c / 2; i <= c; i++) { long long k = (a * i) / b - a * (i / b); maxn = max(maxn, k); } cout << maxn; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, x; cin >> a >> b >> x; long long n = min(b - 1, x); cout << (a * n) / b - a * (n / b); return 0; }
replace
3
15
3
7
TLE
p02696
C++
Time Limit Exceeded
/* * author :Sadik Hassan * */ #include "bits/stdc++.h" using namespace std; #define ll long long #define nl "\n" #define pb push_back #define fi first #define se second #define PI (acos(-1.0)) #define _SAD() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define repp(i, a, n) for (int i = a; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define SZ(s) s.size() #define SRT(x, y) sort(x, x + y) #define REV(a, b) reverse(a, a + b) #define VSRT(x) sort(x.begin(), x.end()) #define VREV(x) reverse(x.begin(), x.end()) #define w(t) \ int t; \ cin >> t; \ while (t--) #define TSFL(s) transform(s.begin(), s.end(), s.begin(), ::toupper); #define TSFH(s) transform(s.begin(), s.end(), s.begin(), ::tolower); typedef vector<int> vi; typedef vector<ll> vii; typedef set<int> si; typedef set<ll> sii; const int N = 1e5 + 10; const ll xy = 1e11 + 10000000; const int INF = (int)1e9 + 5; int main() { _SAD() ll a, b, n; cin >> a >> b >> n; ll ans = 1e-18, cnt = 0; if (n > xy) { ll sap = sqrt(n); for (ll i = n - (sap + 999999999); i <= n; i++) { cnt = ((a * i) / b) - (a * (i / b)); if (cnt < ans) break; ans = max(cnt, ans); } cout << ans << nl; return 0; } for (ll i = n / 2; i <= min(n, xy); i++) { cnt = ((a * i) / b) - (a * (i / b)); ans = max(cnt, ans); } cout << ans << nl; return 0; }
/* * author :Sadik Hassan * */ #include "bits/stdc++.h" using namespace std; #define ll long long #define nl "\n" #define pb push_back #define fi first #define se second #define PI (acos(-1.0)) #define _SAD() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define repp(i, a, n) for (int i = a; i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define SZ(s) s.size() #define SRT(x, y) sort(x, x + y) #define REV(a, b) reverse(a, a + b) #define VSRT(x) sort(x.begin(), x.end()) #define VREV(x) reverse(x.begin(), x.end()) #define w(t) \ int t; \ cin >> t; \ while (t--) #define TSFL(s) transform(s.begin(), s.end(), s.begin(), ::toupper); #define TSFH(s) transform(s.begin(), s.end(), s.begin(), ::tolower); typedef vector<int> vi; typedef vector<ll> vii; typedef set<int> si; typedef set<ll> sii; const int N = 1e5 + 10; const ll xy = 1e11 + 10000000; const int INF = (int)1e9 + 5; int main() { _SAD() ll a, b, n; cin >> a >> b >> n; ll ans = min(b - 1, n); cout << ans * a / b << nl; return 0; }
replace
39
56
39
41
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1000000007; constexpr ll INF = 1ll << 60; ll A, B, N; inline ll f(ll n) { return ((A * n) / B) - A * (n / B); } int main(int argc, char **argv) { cin >> A >> B >> N; ll res{0}; for (ll i = N / 2; i <= N; ++i) { res = max(res, f(i)); } std::cout << res << std::endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1000000007; constexpr ll INF = 1ll << 60; ll A, B, N; inline ll f(ll n) { return ((A * n) / B) - A * (n / B); } int main(int argc, char **argv) { cin >> A >> B >> N; std::cout << f(min(N, B - 1)) << std::endl; }
replace
12
17
12
13
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, a, b) for (int i = a; i < b; i++) #define each(i, mp) for (auto &i : mp) int main() { long double a, b, n; cin >> a >> b >> n; ll ans = 0; ll tmp = 0; // rep(x,n+1) bool is_stop = 0; for (ll x = 0; x < n + 1; x++) { tmp = floor(a * (long double)x / b) - a * floor((long double)x / b); if (tmp >= ans) ans = tmp; if (x % (ll)b == 0) { if (is_stop) break; is_stop = 1; } // cout << x<< " " << tmp<< " " << a*(long double)x/b<<endl; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, a, b) for (int i = a; i < b; i++) #define each(i, mp) for (auto &i : mp) int main() { long double a, b, n; cin >> a >> b >> n; ll ans = 0; ll tmp = 0; // rep(x,n+1) bool is_stop = 0; // for (ll x = 0; x < n+1; x++){ // tmp = floor(a*(long double)x/b) - a*floor((long double)x/b); // if (tmp >= ans) ans = tmp; // if(x%(ll)b == 0){ // if (is_stop) break; // is_stop = 1; // } // // cout << x<< " " << tmp<< " " << a*(long double)x/b<<endl; // } if (n >= b) { ans = floor(a * (b - 1.0) / b) - a * floor((b - 1.0) / b); } else { ans = floor(a * n / b) - a * floor(n / b); } cout << ans << endl; return 0; }
replace
17
27
17
30
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { long long A, B, N, max = 0; cin >> A >> B >> N; for (long long x = N; x >= 0; x -= 1) { long long Ax = A * x; long long res = Ax / B - A * (x / B); if (res > max) max = res; } cout << max << endl; }
#include <iostream> using namespace std; int main() { long long A, B, N, max = 0; cin >> A >> B >> N; long long x = 0; if (N >= B) x = B - 1; else x = N; long long res = (A * x) / B; cout << res << endl; }
replace
5
12
5
16
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < n; i++) const ll INF = 1001001001; const double PI = 3.141592653; const ll MOD = 1000000007; // 大きい素数 // 提出のときに言語がc++似合っていることを確認する // 絶対値の関数 int z(int a, int b) { if (a > b) return a - b; else return b - a; } int main() { ll a, b, n; cin >> a >> b >> n; ll sum = 0; for (ll i = 1; i <= n; i++) { sum = max(sum, (a * i) / b - a * (i / b)); } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < n; i++) const ll INF = 1001001001; const double PI = 3.141592653; const ll MOD = 1000000007; // 大きい素数 // 提出のときに言語がc++似合っていることを確認する // 絶対値の関数 int z(int a, int b) { if (a > b) return a - b; else return b - a; } int main() { ll a, b, n; cin >> a >> b >> n; ll l = min(n, b - 1); ll sum = (a * l) / b; cout << sum << endl; return 0; }
replace
24
28
24
26
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define pb push_back #define N 200001 #define ll long long #define int ll #define pi pair<int, int> #define pip pair<pair, int> #define mp make_pair #define f first #define s second #define mod 998244353 ll Mod(ll x, ll y, int p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } int *getlps(string pattern) { int len = pattern.length(); int *lps = new int[len]; lps[0] = 0; int i = 1, j = 0; while (i < len) { if (pattern[i] == pattern[j]) { lps[i] = j + 1; i++; j++; } else { if (j != 0) { j = lps[j - 1]; } else { lps[i] = 0; i++; } } } return lps; } class Triplet { public: int x; int y; int gcd; }; Triplet extendedEuclid(int a, int b) { if (b == 0) { Triplet ans; ans.gcd = a; ans.x = 1; ans.y = 0; return ans; } Triplet smallAns = extendedEuclid(b, a % b); Triplet ans; ans.gcd = smallAns.gcd; ans.x = smallAns.y; ans.y = smallAns.x - (a / b) * smallAns.y; return ans; } int mmInverse(int a, int m) { Triplet ans = extendedEuclid(a, m); return (ans.x + m) % m; } int fact[N]; void calfac(int n) { fact[0] = 1; for (int i = 1; i <= n + 2; i++) { fact[i] = (((fact[i - 1] % mod) * (i % mod)) % mod + mod) % mod; } } int calc(int n, int r) { if (r > n) return 0; if (r == n) return 1; int ans = 1; ans = ((ans % mod) * (fact[n]) % mod + mod) % mod; ans = ((ans % mod) * (mmInverse(fact[n - r], mod) % mod) + mod) % mod; ans = ((ans % mod) * (mmInverse(fact[r], mod) % mod) + mod) % mod; return (ans + mod) % mod; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, n; cin >> a >> b >> n; int i = min(b - 1, n); // int i = n; while (i % b == 0) i--; cout << (a * i) / b - a * (i / b) << endl; //} }
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define pb push_back #define N 200001 #define ll long long #define int ll #define pi pair<int, int> #define pip pair<pair, int> #define mp make_pair #define f first #define s second #define mod 998244353 ll Mod(ll x, ll y, int p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } int *getlps(string pattern) { int len = pattern.length(); int *lps = new int[len]; lps[0] = 0; int i = 1, j = 0; while (i < len) { if (pattern[i] == pattern[j]) { lps[i] = j + 1; i++; j++; } else { if (j != 0) { j = lps[j - 1]; } else { lps[i] = 0; i++; } } } return lps; } class Triplet { public: int x; int y; int gcd; }; Triplet extendedEuclid(int a, int b) { if (b == 0) { Triplet ans; ans.gcd = a; ans.x = 1; ans.y = 0; return ans; } Triplet smallAns = extendedEuclid(b, a % b); Triplet ans; ans.gcd = smallAns.gcd; ans.x = smallAns.y; ans.y = smallAns.x - (a / b) * smallAns.y; return ans; } int mmInverse(int a, int m) { Triplet ans = extendedEuclid(a, m); return (ans.x + m) % m; } int fact[N]; void calfac(int n) { fact[0] = 1; for (int i = 1; i <= n + 2; i++) { fact[i] = (((fact[i - 1] % mod) * (i % mod)) % mod + mod) % mod; } } int calc(int n, int r) { if (r > n) return 0; if (r == n) return 1; int ans = 1; ans = ((ans % mod) * (fact[n]) % mod + mod) % mod; ans = ((ans % mod) * (mmInverse(fact[n - r], mod) % mod) + mod) % mod; ans = ((ans % mod) * (mmInverse(fact[r], mod) % mod) + mod) % mod; return (ans + mod) % mod; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, n; cin >> a >> b >> n; int i = min(b - 1, n); // int i = n; while (i % b == 0 && b != 1) i--; cout << (a * i) / b - a * (i / b) << endl; //} }
replace
100
101
100
101
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long ll; typedef pair<int, int> PII; typedef double db; const ll mod = 998244353; ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const int N = 1e5 + 50; ll s[N]; ll a[N]; int main() { ll a, b, n; cin >> a >> b >> n; if (b > n) { cout << floor((1ll) * a * n / b); } else { ll ans = 0; for (int i = b - 1; i <= n; i += b) { ans = max(ans, (ll)(floor((1ll) * a * i / b) - a * floor(i / b))); } ans = max(ans, (ll)(floor((1ll) * a * n / b) - a * floor(n / b))); cout << ans; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long ll; typedef pair<int, int> PII; typedef double db; const ll mod = 998244353; ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const int N = 1e5 + 50; ll s[N]; ll a[N]; int main() { ll a, b, n; cin >> a >> b >> n; if (b > n) { cout << floor((1ll) * a * n / b); } else { cout << floor((1ll) * a * (b - 1) / b); } return 0; }
replace
37
43
37
39
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n, mx = 0; cin >> a >> b >> n; for (int i = 1; i * b - 1 <= n; i++) { long long t = i * b - 1; mx = max(mx, (a * t / b) - a * (t / b)); } long long t = n; mx = max(mx, (a * t / b) - a * (t / b)); cout << mx << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n, mx = 0; cin >> a >> b >> n; if (b == 1) { cout << 0 << endl; return 0; } for (int i = 1; i * b - 1 <= n; i++) { long long t = i * b - 1; mx = max(mx, (a * t / b) - a * (t / b)); } long long t = n; mx = max(mx, (a * t / b) - a * (t / b)); cout << mx << endl; }
insert
7
7
7
11
TLE
p02696
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; typedef unsigned long long ull; typedef long long ll; #define big ((ll)(1e9) + 7) int main() { ll a, b, n; cin >> a >> b >> n; vector<ull> ans(n); for (ll i = 0; i < n; i++) { ans[i] = (a * (i + 1)) / b - a * ((i + 1) / b); } sort(ans.rbegin(), ans.rend()); cout << ans[0] << endl; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; typedef unsigned long long ull; typedef long long ll; #define big ((ll)(1e9) + 7) int main() { ll a, b, n; cin >> a >> b >> n; ll x = min(n, b - 1); cout << (a * (x)) / b - a * ((x) / b) << endl; }
replace
18
24
18
20
0
p02696
C++
Time Limit Exceeded
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) typedef long long INT; double PI = 3.14159265; using namespace std; using Graph = vector<vector<int>>; using Field = vector<string>; using DGraph = vector<vector<pair<int, int>>>; const long long INF = 1LL << 60; //---// int main() { INT a, b, n, ans = 0; cin >> a >> b >> n; for (int i = 0; i <= b && i <= n; i++) { ans = max(ans, (a * i) / b - (i / b) * a); } cout << ans << endl; return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) typedef long long INT; double PI = 3.14159265; using namespace std; using Graph = vector<vector<int>>; using Field = vector<string>; using DGraph = vector<vector<pair<int, int>>>; const long long INF = 1LL << 60; //---// int main() { INT a, b, n, ans = 0; cin >> a >> b >> n; if (b - 1 <= n) n = max(n % b, b - 1); else n = n % b; ans = (a * n) / b - (n / b) * a; cout << ans << endl; return 0; }
replace
16
19
16
23
TLE
p02696
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int main() { long long int a, b, n, i, max = 0, temp = 0; cin >> a >> b >> n; for (i = 1; ((i <= n) && (i <= b)); i++) { temp = floor(a * i / b) - a * floor(i / b); if (temp > max) max = temp; if (temp < max) break; } cout << max << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; int main() { long long int a, b, n, i, max = 0, temp = 0; cin >> a >> b >> n; if (b - 1 <= n) max = floor((b - 1) * a / b) - a * floor((b - 1) / b); else max = floor(n * a / b) - a * floor(n / b); cout << max << endl; return 0; }
replace
6
13
6
10
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define lld long long #define pi pair<int, int> #define pl pair<lld, lld> #define mem0(x) memset(x, 0, sizeof(x)) #define fillnum(x, n) fill(begin(x), end(x), n) #define asort(x) sort(x.begin(), x.end()) #define dsort(x, t) sort(x.begin(), x.end(), greater<t>()) int main() { lld A, B, N; cin >> A >> B >> N; lld maxv = -1; lld nowx = N / 2; while (true) { if (nowx > N) { cout << maxv << endl; exit(0); } lld left = (A * nowx / B); lld right = A * (nowx / B); // cout << left << " " << right << endl; maxv = max(maxv, left - right); nowx = min(((left + 1) * B / A) + 1, (right + 1) * B); // cout << ((left + 1) * B / A) + 1 << " " << (right + 1) * B << endl; // cout << nowx << endl; } }
#include <bits/stdc++.h> using namespace std; #define lld long long #define pi pair<int, int> #define pl pair<lld, lld> #define mem0(x) memset(x, 0, sizeof(x)) #define fillnum(x, n) fill(begin(x), end(x), n) #define asort(x) sort(x.begin(), x.end()) #define dsort(x, t) sort(x.begin(), x.end(), greater<t>()) int main() { lld A, B, N; cin >> A >> B >> N; lld maxv = -1; lld nowx = max(0LL, N - 10 * B); while (true) { if (nowx > N) { cout << maxv << endl; exit(0); } lld left = (A * nowx / B); lld right = A * (nowx / B); // cout << left << " " << right << endl; maxv = max(maxv, left - right); nowx = min(((left + 1) * B / A) + 1, (right + 1) * B); // cout << ((left + 1) * B / A) + 1 << " " << (right + 1) * B << endl; // cout << nowx << endl; } }
replace
15
16
15
16
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; using P = pair<ll, ll>; int main() { ll a, b, n; cin >> a >> b >> n; ll sum = 0, ans = 0; for (int i = 0; i <= n; i++) { sum = (a * i) / b - a * (i / b); ans = max(sum, ans); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; using P = pair<ll, ll>; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (n < b) { cout << a * n / b << endl; return 0; } else { ans = (a * n) / b - a * (n / b); ans = max(ans, ((a * b) / b - a)); ans = max(ans, ((a * (b - 1)) / b)); } cout << ans << endl; }
replace
9
13
9
17
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> int main(int argc, const char *argv[]) { long long int a, b, n, c; c = 0; std::cin >> a >> b >> n; if (b > n) { std::cout << a * n / b - a * (n / b) << std::endl; } else { for (int i = 1; i * b - 1 < n; i++) { c = i * b - 1; } std::cout << a * c / b - a * (c / b) << std::endl; } return 0; }
#include <iostream> int main(int argc, const char *argv[]) { long long int a, b, n, c; c = 0; std::cin >> a >> b >> n; if (b > n) { std::cout << a * n / b - a * (n / b) << std::endl; } else { c = (n / b) * b - 1; std::cout << a * c / b - a * (c / b) << std::endl; } return 0; }
replace
9
12
9
10
TLE
p02696
C++
Time Limit Exceeded
// #pragma GCC optimize("Ofast,unroll-all-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define all(v) v.begin(), v.end() #define len(v) ((int)(v).size()) #define pb push_back #define kek pop_back #define pii pair<int, int> #define mp make_pair #define int ll #define debug(x) cout << #x << " = " << x << endl; const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666); // const int MEM_SIZE = 1e8; // char mem[MEM_SIZE]; // int cur_mem_ptr = 0; // void* operator new(size_t n) { // cur_mem_ptr += n; // return mem + cur_mem_ptr - n; // } // void operator delete(void*) noexcept {} // void operator delete(void*, size_t) noexcept {} template <class t1, class t2> bool cmin(t1 &a, const t2 &b) { if (a > b) { a = b; return true; } return false; } template <class t1, class t2> bool cmax(t1 &a, const t2 &b) { if (a < b) { a = b; return true; } return false; } #ifndef LOCAL void UseFiles(const string &s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } #else void UseFiles(const string &) {} #endif void run(); signed main() { // UseFiles("squads"); iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0); run(); } void run() { // floor(ax / b) - a * floor(x / b) = ax - (ax % b) - a * (x - x % b) = a * // (x % b) - (ax % b) -> max ax % b < a a * (x % b) - (a * x % b) -> max a * x // % b < a int a, b, n; cin >> a >> b >> n; int x = 0; int ans = 0; while (x <= n) { cmax(ans, a * (x % b) - ((a * x) % b)); x += (b + a - 1) / a; if ((a * x) % b >= a) --x; } cout << ans / b << endl; }
// #pragma GCC optimize("Ofast,unroll-all-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define all(v) v.begin(), v.end() #define len(v) ((int)(v).size()) #define pb push_back #define kek pop_back #define pii pair<int, int> #define mp make_pair #define int ll #define debug(x) cout << #x << " = " << x << endl; const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666); // const int MEM_SIZE = 1e8; // char mem[MEM_SIZE]; // int cur_mem_ptr = 0; // void* operator new(size_t n) { // cur_mem_ptr += n; // return mem + cur_mem_ptr - n; // } // void operator delete(void*) noexcept {} // void operator delete(void*, size_t) noexcept {} template <class t1, class t2> bool cmin(t1 &a, const t2 &b) { if (a > b) { a = b; return true; } return false; } template <class t1, class t2> bool cmax(t1 &a, const t2 &b) { if (a < b) { a = b; return true; } return false; } #ifndef LOCAL void UseFiles(const string &s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } #else void UseFiles(const string &) {} #endif void run(); signed main() { // UseFiles("squads"); iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0); run(); } void run() { // floor(ax / b) - a * floor(x / b) = ax - (ax % b) - a * (x - x % b) = a * // (x % b) - (ax % b) -> max ax % b < a a * (x % b) - (a * x % b) -> max a * x // % b < a int a, b, n; cin >> a >> b >> n; int x = 0; int ans = 0; while (x <= min(n, b)) { cmax(ans, a * (x % b) - ((a * x) % b)); x += (b + a - 1) / a; if ((a * x) % b >= a) --x; } cout << ans / b << endl; }
replace
77
78
77
78
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; for (ll i = 1; i <= min(n, b); i++) { ll tmp = (a * i) / b - a * (i / b); ans = max(ans, tmp); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; cout << a * min(b - 1, n) / b << endl; return 0; }
replace
7
13
7
8
TLE
p02696
C++
Time Limit Exceeded
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define INF 1 << 30 const ll mod = 1000000007; int main() { ll A, B, N, x = 1, M = 0, c = 1; scanf("%lld%lld%lld", &A, &B, &N); if (B == 1) { puts("0"); return 0; } if (N < 100000) { while (x <= N) { M = max(M, A * x / B - A * (x / B)); x++; } } else { c = max((N - 10000000) / B, 0ll); while ((x = B * c - 1) <= N) { M = max(M, A * x / B - A * (x / B)); c++; } x -= B; while (x <= N) { M = max(M, A * x / B - A * (x / B)); x++; } } printf("%lld\n", M); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define INF 1 << 30 const ll mod = 1000000007; int main() { ll A, B, N, x = 1, M = 0, c = 1; scanf("%lld%lld%lld", &A, &B, &N); if (B == 1) { puts("0"); return 0; } if (N < 100000) { while (x <= N) { M = max(M, A * x / B - A * (x / B)); x++; } } else { c = max((N - 10000000) / B, 0ll); while ((x = B * c - 1) <= N) { M = max(M, A * x / B - A * (x / B)); c++; } x = max(N - 100000, 0ll); while (x <= N) { M = max(M, A * x / B - A * (x / B)); x++; } } printf("%lld\n", M); return 0; }
replace
45
46
45
46
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int64_t a, b, n; cin >> a >> b >> n; int64_t x, maxi = 0; for (x = 0; x <= n; x++) { int64_t p = x / b; int64_t ans = a * x / b - a * p; maxi = max(ans, maxi); } cout << maxi; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t a, b, n; cin >> a >> b >> n; int64_t x, maxi = 0; int64_t p = min(b - 1, n); int64_t q = p / b; int64_t ans = a * p / b - a * q; cout << ans; }
replace
6
12
6
10
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 rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()); typedef long long ll; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; rep(i, min(b, n + 1)) { ans = max(ans, (i * a / b) - a * (i / b)); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()); typedef long long ll; int main() { ll a, b, n; cin >> a >> b >> n; ll ans = 0; if (n >= b) { cout << ((b - 1) * a / b) - a * ((b - 1) / b); } if (n < b) { cout << n * a / b - a * (n / b); } }
replace
12
14
12
18
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const long INF = 1L << 60; int main() { long a, b, n; scanf("%ld%ld%ld", &a, &b, &n); long ans = -INF; for (int i = n / 2; i <= n; i++) ans = max(ans, (long)(floor(a * i / b) - a * floor(i / b))); printf("%ld\n", ans); }
#include <bits/stdc++.h> using namespace std; const long INF = 1L << 60; int main() { long a, b, n; scanf("%ld%ld%ld", &a, &b, &n); if (b - 1 >= n) printf("%ld\n", (long)(floor(a * n / b) - a * floor(n / b))); else printf("%ld\n", (long)(floor(a * (b - 1) / b) - a * floor((b - 1) / b))); }
replace
8
12
8
12
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { long long A; long long B, N; cin >> A >> B >> N; long long max = 0; for (long long x = 0; x <= B && x <= N; x++) { long long p = (A * x) / B - A * (x / B); if (p > max) { max = p; } } cout << max << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { long long A; long long B, N; cin >> A >> B >> N; long long max = 0; if (N < B) { max = (A * N) / B - A * (N / B); } else { max = (A * (B - 1)) / B - A * ((B - 1) / B); } cout << max << endl; }
replace
12
17
12
16
TLE
p02696
C++
Time Limit Exceeded
/** * Created by hiramekun at 20:54 on 2020-05-02. */ #include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using P = pair<ll, ll>; template <typename T> using pq = priority_queue<T>; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template <typename T, typename K> using ump = unordered_map<T, K>; const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ll mod = 1000000007; const ll inf = ll(1e9); const ll e5 = ll(1e5); const ll ll_inf = ll(1e9) * ll(1e9); #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--) #define each(i, mp) for (auto &i : mp) #define eb emplace_back #define F first #define S second #define all(obj) (obj).begin(), (obj).end() template <class T> ostream &operator<<(ostream &out, const vector<T> &list) { ll n = list.size(); rep(i, n) out << list[i] << ' '; return out; } template <class T> istream &operator>>(istream &in, vector<T> &list) { ll n = list.size(); rep(i, n) in >> list[i]; return in; } template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) { ll n = list.size(); rep(i, n) out << list[i] << '\n'; return out; } /* ------------- ANSWER ------------- */ /* ---------------------------------- */ void solve() { ll a, b, n; cin >> a >> b >> n; ll ans = -1; for (ll i = 1; i <= n; ++i) { ans = max(ans, (a * i) / b - a * (i / b)); } cout << ans << '\n'; } int main() { #ifdef MY_DEBUG while (true) { #endif solve(); #ifdef MY_DEBUG } #endif return 0; }
/** * Created by hiramekun at 20:54 on 2020-05-02. */ #include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using P = pair<ll, ll>; template <typename T> using pq = priority_queue<T>; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template <typename T, typename K> using ump = unordered_map<T, K>; const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ll mod = 1000000007; const ll inf = ll(1e9); const ll e5 = ll(1e5); const ll ll_inf = ll(1e9) * ll(1e9); #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--) #define each(i, mp) for (auto &i : mp) #define eb emplace_back #define F first #define S second #define all(obj) (obj).begin(), (obj).end() template <class T> ostream &operator<<(ostream &out, const vector<T> &list) { ll n = list.size(); rep(i, n) out << list[i] << ' '; return out; } template <class T> istream &operator>>(istream &in, vector<T> &list) { ll n = list.size(); rep(i, n) in >> list[i]; return in; } template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) { ll n = list.size(); rep(i, n) out << list[i] << '\n'; return out; } /* ------------- ANSWER ------------- */ /* ---------------------------------- */ void solve() { ll a, b, n; cin >> a >> b >> n; if (n >= b - 1) cout << (a * (b - 1)) / b << '\n'; else cout << a * (n) / b - a * (n / b) << '\n'; } int main() { #ifdef MY_DEBUG while (true) { #endif solve(); #ifdef MY_DEBUG } #endif return 0; }
replace
54
59
54
58
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; // D - Floor Function int main() { long long A, B, N; cin >> A >> B >> N; long long result = -1; for (int x = 0; x <= N; x++) { long long tmp = floor(A * x / B) - A * floor(x / B); if (result > 0 && tmp == 0) break; result = max(result, tmp); } cout << result; }
#include <bits/stdc++.h> using namespace std; // D - Floor Function int main() { long long A, B, N; cin >> A >> B >> N; long long x = B - 1; x = min(x, N); long long result = floor(A * x / B) - A * floor(x / B); cout << result; }
replace
8
15
8
11
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, a, b) for (ll i = a; (i) < (b); ++(i)) #define RFOR(i, a, b) for (ll i = a; (i) >= (b); --(i)) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define UNIQ(v) \ sort(ALL(v)); \ v.erase(unique(ALL(v)), v.end()) #define BIT(n) (1LL << (n)) #define DEBUG(a) cerr << #a << " = " << a << endl const int inf = 1001001001; const int mod = (int)1e9 + 7; // const ll inf = 1e15; // const ll mod = 1e9+7; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int main() { ll A, B, N; cin >> A >> B >> N; // int mx = 0; // if (N < B) { // mx = floor(A*N/B) - A*floor(N/B); // } else { // REP(i, B) { // int diff = floor(A*i/B) - A*floor(i/B); // mx = max(mx, diff); // } // } ll mx = 0; for (ll i = 0; i < B && i <= N; ++i) { ll diff = A * i / B - A * (i / B); mx = max(mx, diff); } cout << mx << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, a, b) for (ll i = a; (i) < (b); ++(i)) #define RFOR(i, a, b) for (ll i = a; (i) >= (b); --(i)) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define UNIQ(v) \ sort(ALL(v)); \ v.erase(unique(ALL(v)), v.end()) #define BIT(n) (1LL << (n)) #define DEBUG(a) cerr << #a << " = " << a << endl const int inf = 1001001001; const int mod = (int)1e9 + 7; // const ll inf = 1e15; // const ll mod = 1e9+7; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int main() { ll A, B, N; cin >> A >> B >> N; // int mx = 0; // if (N < B) { // mx = floor(A*N/B) - A*floor(N/B); // } else { // REP(i, B) { // int diff = floor(A*i/B) - A*floor(i/B); // mx = max(mx, diff); // } // } ll x = min(B - 1, N); ll diff = A * x / B - A * (x / B); cout << diff << endl; }
replace
37
43
37
40
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll a, b, n; cin >> a >> b >> n; if (n < b) { cout << (a * n) / b << endl; } else { ll ans = 0; ll x = b - 1; while (x < n) { ll temp = (a * x) / b - a * (x / b); if (temp > ans) ans = temp; x += b; } cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll a, b, n; cin >> a >> b >> n; ll x = (n / b) * b - 1; if (x == -1) cout << (a * n) / b; else cout << (a * x) / b - a * (x / b); }
replace
8
21
8
13
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #include <cstdlib> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans; ans = 0; for (int i = 0; i <= n; i++) { long long f; f = a * i / b - a * (i / b); ans = max(ans, f); } cout << ans << endl; }
#include <algorithm> #include <bits/stdc++.h> #include <cstdlib> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans; ans = 0; if (n >= b) { ans = (b - 1) * a / b; } else { ans = n * a / b; } cout << ans << endl; }
replace
16
20
16
20
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define fo(i, a, b) for (int i = a; i < b; ++i) #define rep(i, n) fo(i, 0, n) #define pln(n) printf("%lld", n) #define sll(n) scanf("%lld", &n) #define ss(n) scanf("%s", n) #define vi vector<int> #define ll long long #define pii pair<ll, ll> #define pb push_back #define mp make_pair #define ull unsigned long long #define INF 0x3f3f3f3f #define dbg(x) \ { cout << #x << ": " << (x) << endl; } #define dbg2(x, y) \ { cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; } #define dbg3(x, y, z) \ { \ cout << #x << ": " << (x) << " , " << #y << ": " << (y) << " , " << #z \ << ": " << (z) << endl; \ } #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define vll vector<long long> #define vvll vector<vector<long long>> #define vvvll vector<vector<vector<ll>>> #define si set<int> #define tr(c, it) for (decltype(c.begin()) it = c.begin(); it != c.end(); it++) #define pis pair<int, string> #define present(c, x) (c.find(x) != c.end()) #define cpresent(c, x) (find(all(c), x) != c.end()) #define ones(x) __builtin_popcount(x) using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll x = 0; ll ans = 0; while (x <= n) { ll f = floor(a * x / b) - (ll)a * floor(x / b); ans = max(ans, f); x++; } cout << ans; }
#include <bits/stdc++.h> #define fo(i, a, b) for (int i = a; i < b; ++i) #define rep(i, n) fo(i, 0, n) #define pln(n) printf("%lld", n) #define sll(n) scanf("%lld", &n) #define ss(n) scanf("%s", n) #define vi vector<int> #define ll long long #define pii pair<ll, ll> #define pb push_back #define mp make_pair #define ull unsigned long long #define INF 0x3f3f3f3f #define dbg(x) \ { cout << #x << ": " << (x) << endl; } #define dbg2(x, y) \ { cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; } #define dbg3(x, y, z) \ { \ cout << #x << ": " << (x) << " , " << #y << ": " << (y) << " , " << #z \ << ": " << (z) << endl; \ } #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define vll vector<long long> #define vvll vector<vector<long long>> #define vvvll vector<vector<vector<ll>>> #define si set<int> #define tr(c, it) for (decltype(c.begin()) it = c.begin(); it != c.end(); it++) #define pis pair<int, string> #define present(c, x) (c.find(x) != c.end()) #define cpresent(c, x) (find(all(c), x) != c.end()) #define ones(x) __builtin_popcount(x) using namespace std; int main() { ll a, b, n; cin >> a >> b >> n; ll f = floor(a * (min(b - 1, n)) / b) - (ll)a * floor((min(b - 1, n)) / b); cout << f; }
replace
38
46
38
40
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <vector> using namespace std; void C(void) { long long n, m, q; long long i, j, k; long long temp_a, temp_b, temp_c, temp_d; vector<long long> a, b, c, d; cin >> n >> m >> q; for (i = 0; i < q; i++) { cin >> temp_a, temp_b, temp_c, temp_d; a.push_back(temp_a); b.push_back(temp_b); c.push_back(temp_c); d.push_back(temp_d); } } int main(void) { long long n, m, q; long long i, j, k; long long a, b; long long max = 0; cin >> a >> b >> n; for (i = 0; i <= n; i++) { m = floor((a * i) / double(b)) - a * floor(i / double(b)); if (max < m) { max = m; } } cout << max << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <vector> using namespace std; void C(void) { long long n, m, q; long long i, j, k; long long temp_a, temp_b, temp_c, temp_d; vector<long long> a, b, c, d; cin >> n >> m >> q; for (i = 0; i < q; i++) { cin >> temp_a, temp_b, temp_c, temp_d; a.push_back(temp_a); b.push_back(temp_b); c.push_back(temp_c); d.push_back(temp_d); } } int main(void) { long long n, m, q; long long i, j, k; long long a, b; long long max = 0; cin >> a >> b >> n; if (b > n) { max = floor((a * n) / double(b)) - a * floor(n / double(b)); } else { max = floor((a * (b - 1)) / double(b)) - a * floor((b - 1) / double(b)); } cout << max << endl; return 0; }
replace
34
39
34
38
TLE
p02696
Python
Time Limit Exceeded
#!/usr/bin/env python3 def main(): import sys input = sys.stdin.readline A, B, N = map(int, input().split()) ans = 0 for x in range(N + 1): res = int((A * x) // B) - A * int(x // B) ans = max(ans, res) print(ans) if __name__ == "__main__": main()
#!/usr/bin/env python3 def main(): import sys input = sys.stdin.readline A, B, N = map(int, input().split()) x = min(B - 1, N) print((A * x) // B - A * (x // B)) if __name__ == "__main__": main()
replace
8
13
8
10
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { long long a, b, n; long long ma = 0; cin >> a >> b >> n; for (long long j = n; j >= n - 100000000; j--) { if (j < 0) { break; } if (ma < (a * j) / b - a * (j / b)) { ma = (a * j) / b - a * (j / b); } } for (long long j = 0; j < 100000000; j++) { if (j > n) { break; } if (ma < (a * j) / b - a * (j / b)) { ma = (a * j) / b - a * (j / b); } } if (ma < (a * (n / 2)) / b - a * ((n / 2) / b)) { ma = (a * (n / 2)) / b - a * ((n / 2) / b); } cout << ma << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { long long a, b, x; cin >> a >> b >> x; long long n = min(b - 1, x); cout << (a * n) / b - a * (n / b) << endl; return 0; }
replace
17
40
17
21
TLE
p02696
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; long A, B, N; long f(double x) { return floor((A * x) / B) - A * floor(x / B); } int main() { cin >> A >> B >> N; long cnt = N > B ? B : N; long max = -100; for (long x = 1; x <= cnt; x++) { long now = f((double)x); max = max > now ? max : now; } cout << max << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; long A, B, N; long f(double x) { return floor((A * x) / B) - A * floor(x / B); } int main() { cin >> A >> B >> N; long min = N > B - 1 ? B - 1 : N; cout << f(min) << endl; return 0; }
replace
10
17
10
12
TLE
p02696
C++
Time Limit Exceeded
#include <climits> #include <cmath> #include <iostream> typedef long long ll; using namespace std; int main() { ll a; cin >> a; ll b; cin >> b; ll n; cin >> n; ll k = min(b, n); ll answer = INT_MIN; for (ll i = k; a * i >= b; i--) { ll medi = floor((a * i) / b) - a * (floor(i / b)); answer = max(answer, medi); } cout << answer; }
#include <climits> #include <cmath> #include <iostream> typedef long long ll; using namespace std; int main() { ll a; cin >> a; ll b; cin >> b; ll n; cin >> n; ll k = min(b - 1, n); ll medi = floor((a * k) / b) - a * (floor(k / b)); cout << medi; }
replace
12
19
12
16
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <iomanip> using namespace std; #define reps(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) reps(i, 0, n) #define Rreps(i, n, e) for (int i = n - 1; i >= e; --i) #define Rrep(i, n) Rreps(i, n, 0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector<ll> vec; typedef vector<vec> mat; ll N, M, H, W, Q, K, A, B; string S; const ll MOD = 998244353; // const ll MOD = (1e+9) + 7; typedef pair<ll, ll> P; const ll INF = (1LL << 50); template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } else return false; } template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } else return false; } int main() { cin >> A >> B >> N; ll x = min(N, B - 1); if (x == N) { cout << (A * x) / B - A * (x / B) << endl; return 0; } ll ans = (A * x) / B - A * (x / B); while (x <= N && (A * x) % B == (A * (B - 1)) % B) { chmax(ans, (A * x) / B - A * (x / B)); x += B; } cout << ans << endl; }
#include <bits/stdc++.h> #include <iomanip> using namespace std; #define reps(i, s, n) for (int i = s; i < n; i++) #define rep(i, n) reps(i, 0, n) #define Rreps(i, n, e) for (int i = n - 1; i >= e; --i) #define Rrep(i, n) Rreps(i, n, 0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector<ll> vec; typedef vector<vec> mat; ll N, M, H, W, Q, K, A, B; string S; const ll MOD = 998244353; // const ll MOD = (1e+9) + 7; typedef pair<ll, ll> P; const ll INF = (1LL << 50); template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } else return false; } template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } else return false; } int main() { cin >> A >> B >> N; ll x = min(N, B - 1); if (x == N) { cout << (A * x) / B - A * (x / B) << endl; return 0; } ll ans = (A * x) / B - A * (x / B); x += B; while (x <= N && (A * x) % B != (A * (B - 1)) % B) { chmax(ans, (A * x) / B - A * (x / B)); x += B; } cout << ans << endl; }
replace
43
44
43
45
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; long long A, B, M, x, maxim = -1; int main() { cin >> A >> B >> M; if (M < B) { x = M; cout << A * x / B << '\n'; } else { x = B - 1; while (x < M) { maxim = max(A * x / B - A * (x / B), maxim); x += B; } x = M; maxim = max(A * x / B - A * (x / B), maxim); cout << maxim << '\n'; } }
#include <bits/stdc++.h> using namespace std; long long A, B, M, x, maxim = -1; int main() { cin >> A >> B >> M; if (M < B) { x = M; cout << A * x / B << '\n'; } else { x = B - 1; maxim = max(A * x / B - A * (x / B), maxim); long long coe = ((M + 1) / B) - 1; x = coe * B - 1; maxim = max(A * x / B - A * (x / B), maxim); x = M; maxim = max(A * x / B - A * (x / B), maxim); cout << maxim << '\n'; } }
replace
10
14
10
14
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int MOD = 1000000007; const ll INF = 1LL << 60; int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n; cin >> a >> b >> n; ll m = -1; for (int i = 1; i <= n; i++) { if (i > b) { cout << m << endl; return 0; } ll num = (a * i) / b - a * (i / b); m = max(m, num); } cout << m << endl; }
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int MOD = 1000000007; const ll INF = 1LL << 60; int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n; cin >> a >> b >> n; ll flag = min(b - 1, n); ll i = flag; ll num = (a * i) / b - a * (i / b); cout << num << endl; }
replace
12
22
12
16
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define int long long int using namespace std; signed main() { int a, b, n; cin >> a >> b >> n; int maxi = INT_MIN; for (int x = 1; x <= n; x++) { int t = floor((a * x) / b) - a * floor(x / b); maxi = max(t, maxi); } cout << maxi; }
#include <bits/stdc++.h> #define int long long int using namespace std; signed main() { int a, b, n; cin >> a >> b >> n; int x = min(b - 1, n); cout << floor((a * x) / b) - a * floor(x / b); return 0; }
replace
6
13
6
9
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int main() { ll n, a, b; cin >> a >> b >> n; ll ans = 0; for (ll i = 0; i <= n; i++) { ans = max(ans, ((a * i) / b) - a * (i / b)); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int main() { ll n, a, b; cin >> a >> b >> n; cout << (a * min(n, (b - 1))) / b; return 0; }
replace
9
14
9
10
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; int main() { int64_t A, B, N; cin >> A >> B >> N; int64_t max_xB = 0; // A(x%B)のmax for (int i = 0; i < N; i++) { int x = i + 1; max_xB = max(max_xB, x % B); } printf("%ld\n", (-A * max_xB % B + A * max_xB) / B); return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; int main() { int64_t A, B, N; cin >> A >> B >> N; int64_t x = 0; if (N < B - 1) x = N; else x = B - 1; printf("%ld\n", (-A * (x % B) % B + A * (x % B)) / B); return 0; }
replace
8
15
8
14
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define f(i, a, b) for (int i = a; i <= b; i++) inline ll read() { int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } #define d read() ll a, b, n; ll mx, num; int main() { // while(1){ // mx=num=0; // a=d,b=d,n=d; // //if(a>b)swap(a,b); // f(i,1,n){ // ll //k=floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b); // if(k>mx)mx=k; // } // f(i,1,n) // if(floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b)==mx)cout<<i<<" //"; cout<<endl; // } scanf("%lld%lld%lld", &a, &b, &n); if (a >= b) { f(i, 1, n) { ll x = a * i / b - a * (i / b); if (x > mx) mx = x; } cout << mx; return 0; } if (b - b / a <= n) { cout << a * (b - b / a) / b - a * ((b - b / a) / b); return 0; } cout << a * n / b - a * (n / b); return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define f(i, a, b) for (int i = a; i <= b; i++) inline ll read() { int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } #define d read() ll a, b, n; ll mx, num; int main() { // while(1){ // mx=num=0; // a=d,b=d,n=d; // //if(a>b)swap(a,b); // f(i,1,n){ // ll //k=floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b); // if(k>mx)mx=k; // } // f(i,1,n) // if(floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b)==mx)cout<<i<<" //"; cout<<endl; // } scanf("%lld%lld%lld", &a, &b, &n); if (a >= b) { if (b - 1 <= n) cout << a * (b - 1) / b - a * ((b - 1) / b); else cout << a * n / b - a * (n / b); return 0; } if (b - b / a <= n) { cout << a * (b - b / a) / b - a * ((b - b / a) / b); return 0; } cout << a * n / b - a * (n / b); return 0; }
replace
46
52
46
50
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> //Carefully Crafted by hetp111 using namespace std; #define int long long #define double long double #define all(v) (v).begin(), (v).end() #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vii vector<pii> #define MOD (1000000007) #define MOD2 (998244353) #define MOD3 (1000000009) #define PI acos(-1) #define eps (1e-8) #define INF (1e18) #define FASTER \ ios_base::sync_with_stdio(0); \ cin.tie(0) template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &a) { return out << "(" << a.first << "," << a.second << ")"; } template <class A> ostream &operator<<(ostream &out, const vector<A> &a) { for (const A &it : a) out << it << " "; return out; } template <class A, class B> istream &operator>>(istream &in, pair<A, B> &a) { return in >> a.first >> a.second; } template <class A> istream &operator>>(istream &in, vector<A> &a) { for (A &i : a) in >> i; return in; } ifstream cinn("input.txt"); ofstream coutt("output.txt"); int a, b, n; int ff(int x) { return (a * x) / b - a * (x / b); } int f(int l, int r) { if (l > r) return 0; if (l / b == r / b) { return ff(r); } int mid = (l + r) / 2; return max(f(l, mid), f(mid + 1, r)); } signed main() { FASTER; cin >> a >> b >> n; cout << f(0, n); }
#include <bits/stdc++.h> //Carefully Crafted by hetp111 using namespace std; #define int long long #define double long double #define all(v) (v).begin(), (v).end() #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vii vector<pii> #define MOD (1000000007) #define MOD2 (998244353) #define MOD3 (1000000009) #define PI acos(-1) #define eps (1e-8) #define INF (1e18) #define FASTER \ ios_base::sync_with_stdio(0); \ cin.tie(0) template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &a) { return out << "(" << a.first << "," << a.second << ")"; } template <class A> ostream &operator<<(ostream &out, const vector<A> &a) { for (const A &it : a) out << it << " "; return out; } template <class A, class B> istream &operator>>(istream &in, pair<A, B> &a) { return in >> a.first >> a.second; } template <class A> istream &operator>>(istream &in, vector<A> &a) { for (A &i : a) in >> i; return in; } ifstream cinn("input.txt"); ofstream coutt("output.txt"); int a, b, n; int ff(int x) { return (a * x) / b - a * (x / b); } int f(int l, int r) { if (l > r) return 0; if (l / b == r / b) { return ff(r); } int mid = (l + r) / 2; return max(f(l, mid), f(mid + 1, r)); } signed main() { FASTER; cin >> a >> b >> n; n = min(b, n); cout << f(0, n); }
insert
55
55
55
56
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; long long MOD = 1000000007LL; const double PI = 3.14159265358979323846; #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define endl "\n" int main() { long long A, B, N; cin >> A >> B >> N; long long ans = 0; for (long long i = N; 0 <= i; --i) { long long buf = (floor(A * i / B) - A * floor(i / B)); ans = max(ans, buf); } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; long long MOD = 1000000007LL; const double PI = 3.14159265358979323846; #undef INT_MIN #undef INT_MAX #define INT_MIN -2147483648 #define INT_MAX 2147483647 #define endl "\n" int main() { long long A, B, N; cin >> A >> B >> N; long long ans = 0; long long x = min(N, B - 1); ans = floor((A * x) / B); cout << ans << endl; return 0; }
replace
25
29
25
27
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define ALL(n) begin(n), end(n) using namespace std; using ll = long long; int main() { ll a; ll b, n; cin >> a >> b >> n; ll ans = 0; rep(i, n + 1) { ll tmp; tmp = floor((double)(a * i) / b) - a * floor((double)i / b); ans = max(ans, tmp); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define ALL(n) begin(n), end(n) using namespace std; using ll = long long; int main() { ll a; ll b, n; cin >> a >> b >> n; ll ans = floor((double)(a * min(b - 1, n)) / b) - a * floor((double)min(b - 1, n) / b); cout << ans << endl; return 0; }
replace
11
17
11
13
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; int ans = 0; for (double x = 1; x <= n; x++) { int g = ans; ans = floor(a * x / b) - a * floor(x / b); ans = max(ans, g); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, n; cin >> a >> b >> n; long long ans = 0, x = n; if (n >= b - 1) x = b - 1; ans = floor(a * x / b) - a * floor(x / b); cout << ans << endl; }
replace
7
13
7
12
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long int #define mod 1000000007 #define se second #define fi first #define endl "\n" #define pi 3.1415926535897932384626433832795028841971 #define MAX 9223372036854775807 using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // cout<<fixed<<setprecision(10); ll a, b, n; cin >> a >> b >> n; ll x, y, z; x = min(b - 1, n); ll ans = 0; ll ans1; while (x <= n) { ans1 = ((a * x) / b) - a * (x / b); ans = max(ans, ans1); x += 1; x += b; x -= 1; } cout << ans; return 0; }
#include <bits/stdc++.h> #define ll long long int #define mod 1000000007 #define se second #define fi first #define endl "\n" #define pi 3.1415926535897932384626433832795028841971 #define MAX 9223372036854775807 using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // cout<<fixed<<setprecision(10); ll a, b, n; cin >> a >> b >> n; ll m = (n / b) * b - 1; ll ans1 = ((a * m) / b) - a * (m / b); ll ans = ((a * n) / b) - a * (n / b); cout << max(ans, ans1); return 0; }
replace
16
28
16
20
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(var, begin, end) for (int var = (begin); var <= (end); var++) #define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--) #define REP(var, length) FOR(var, 0, length - 1) #define RREP(var, length) RFOR(var, length - 1, 0) #define EACH(value, var) for (auto value : var) #define SORT(var) sort(var.begin(), var.end()) #define REVERSE(var) reverse(var.begin(), var.end()) #define RSORT(var) \ SORT(var); \ REVERSE(var) #define OPTIMIZE_STDIO \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.precision(10); \ cout << fixed #define endl '\n' const int INF = 1e9; const ll MOD = 1e9 + 7; const ll LINF = 1e18; struct mint { ll x; mint() : x(0) {} mint(ll x) : x((x % MOD + MOD) % MOD) {} mint &operator+=(const mint &r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; } mint &operator-=(const mint &r) { if ((x -= r.x) < 0) { x += MOD; } return *this; } mint &operator*=(const mint &r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; } mint &operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; } mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x -= MOD; } return ret; } mint &operator--() { if ((--x) < 0) { x += MOD; } return *this; } mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; } mint operator+(const mint &r) { mint ret; return ret = x + r.x; } mint operator-(const mint &r) { mint ret; return ret = x - r.x; } mint operator*(const mint &r) { mint ret; return ret = x * r.x; } mint operator-() { return mint() - *this; } bool operator<(const mint &a) { return x < a.x; } bool operator>(const mint &a) { return x > a.x; } bool operator<=(const mint &a) { return x <= a.x; } bool operator>=(const mint &a) { return x >= a.x; } bool operator==(const mint &a) { return x == a.x; } bool operator!=(const mint &a) { return x != a.x; } }; ostream &operator<<(ostream &os, const mint &r) { os << r.x; return os; } ostream &operator>>(ostream &os, const mint &r) { os >> r.x; return os; } ll a, b, n; ll ans; void solve(istream &cin, ostream &cout) { cin >> a >> b >> n; ll r = min(b - 1, n); ll ans = -LINF; for (ll i = 0; i <= r; i++) { ll tmp = floor(a * i / b) - a * floor(i / b); ans = max(ans, tmp); } cout << ans << endl; } #ifndef TEST int main() { OPTIMIZE_STDIO; solve(cin, cout); return 0; } #endif
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(var, begin, end) for (int var = (begin); var <= (end); var++) #define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--) #define REP(var, length) FOR(var, 0, length - 1) #define RREP(var, length) RFOR(var, length - 1, 0) #define EACH(value, var) for (auto value : var) #define SORT(var) sort(var.begin(), var.end()) #define REVERSE(var) reverse(var.begin(), var.end()) #define RSORT(var) \ SORT(var); \ REVERSE(var) #define OPTIMIZE_STDIO \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.precision(10); \ cout << fixed #define endl '\n' const int INF = 1e9; const ll MOD = 1e9 + 7; const ll LINF = 1e18; struct mint { ll x; mint() : x(0) {} mint(ll x) : x((x % MOD + MOD) % MOD) {} mint &operator+=(const mint &r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; } mint &operator-=(const mint &r) { if ((x -= r.x) < 0) { x += MOD; } return *this; } mint &operator*=(const mint &r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; } mint &operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; } mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x -= MOD; } return ret; } mint &operator--() { if ((--x) < 0) { x += MOD; } return *this; } mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; } mint operator+(const mint &r) { mint ret; return ret = x + r.x; } mint operator-(const mint &r) { mint ret; return ret = x - r.x; } mint operator*(const mint &r) { mint ret; return ret = x * r.x; } mint operator-() { return mint() - *this; } bool operator<(const mint &a) { return x < a.x; } bool operator>(const mint &a) { return x > a.x; } bool operator<=(const mint &a) { return x <= a.x; } bool operator>=(const mint &a) { return x >= a.x; } bool operator==(const mint &a) { return x == a.x; } bool operator!=(const mint &a) { return x != a.x; } }; ostream &operator<<(ostream &os, const mint &r) { os << r.x; return os; } ostream &operator>>(ostream &os, const mint &r) { os >> r.x; return os; } ll a, b, n; ll ans; void solve(istream &cin, ostream &cout) { cin >> a >> b >> n; ll r = min(b - 1, n); ll ans = floor(a * r / b) - a * floor(r / b); cout << ans << endl; } #ifndef TEST int main() { OPTIMIZE_STDIO; solve(cin, cout); return 0; } #endif
replace
106
111
106
107
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; // xはBの倍数-1だけ試す long long x = B - 1; int i = 1; int ans = 0; if (B > N) { ans = (A * N) / B - A * (x / B); cout << ans << endl; return 0; } while (x <= N) { int TRY; TRY = (A * x) / B - A * (x / B); ans = max(ans, TRY); i++; x = B * i - 1; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, N; cin >> A >> B >> N; if (B == 1) { // B = 1の時は計算しない cout << 0 << endl; return 0; } // xはBの倍数-1だけ試す long long x = B - 1; int i = 1; int ans = 0; if (B > N) { ans = (A * N) / B - A * (x / B); cout << ans << endl; return 0; } while (x <= N) { int TRY; TRY = (A * x) / B - A * (x / B); ans = max(ans, TRY); i++; x = B * i - 1; } cout << ans << endl; return 0; }
insert
6
6
6
11
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; const int mod = 1e9 + 7; int main() { long long a, b, n; cin >> a >> b >> n; long long x = 0; long long ans = 0; if (b > n) { x = n; ans = a * x / b; } else { double M = 0; for (int i = 1; i < b; i++) { double num = (double)i / (double)b; if (M < num) { M = num; x = i; } } ans = (int)((double)a * M); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; const int mod = 1e9 + 7; int main() { long long a, b, n; cin >> a >> b >> n; long long x = 0; long long ans = 0; if (b > n) { x = n; ans = a * x / b; } else { ans = (int)((double)a * (double)(b - 1) / (double)b); } cout << ans << endl; return 0; }
replace
16
25
16
18
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; #define vll vector<ll> #define FOR(i, b, e) for (int i = (b); i < (e); ++i) #define REP(i, e) FOR(i, 0, e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define REV(v) reverse((v).begin(), (v).end()) #define IN(v) cin >> (v); #define VIN(v, n) REP(i, n) cin >> v[i]; #define OUT(v) cout << (v) << endl; #define YN(b) OUT((b) ? "YES" : "NO") #define Yn(b) OUT((b) ? "Yes" : "No") #define yn(b) OUT((b) ? "yes" : "no") const ll MOD = 1000000007; ll f(ll a, ll b, ll x) { return floor(a * x / (double)b) - a * floor(x / (double)b); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n, mv = 0, v; cin >> a >> b >> n; REP(i, min(b, n) + 1) { v = f(a, b, i); mv = max(v, mv); if (mv != 0 && v == 0) break; } cout << mv << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; #define vll vector<ll> #define FOR(i, b, e) for (int i = (b); i < (e); ++i) #define REP(i, e) FOR(i, 0, e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define REV(v) reverse((v).begin(), (v).end()) #define IN(v) cin >> (v); #define VIN(v, n) REP(i, n) cin >> v[i]; #define OUT(v) cout << (v) << endl; #define YN(b) OUT((b) ? "YES" : "NO") #define Yn(b) OUT((b) ? "Yes" : "No") #define yn(b) OUT((b) ? "yes" : "no") const ll MOD = 1000000007; ll f(ll a, ll b, ll x) { return floor(a * x / (double)b) - a * floor(x / (double)b); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, n, mv = 0, v; cin >> a >> b >> n; if (b <= n) cout << f(a, b, b - 1) << endl; else cout << f(a, b, n) << endl; return 0; }
replace
32
40
32
36
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; typedef long long ll; const int MOD = 1e9 + 7; int main() { ll a, b, n; cin >> a >> b >> n; ll maxi = INT_MIN; int j = 1; if (j > 100000000) j = 100000000; for (ll i = j; i <= n; i++) { maxi = max(maxi, ((a * i) / b) - a * (i / b)); } cout << maxi << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; typedef long long ll; const int MOD = 1e9 + 7; int main() { ll a, b, n; cin >> a >> b >> n; // ll maxi=INT_MIN; ll ans; if (b <= n) ans = (a * (b - 1)) / b; else ans = (a * n) / b; cout << ans << endl; return 0; }
replace
9
17
9
16
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<vector<int>> VVI; typedef vector<ll> VL; typedef vector<vector<ll>> VVL; typedef vector<double> VD; typedef vector<vector<double>> VVD; const double PI = 3.14159265358979323846; const int INF = 1 << 30; const ll LINF = 1LL << 62; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP1(i, n) for (int i = 1; i <= (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPLL1(i, n) for (ll i = 1; i <= (ll)(n); i++) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define LEN(x) ((int)(x).length()) #define ZERO(a) memset(a, 0, sizeof(a)) #define RAD(d) (PI * (d) / 180) #define DEG(r) (180.0 * (r) / PI) #define POPCOUNT(x) __builtin_popcount(x) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template <class T> void dump(const vector<T> &v) { REP(i, SZ(v) - 1) { cout << v[i] << " "; } cout << v[SZ(v) - 1] << endl; } template <class T> void dump(int w, int h, const vector<T> &v) { REP(j, h) { REP(i, w - 1) { cout << v[j * w + i] << " "; } cout << v[j * w + w - 1] << endl; } } // 和 template <class T> T accumulate(const vector<T> &v) { T sum = 0; REP(i, SZ(v)) { sum += v[i]; } return sum; } // 和(範囲指定) template <class T> T accumulate(const vector<T> &v, int start, int length) { T sum = 0; REP(i, length) { sum += v[start + i]; } return sum; } // 平均 template <class T> T average(const vector<T> &v) { return accumulate(v) / SZ(v); } // 行列 template <class T> struct Matrix { T w, h; vector<T> A; Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {} T get(T x, T y) const { return A[y * w + x]; } }; template <class T> void input(Matrix<T> &m) { REP(j, m.h) { REP(i, m.w) { cin >> m.A[j * m.w + i]; } } } template <class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b) { Matrix<T> m(b.w, a.h); REP(j, m.h) { REP(i, m.w) { ll c = 0; REP(k, a.w) { c += a.A[j * a.w + k] * b.A[k * b.w + i]; } m.A[j * m.w + i] = c; } } return m; } void dump(const Matrix<ll> &m) { REP(j, m.h) { REP(i, m.w - 1) { printf("%lld ", m.A[j * m.w + i]); } printf("%lld\n", m.A[j * m.w + m.w - 1]); } } void dump(const Matrix<double> &m) { REP(j, m.h) { REP(i, m.w - 1) { printf("%f ", m.A[j * m.w + i]); } printf("%f\n", m.A[j * m.w + m.w - 1]); } } // 文字列の大文字化 string &to_upper(string &s) { REP(i, s.length()) { if ('a' <= s[i] && s[i] <= 'z') { s[i] -= 32; } } return s; } // 文字列の小文字化 string &to_lower(string &s) { REP(i, s.length()) { if ('A' <= s[i] && s[i] <= 'Z') { s[i] += 32; } } return s; } // すべての約数を列挙する template <class T> vector<T> get_divisors(T n) { vector<T> ret; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ALL(ret)); return ret; } // 1-sqrt(N)までの約数を列挙する template <class T> vector<T> get_divisors2(T n) { vector<T> ret; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); } } return ret; } // 最大公約数(※ユークリッドの互除法) template <class T> T gcd(T a, T b) { if (a < b) return gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } // 3数の最大公約数(※ユークリッドの互除法) template <class T> T gcd(T a, T b, T c) { return gcd(gcd(a, b), c); } // 3数以上の最大公約数 template <class T> T gcd(const vector<T> v) { if (SZ(v) == 0) return 0; if (SZ(v) == 1) return v[0]; if (SZ(v) == 2) return gcd(v[0], v[1]); T g = v[0]; for (int i = 1; i < SZ(v); i++) { g = gcd(g, v[i]); } return g; } // MOD計算 // // modint 構造体を使ってみませんか? (C++) - noshi91のメモ // https://noshi91.hatenablog.com/entry/2019/03/31/174006 // // 使い方: // const int MOD = 1000000007; // using mint = modint<MOD>; // mint a = 1234; // template <std::uint_fast64_t Modulus> class modint { using u64 = std::uint_fast64_t; public: u64 a; constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; } constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; } constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; } constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; } constexpr modint &operator+=(const modint rhs) noexcept { a += rhs.a; if (a >= Modulus) { a -= Modulus; } return *this; } constexpr modint &operator-=(const modint rhs) noexcept { if (a < rhs.a) { a += Modulus; } a -= rhs.a; return *this; } constexpr modint &operator*=(const modint rhs) noexcept { a = a * rhs.a % Modulus; return *this; } constexpr modint &operator/=(modint rhs) noexcept { u64 exp = Modulus - 2; while (exp) { if (exp % 2) { *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } }; int main() { ll A, B, N; cin >> A >> B >> N; ll max_x = 0; if (B > A) { for (ll x = 0; x <= N; x = x * B / A) { chmax(max_x, (ll)(floor(A * x / (double)B) - A * floor(x / (double)B))); } } else { for (ll x = 0; x <= N; x = x++) { chmax(max_x, (ll)(floor(A * x / (double)B) - A * floor(x / (double)B))); } } cout << max_x << endl; return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<vector<int>> VVI; typedef vector<ll> VL; typedef vector<vector<ll>> VVL; typedef vector<double> VD; typedef vector<vector<double>> VVD; const double PI = 3.14159265358979323846; const int INF = 1 << 30; const ll LINF = 1LL << 62; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP1(i, n) for (int i = 1; i <= (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPLL1(i, n) for (ll i = 1; i <= (ll)(n); i++) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define LEN(x) ((int)(x).length()) #define ZERO(a) memset(a, 0, sizeof(a)) #define RAD(d) (PI * (d) / 180) #define DEG(r) (180.0 * (r) / PI) #define POPCOUNT(x) __builtin_popcount(x) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } template <class T> void dump(const vector<T> &v) { REP(i, SZ(v) - 1) { cout << v[i] << " "; } cout << v[SZ(v) - 1] << endl; } template <class T> void dump(int w, int h, const vector<T> &v) { REP(j, h) { REP(i, w - 1) { cout << v[j * w + i] << " "; } cout << v[j * w + w - 1] << endl; } } // 和 template <class T> T accumulate(const vector<T> &v) { T sum = 0; REP(i, SZ(v)) { sum += v[i]; } return sum; } // 和(範囲指定) template <class T> T accumulate(const vector<T> &v, int start, int length) { T sum = 0; REP(i, length) { sum += v[start + i]; } return sum; } // 平均 template <class T> T average(const vector<T> &v) { return accumulate(v) / SZ(v); } // 行列 template <class T> struct Matrix { T w, h; vector<T> A; Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {} T get(T x, T y) const { return A[y * w + x]; } }; template <class T> void input(Matrix<T> &m) { REP(j, m.h) { REP(i, m.w) { cin >> m.A[j * m.w + i]; } } } template <class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b) { Matrix<T> m(b.w, a.h); REP(j, m.h) { REP(i, m.w) { ll c = 0; REP(k, a.w) { c += a.A[j * a.w + k] * b.A[k * b.w + i]; } m.A[j * m.w + i] = c; } } return m; } void dump(const Matrix<ll> &m) { REP(j, m.h) { REP(i, m.w - 1) { printf("%lld ", m.A[j * m.w + i]); } printf("%lld\n", m.A[j * m.w + m.w - 1]); } } void dump(const Matrix<double> &m) { REP(j, m.h) { REP(i, m.w - 1) { printf("%f ", m.A[j * m.w + i]); } printf("%f\n", m.A[j * m.w + m.w - 1]); } } // 文字列の大文字化 string &to_upper(string &s) { REP(i, s.length()) { if ('a' <= s[i] && s[i] <= 'z') { s[i] -= 32; } } return s; } // 文字列の小文字化 string &to_lower(string &s) { REP(i, s.length()) { if ('A' <= s[i] && s[i] <= 'Z') { s[i] += 32; } } return s; } // すべての約数を列挙する template <class T> vector<T> get_divisors(T n) { vector<T> ret; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ALL(ret)); return ret; } // 1-sqrt(N)までの約数を列挙する template <class T> vector<T> get_divisors2(T n) { vector<T> ret; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); } } return ret; } // 最大公約数(※ユークリッドの互除法) template <class T> T gcd(T a, T b) { if (a < b) return gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } // 3数の最大公約数(※ユークリッドの互除法) template <class T> T gcd(T a, T b, T c) { return gcd(gcd(a, b), c); } // 3数以上の最大公約数 template <class T> T gcd(const vector<T> v) { if (SZ(v) == 0) return 0; if (SZ(v) == 1) return v[0]; if (SZ(v) == 2) return gcd(v[0], v[1]); T g = v[0]; for (int i = 1; i < SZ(v); i++) { g = gcd(g, v[i]); } return g; } // MOD計算 // // modint 構造体を使ってみませんか? (C++) - noshi91のメモ // https://noshi91.hatenablog.com/entry/2019/03/31/174006 // // 使い方: // const int MOD = 1000000007; // using mint = modint<MOD>; // mint a = 1234; // template <std::uint_fast64_t Modulus> class modint { using u64 = std::uint_fast64_t; public: u64 a; constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; } constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; } constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; } constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; } constexpr modint &operator+=(const modint rhs) noexcept { a += rhs.a; if (a >= Modulus) { a -= Modulus; } return *this; } constexpr modint &operator-=(const modint rhs) noexcept { if (a < rhs.a) { a += Modulus; } a -= rhs.a; return *this; } constexpr modint &operator*=(const modint rhs) noexcept { a = a * rhs.a % Modulus; return *this; } constexpr modint &operator/=(modint rhs) noexcept { u64 exp = Modulus - 2; while (exp) { if (exp % 2) { *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } }; int main() { ll A, B, N; cin >> A >> B >> N; cout << A * min(B - 1, N) / B << endl; return 0; }
replace
273
285
273
274
TLE
p02696
C++
Time Limit Exceeded
/** * Author : Parth Prajapati aka (PARTH_4399, hungry_chef) * Institute : Pandit Deendayal Petroleum University **/ #include <bits/stdc++.h> using namespace std; #define start_cooking int main() #define food_is_ready return 0; #define main_ingredient_added \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); start_cooking { main_ingredient_added // start with your recipe long long a, b, n; cin >> a >> b >> n; long long i, ans = 0; for (i = b - 1; i < n + 1; i += b) ans = max(ans, (a * i) / b - a * (i / b)); i = n; ans = max(ans, (a * i) / b - a * (i / b)); cout << ans; food_is_ready }
/** * Author : Parth Prajapati aka (PARTH_4399, hungry_chef) * Institute : Pandit Deendayal Petroleum University **/ #include <bits/stdc++.h> using namespace std; #define start_cooking int main() #define food_is_ready return 0; #define main_ingredient_added \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); start_cooking { main_ingredient_added // start with your recipe long long a, b, n; cin >> a >> b >> n; long long k; k = min(n, b - 1); cout << (a * k) / b - a * (k / b); food_is_ready }
replace
21
27
21
24
TLE
p02696
C++
Time Limit Exceeded
#include <iostream> int main() { int64_t A, B, N; std::cin >> A >> B >> N; int64_t starter = N / B; starter *= B; if (starter == 0) starter = B; int64_t max_num = 0; for (int64_t x = B; x <= N; x += B) { int64_t calcx = x - 1; int64_t first = A * calcx / B; int64_t second = calcx / B; int64_t result = first - A * second; if (max_num < result) max_num = result; } int64_t calcx = N; int64_t first = A * calcx / B; int64_t second = calcx / B; int64_t result = first - A * second; if (max_num < result) max_num = result; std::cout << max_num; }
#include <iostream> int main() { int64_t A, B, N; std::cin >> A >> B >> N; int64_t starter = N / B; starter *= B; if (starter == 0) starter = B; int64_t max_num = 0; for (int64_t x = starter; x <= N; x += B) { int64_t calcx = x - 1; int64_t first = A * calcx / B; int64_t second = calcx / B; int64_t result = first - A * second; if (max_num < result) max_num = result; } int64_t calcx = N; int64_t first = A * calcx / B; int64_t second = calcx / B; int64_t result = first - A * second; if (max_num < result) max_num = result; std::cout << max_num; }
replace
11
12
11
12
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++) const int INF = 1001001001; int main() { long long int a, b, n; cin >> a >> b >> n; int ans = 0; if (b < n) n = b; for (int x = 1; x <= n; x++) { long double x1 = a * x / b; long double x2 = x / b; int answ = floor(x1) - a * floor(x2); if (ans < answ) ans = answ; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int INF = 1001001001; int main() { long long int a, b, n; cin >> a >> b >> n; long long int x = min(n, b - 1); long long int ans = (a * x / b) - a * (x / b); cout << ans << endl; }
replace
8
19
8
10
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long long #define pi 3.14159265359 int main() { ll A, B, N; cin >> A >> B >> N; ll m = 0; for (int i = 1; i <= min(B, N); i++) { m = max(m, (A * i) / B - A * (i / B)); } cout << m << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long long #define pi 3.14159265359 int main() { ll A, B, N; cin >> A >> B >> N; ll m; if (N < B) { m = (A * N) / B - A * (N / B); } else { m = (A * (B - 1)) / B - A * ((B - 1) / B); } cout << m << endl; }
replace
10
13
10
15
TLE
p02696
C++
Time Limit Exceeded
// containing t test cases #include <bits/stdc++.h> #define pb push_back #define mod 1000000007 #define mkp make_pair #define fi first #define se second #define ll long long #define scan(n) \ ll a[n]; \ for (ll i = 0; i < n; i++) \ cin >> a[i] #define print(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i] << ' ' #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define rep(i, x, y) for (ll i = x; i < y; i++) // #define int long long using namespace std; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> pll; typedef vector<pair<ll, ll>> vpll; /*vi adj[200005]; ll vis[200005]; ll parent[200005]; ll level[200005]; ll arr[200005]; ll size[200005];*/ // endl mut bhool!! int main() { fast; int test = 1; // cin>>test; while (test--) { ll a, b, n, x; cin >> a >> b >> n; ll flag = 0; for (ll i = n; i > 0; i--) { if (i % b == 0) { x = i - 1; flag = 1; break; } } if (!flag) { x = n; } cout << floor((a * x) / b) - a * floor(x / b); } return 0; } /* cout<<"YES"<<endl; cout<<"NO"<<endl; */
// containing t test cases #include <bits/stdc++.h> #define pb push_back #define mod 1000000007 #define mkp make_pair #define fi first #define se second #define ll long long #define scan(n) \ ll a[n]; \ for (ll i = 0; i < n; i++) \ cin >> a[i] #define print(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i] << ' ' #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define rep(i, x, y) for (ll i = x; i < y; i++) // #define int long long using namespace std; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> pll; typedef vector<pair<ll, ll>> vpll; /*vi adj[200005]; ll vis[200005]; ll parent[200005]; ll level[200005]; ll arr[200005]; ll size[200005];*/ // endl mut bhool!! int main() { fast; int test = 1; // cin>>test; while (test--) { ll a, b, n, x; cin >> a >> b >> n; ll flag = 0; ll y = n % b; x = n - y - 1; if (x <= 0) { x = n; } cout << floor((a * x) / b) - a * floor(x / b); } return 0; } /* cout<<"YES"<<endl; cout<<"NO"<<endl; */
replace
42
50
42
45
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define SORT(a) sort((a).begin(), (a).end()) #define RSORT(a) reverse((a).begin(), (a).end()) #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; const long long INF = 1LL << 60; // const int INF=1010101010; using Graph = vector<vector<int>>; int main() { ll a, b, n; cin >> a >> b >> n; ll ma = 0; for (int x = 0; x <= min(b, n); x++) { ma = max(a * x / b - x / b * a, ma); if (a * x / b - x / b * a >= a) break; } cout << ma << endl; }
#include <bits/stdc++.h> using namespace std; #define SORT(a) sort((a).begin(), (a).end()) #define RSORT(a) reverse((a).begin(), (a).end()) #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; const long long INF = 1LL << 60; // const int INF=1010101010; using Graph = vector<vector<int>>; int main() { ll a, b, n; cin >> a >> b >> n; ll x = min(b - 1, n); cout << a * x / b - a * (x / b) << endl; }
replace
13
21
13
15
TLE
p02696
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #define int long long signed main() { int N, A, B; std::cin >> A >> B >> N; /* int start = 0; int end = N + 1; int maxVal = 0; int moy = 0; while (start < end && moy < N) { moy = (start + end) / 2; int val = ((A * moy) / B) - (A * (moy / B)); if (val > maxVal) { start = moy; } else { end = moy; } maxVal = std::max(val, maxVal); } moy = (start + end) / 2; int val = (int)(std::floor((A * moy) / B)) - (int)((A * std::floor(moy / B))); maxVal = std::max(val, maxVal);*/ int maxVal = 0; for (int i = 0; i <= N; i++) { maxVal = std::max(maxVal, (int)(std::floor((A * i) / B)) - (int)((A * std::floor(i / B)))); } std::cout << maxVal; }
#include <algorithm> #include <cmath> #include <iostream> #define int long long signed main() { int N, A, B; std::cin >> A >> B >> N; std::cout << (int)(std::floor((A * std::min((B - 1), N)) / B)) - (int)((A * std::floor(std::min((B - 1), N) / B))); }
replace
8
40
8
10
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 P = pair<int, int>; using ll = long long; int main() { long double a, b, n; cin >> a >> b >> n; long double ans = 0; rep(x, n + 1) { ans = max(ans, floor(a * x / b) - a * floor(x / b)); } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using P = pair<int, int>; using ll = long long; int main() { long double a, b, n; cin >> a >> b >> n; long double ans = 0; if (n < b) ans = floor(a * n / b) - a * floor(n / b); else ans = floor(a * (b - 1) / b) - a * floor((b - 1) / b); cout << ans << endl; }
replace
11
12
11
15
TLE
p02696
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { long long A, B, N; cin >> A >> B >> N; bool flag = false; long long ans = 0; long long tmp; for (int x = 0; x <= N; x++) { if (A * x < B) continue; else if (x < B) tmp = (A * x) / B; else tmp = (A * x) / B - A * (x / B); if (tmp > ans) { ans = tmp; flag = true; } if (flag == true && tmp == 0) goto END; } END: cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { long long A, B, N; cin >> A >> B >> N; long long x = min(B - 1, N); long long ans = (A * x) / B - A * (x / B); cout << ans << endl; return 0; }
replace
7
25
7
10
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 all(v) v.begin(), v.end() #define _GLIBCXX_DEBUG long long f(long long a, long long b, long long x) { return a * x / b - a * (x / b); } int main() { using vi = vector<int>; long long a, b, n; cin >> a >> b >> n; long long x = 0; long long re = f(a, b, x); // int g = gcd(a,b); while (x <= n) { x += b; if (x > n) { x = n + 1; } long long y = f(a, b, x - 1); if (y > re) { re = y; } } cout << re << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define _GLIBCXX_DEBUG long long f(long long a, long long b, long long x) { return a * x / b - a * (x / b); } int main() { using vi = vector<int>; long long a, b, n; cin >> a >> b >> n; long long x = 0; long long re = f(a, b, x); // int g = gcd(a,b); x += b; if (x > n) { x = n + 1; } long long y = f(a, b, x - 1); if (y > re) { re = y; } cout << re << endl; }
replace
18
27
18
25
TLE