結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー TaniiGo
提出日時 2022-10-14 23:10:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,533 bytes
コンパイル時間 2,189 ms
コンパイル使用メモリ 194,004 KB
最終ジャッジ日時 2025-02-08 04:52:12
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define all(a) begin(a), end(a)
// abab
// (true)
template <typename T>
bool chmax(T &a, const T& b) {
if (a < b) {
a = b; // ab
return true;
}
return false;
}
// abab
// (true)
template <typename T>
bool chmin(T &a, const T& b) {
if (a > b) {
a = b; // ab
return true;
}
return false;
}
ll modpow(ll a, ll b, ll m) {
ll p = a;
ll ans = 1;
rep(i,32) {
if ((b & (0x01 << i)) != 0) {
ans *= p;
ans %= m;
}
p *= p;
p %= m;
}
return (ans);
}
ll pow(ll a, ll b) {
ll p = a;
ll ans = 1;
rep(i,32) {
if ((b & (0x01 << i)) != 0) {
ans *= p;
}
p *= p;
}
return (ans);
}
ll Division(ll a, ll b, ll m) {
return ((a * modpow(b, m - 2, m)) % m);
}
struct V {
int x, y;
V(int x=0, int y=0): x(x), y(y) {}
V operator-(const V &a) const {
return V(x-a.x, y-a.y);
}
int cross(const V &a) const {
return x*a.y - y*a.x;
}
int ccw(const V &a) const {
int area = cross(a);
if (area > 0) return +1; // ccw
if (area < 0) return -1; // cw
return 0; // collinear
}
};
/*
2147483648 int max
1000000000 1e9
9223372036854775807 ll max
1000000000000000000 1e18
*/
int main() {
int t;
cin >> t;
int x, a, y, b;
cin >> x >> a >> y >> b;
if (t > 0) {
int now = 0;
int c0 = (t-now)/a*x;
c0 += t%a;
now = 0;
int c1 = ((t+a-1)/a)*x;
now = (t+a-1)/a*a;
c1 += (now-t+b-1)/b*y;
now -= (now-t+b-1)/b*b;
c1 += (t-now);
now = 0;
int c2 = (t+a+b-1)/a*x;
now = (t+a+b-1)/a*a;
c2 += (now-t+b-1)/b*y;
now -= (now-t+b-1)/b*b;
c2 += (t-now)/a*x;
now += (t-now)/a*a;
c2 += t-now;
now = 0;
int c3 = (t+b-1)/a*x;
now = (t+b-1)/a*a;
c3 += (now-t+b-1)/b*y;
now -= (now-t+b-1)/b*b;
c3 += (t-now)/a*x;
now += (t-now)/a*a;
c3 += (t-now);
chmin(c0,c1);
chmin(c0,c2);
chmin(c0,c3);
cout << c0 << endl;
}
else {
t = -t;
int now = 0;
int c0 = (t-now+b-1)/b*y;
now = (t-now+b-1)/b*b;
c0 += (now-t)/a*x;
now -= (now-t)/a*a;
c0 += abs(t-now);
now = 0;
int c1 = (t-now+a+b-1)/b*y;
now = (t-now+a+b-1)/b*b;
c1 += (now-t)/a*x;
now -= (now-t)/a*a;
c1 += (now-t);
cout << min(c0,c1) << endl;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0