結果
問題 | No.2128 Round up!! |
ユーザー |
|
提出日時 | 2022-11-18 22:18:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 236 ms / 2,000 ms |
コード長 | 503 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 67,960 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 02:39:42 |
合計ジャッジ時間 | 3,167 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
コンパイルメッセージ
main.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 15 | main() | ^~~~
ソースコード
#include<iostream> #include<atcoder/modint> using namespace std; using mint=atcoder::modint998244353; long gcd(long a,long b) { while(b) { long t=a%b; a=b; b=t; } return a; } main() { int T;cin>>T; for(;T--;) { long X,A,B; cin>>X>>A>>B; if(A>B)swap(A,B); mint ans=1; if(X%A!=0&&X%B!=0) { ans++; X=min((X+A-1)/A*A,(X+B-1)/B*B); } if(X%B!=0) { ans++; X=(X+B-1)/B*B; } long k=X/B; long t=A/gcd(A,B); ans+=(-k%t+t)%t*mint(2); cout<<ans.val()<<"\n"; } }