QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#642588 | #6607. Rise of Shadows | potential | WA | 0ms | 3708kb | C++20 | 1.7kb | 2024-10-15 15:06:28 | 2024-10-15 15:06:32 |
Judging History
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;
map <int, int> mp;
vector <int> v;
int exgcd(int a, int b, int &x, int &y){
if(b == 0) {x = 1, y = 0; return a; }
int d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
void Solve(){
int h, m, a;
cin >> h >> m >> a;
double t = (double)a * 2 / (h - 1);
int ans = (h - 2) * (int)t;
// cout << "ans:" << ans <<"\n";
int p = h * m % (h - 1);
// cout <<"p:" << p <<"\n";
int x, y;
int d = exgcd(p, h - 1, x, y);
x *= -a / d;
int mod = (h - 1) / d;
// cout << "mod:" <<mod <<'\n';
x = (x % mod + mod) % mod;
// cout << "x1: "<< x <<"\n";
int sum = 0, xx = x;
sum = (h - 1 - x) / mod + 1;
ans += sum;
d = exgcd(p, h - 1, x, y);
x *= a / d;
x = (x % mod + mod) % mod;
// cout << "x2: "<< x <<"\n";
if(xx != x){
sum = (h - 1 - x) / mod + 1;
ans += sum;
}
ans += 1;
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: 3704kb
input:
5 5 4
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
3 5 1
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3708kb
input:
5 5 0
output:
3
result:
wrong answer 1st numbers differ - expected: '1', found: '3'