您的位置:首页 > 其它

[POJ 2014] Flow Layout · 模拟

2015-05-21 10:22 267 查看
随便挑的条题目,模拟水题。

(丢代码跑)

#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: