結果
問題 |
No.1899 L1 Cafe
|
ユーザー |
|
提出日時 | 2022-01-31 06:15:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 995 bytes |
コンパイル時間 | 990 ms |
コンパイル使用メモリ | 65,824 KB |
最終ジャッジ日時 | 2025-01-27 18:01:40 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 TLE * 5 |
ソースコード
// This file is a "Hello, world!" in C++ language by GCC for wandbox. #include <iostream> #include <cstdlib> using namespace std; int main() { int T; cin >> T; while (T-->0) { int N, A, B; cin >> N >> A >> B; long long ans=0; { int top=N-A; int bottom=A-(A-N%A)%A; ans+=(long long)((top-bottom)/A+1)*(top+bottom)/2; } { int top=N-B; int bottom=B-(B-N%B)%B; ans+=(long long)((top-bottom)/B+1)*(top+bottom)/2; } int i=1; while (i<=N/A) { int k=(N-A*i)/B; int ni=(N-B*k)/A+1; ans-=(long long)k*(ni-i); i=ni; } cout << ans << endl; } } // GCC reference: // https://gcc.gnu.org/ // C++ language references: // https://cppreference.com/ // https://isocpp.org/ // http://www.open-std.org/jtc1/sc22/wg21/ // Boost libraries references: // https://www.boost.org/doc/