結果
| 問題 |
No.2128 Round up!!
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-11-18 22:13:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,004 bytes |
| コンパイル時間 | 4,222 ms |
| コンパイル使用メモリ | 250,532 KB |
| 最終ジャッジ日時 | 2025-02-08 21:50:33 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 WA * 3 |
ソースコード
#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){
if(b==c){
return 0;
}
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;
}
{
__int128 L = b;
L *= c;
a %= L;
}
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;
}
沙耶花