結果
問題 |
No.2128 Round up!!
|
ユーザー |
![]() |
提出日時 | 2022-11-18 22:26:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,555 bytes |
コンパイル時間 | 4,038 ms |
コンパイル使用メモリ | 256,068 KB |
最終ジャッジ日時 | 2025-02-08 21:56:47 |
ジャッジサーバーID (参考情報) |
judge1 / 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==0&&a%c==0)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; } } mint solve(long long a,long long b,long long c){ if(a%b==0&&a%c==0){ return 1; } { __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); } return ans; } mint gu(long long a,long long b,long long c){ set<long long> s; while(true){ s.insert(a); long long x = (a+b-1)/b; x *= b; long long y = (a+c-1)/c; y *= c; long long z =min(x,y); if(z==a)z = max(x,y); if(z==a)break; a = z; } return s.size(); } int main(){ int _t; cin>>_t; /* rep(i,10){ rep(j,10){ rep(k,10){ if(solve(i+1,j+1,k+1)!=gu(i+1,j+1,k+1)){ cout<<i+1<<','<<j+1<<','<<k+1<<endl; cout<<solve(i+1,j+1,k+1).val()<<','<<gu(i+1,j+1,k+1).val()<<endl; cout<<endl; } } } } */ rep(_,_t){ long long a,b,c; cin>>a>>b>>c; cout<<solve(a,b,c).val()<<endl; } return 0; }