随便挑的条题目,模拟水题。
(丢代码跑)
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int n,x,y,ansx,ansy,nowx,nowy,nexty;
int main(){
cin >> n ;
while ( n ) {
ansx = ansy = nowx = nowy = nexty = 0 ;
cin >> x >> y ;
while (x > 0 && y > 0) {
if ( x + nowx <= n ) {
nowx += x ;
ansx = max( ansx , nowx ) ;
nexty = max( nowy + y , nexty ) ;
}
else {
nowx = x ;
ansx = max( ansx , nowx ) ;
nowy = nexty ;
nexty = nowy + y ;
}
cin >> x >> y ;
}
cout << ansx << " x " << nexty << endl ;
cin >> n ;
}
return 0;
}