QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688281#2944. Transporting Spaghettikevinyang#WA 1ms3632kbC++17809b2024-10-30 02:21:102024-10-30 02:21:10

Judging History

你现在查看的是最新测评结果

  • [2024-10-30 02:21:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3632kb
  • [2024-10-30 02:21:10]
  • 提交

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 = 1; 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3580kb

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: 0ms
memory: 3564kb

input:

100 20 30 10

output:

No solution.

result:

ok single line: 'No solution.'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3576kb

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: 0ms
memory: 3580kb

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: 0ms
memory: 3580kb

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: -100
Wrong Answer
time: 0ms
memory: 3632kb

input:

1 1 0 0

output:

We need 1 truck and 1 boat.

result:

wrong answer 1st lines differ - expected: 'We need 0 trucks and 0 boats.', found: 'We need 1 truck and 1 boat.'