結果
問題 | No.2128 Round up!! |
ユーザー | kotatsugame |
提出日時 | 2022-11-18 22:18:19 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 246 ms / 2,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 67,064 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-10-20 07:08:11 |
合計ジャッジ時間 | 3,507 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 95 ms
4,348 KB |
testcase_02 | AC | 1 ms
4,348 KB |
testcase_03 | AC | 111 ms
4,348 KB |
testcase_04 | AC | 119 ms
4,348 KB |
testcase_05 | AC | 150 ms
4,348 KB |
testcase_06 | AC | 246 ms
4,348 KB |
testcase_07 | AC | 191 ms
4,348 KB |
testcase_08 | AC | 204 ms
4,348 KB |
testcase_09 | AC | 109 ms
4,348 KB |
testcase_10 | AC | 168 ms
4,348 KB |
testcase_11 | AC | 167 ms
4,348 KB |
testcase_12 | AC | 186 ms
4,348 KB |
コンパイルメッセージ
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) { if(X%A==0)cout<<"1\n"; else cout<<"2\n"; continue; } 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"; } }