QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73205 | #2944. Transporting Spaghetti | qdd# | AC ✓ | 3ms | 3536kb | C++20 | 1.0kb | 2023-01-23 04:53:29 | 2023-01-23 04:53:30 |
Judging History
answer
// qdd on Jan 22, 2023
#ifdef qdd
#include <ringo>
#else
#include <bits/stdc++.h>
#define dbg(...)
#define dbgr(x, y)
#endif
using namespace std;
using ll = long long;
#define ALL(x) begin(x), end(x)
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v) is >> x;
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
bool f = 0;
for (const T& x : v) (f ? os << ' ' : os) << x, f = 1;
return os;
}
void output(int x, int y) {
if (x == -1) {
cout << "No solution.\n";
} else {
cout << "We need " << x << (x == 1 ? " truck" : " trucks");
cout << " and " << y << (y == 1 ? " boat.\n" : " boats.\n");
}
}
void sol() {
int a, b, c, d;
cin >> a >> b >> c >> d;
for (int x = 0; x <= 10000; x++) {
if ((c + d + x) % a == 0 && (c + x) % b == 0) {
output((c + d + x) / a, (c + x) / b);
return;
}
}
output(-1, -1);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3340kb
input:
31 13 50 28
output:
We need 3 trucks and 5 boats.
result:
ok single line: 'We need 3 trucks and 5 boats.'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3416kb
input:
100 20 30 10
output:
No solution.
result:
ok single line: 'No solution.'
Test #3:
score: 0
Accepted
time: 3ms
memory: 3416kb
input:
1 1 1 100
output:
We need 101 trucks and 1 boat.
result:
ok single line: 'We need 101 trucks and 1 boat.'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3384kb
input:
20 5 5 15
output:
We need 1 truck and 1 boat.
result:
ok single line: 'We need 1 truck and 1 boat.'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3308kb
input:
100 20 100 100
output:
We need 2 trucks and 5 boats.
result:
ok single line: 'We need 2 trucks and 5 boats.'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3376kb
input:
1 1 0 0
output:
We need 0 trucks and 0 boats.
result:
ok single line: 'We need 0 trucks and 0 boats.'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
1 5 10 50
output:
We need 60 trucks and 2 boats.
result:
ok single line: 'We need 60 trucks and 2 boats.'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
100 1 100 100
output:
We need 2 trucks and 100 boats.
result:
ok single line: 'We need 2 trucks and 100 boats.'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3372kb
input:
1 1 100 100
output:
We need 200 trucks and 100 boats.
result:
ok single line: 'We need 200 trucks and 100 boats.'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
1 1 97 100
output:
We need 197 trucks and 97 boats.
result:
ok single line: 'We need 197 trucks and 97 boats.'