QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708784#2944. Transporting Spaghettisefnuray#Compile Error//Java111.3kb2024-11-04 06:35:382024-11-04 06:35:39

Judging History

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

  • [2024-11-04 06:35:39]
  • 评测
  • [2024-11-04 06:35:38]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <bitset>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>
#include <stdexcept>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
typedef long double ld;

int gcd (int a, int b) {
    return b ? gcd (b, a % b) : a;
}

int main() {
    //these first two lines speed up input / output significantly
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ld a, b, c, d;

    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;

    string truck = "truck";
    string boat = "boat";

    if((a>(b+d) || (a==0 && (c!=0 || d!=0)) ) || (b==0 && c!=0)) {
        cout<<"No solution.";
    } else if (a == 0 ) {
        cout<<"We need 0 trucks and 0 boats";
    } else if(b == 0) {
        ll t = ceil((c+d)/a);
        if(t != 1) {
            truck+= "s";
        } 
        
        cout<<"We need "<<t<<" "<<truck<<" and 0 boats.";
    } else {
        ll t = ceil((c+d)/a);
        ll boats = ceil((a*t-d)/b);
        if(t != 1) {
            truck+= "s";
        } 
        if(boats != 1) {
            boat+= "s";
        }

        cout<<"We need "<<t<<" "<<truck<<" and "<<boats<<" "<<boat<<".";
    }


}
    

Details

Can't find the main class.