QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641589#6607. Rise of ShadowspotentialWA 0ms3632kbC++201.7kb2024-10-14 21:28:422024-10-14 21:28:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-14 21:28:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-10-14 21:28:42]
  • 提交

answer

# include <bits/stdc++.h>
using namespace std;
# define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
# define int long long
# define lowbit(x) (x & (-x))
# define fi first
# define se second
# define all(x) x.begin(), x.end()
// # define endl '\n'

inline int Read();

typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int N = 1e6 + 10;
const double eps = 1e-8;

int sgn(double x, double y){
    if(fabs(x - y) < eps) return 0;
    if(x < y) return -1;
    else return 1;
}

map <int, int> mp;
vector <int> v;

void Solve(){
    int h, m, a;
    cin >> h >> m >> a;
    double t = (double)a * 2 / (h - 1);
    int ans = (h - 2) * t;
    // cout << ans <<"\n";
    ans += 1 + a / (h - 1) * 2;
    // cout << ans <<"\n";
    int l = 0, r = h / 2, mid;
    while(l < r){
        mid = l + r + 1 >> 1;
        int k = h * m % (h - 1) * mid % (h - 1);
        if(sgn((double) a  / (h - 1) - (int)(a  / (h - 1)), (double) k / (h - 1)) >= 0) l = mid;
        else r = mid - 1;
    }
    int k = h * m % (h - 1) * l % (h - 1);
    // cout << (double) a  / (h - 1) - (int)(a  / (h - 1)) <<'\n';
    // cout << l <<" " << k <<" " << (double) k / (h - 1)<<"\n";
    if(h & 1){
        if(l == h / 2) ans += min((l - 1) * 2 + 1, h);
        else ans += min(l * 2, h);
    }else{
        ans += min(l * 2, h);
    }
    cout << ans <<"\n";
}
signed main(){
    IOS;
    int T = 1;
    // cin >> T;
    while (T--) 
        Solve();
    return 0;
}
inline int Read(){
    int x = 0, f = 1; char c = getchar();
    while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

input:

5 5 4

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3 5 1

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

5 5 0

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3628kb

input:

5 5 1

output:

4

result:

wrong answer 1st numbers differ - expected: '3', found: '4'