結果
問題 |
No.2128 Round up!!
|
ユーザー |
![]() |
提出日時 | 2022-11-18 22:10:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 926 bytes |
コンパイル時間 | 3,858 ms |
コンパイル使用メモリ | 250,832 KB |
最終ジャッジ日時 | 2025-02-08 21:49:02 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 WA * 2 TLE * 2 MLE * 5 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 mint get(long long a,long long b,long long c){ long long g = gcd(b,c); a /= g; b /= g; c /= g; //cout<<a<<','<<b<<','<<c<<endl; if(a/b==c)return 0; if(b>c){ mint ret = c; ret -= a/b; ret *= 2; return ret; } else{ return get(((a+c-1)/c)*c,c,b) + 1; } } int main(){ int _t; cin>>_t; rep(_,_t){ long long a,b,c; cin>>a>>b>>c; if(a%b==0&&a%c==0){ cout<<1<<endl; continue; } mint ans = 0; ans += 1; long long x = ((a+b-1)/b)*b; long long y = ((a+c-1)/c)*c; if(x<=y){ if(x!=a)ans++; ans += get(x,b,c); } else{ if(y!=a)ans++; ans += get(y,c,b); } cout<<ans.val()<<endl; } return 0; }