QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#688282 | #2944. Transporting Spaghetti | kevinyang# | AC ✓ | 1ms | 3664kb | C++17 | 809b | 2024-10-30 02:22:15 | 2024-10-30 02:22:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
void output(int x, int y){
cout << "We need " << x << ' ';
if(x == 1){
cout << "truck and ";
}
else{
cout << "trucks and ";
}
cout << y << ' ';
if(y == 1){
cout << "boat.\n";
}
else{
cout << "boats.\n";
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int a,b,c,d;
cin >> a >> b >> c >> d;
swap(c,d);
for(int t = 0; t<=1000; t++){
int n = t*a;
if(n>=c && (n-c)%b == 0 && n-c >= d){
int m = (n-c)/b;
output(t,m);
return 0;
}
}
cout << "No solution.\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
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: 1ms
memory: 3644kb
input:
100 20 30 10
output:
No solution.
result:
ok single line: 'No solution.'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3584kb
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: 1ms
memory: 3636kb
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: 1ms
memory: 3648kb
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: 0ms
memory: 3648kb
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: 0ms
memory: 3656kb
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: 1ms
memory: 3584kb
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: 0ms
memory: 3664kb
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: 1ms
memory: 3648kb
input:
1 1 97 100
output:
We need 197 trucks and 97 boats.
result:
ok single line: 'We need 197 trucks and 97 boats.'