跳至正文

USACO 3.2.4 Feed Ratios 解题报告

  • OI路程

这题网上普遍的解法都是什么高斯消原,什么解线性方程,我可真不懂,只看到有个人说暴力上能够干掉,我就暴力了咯,代码如下: de lang="c">/ LANG: C ID: yylogoo1 PROG: ratios / #include #include int need[3]; int have[3][3]; int ans[3]; int best = 300, last_ans; int tmp[3]; void check(void) { int i, t, s; int got[3] = {0, 0, 0}; for(i = 0; i <3 i goti="tmp[0]" havei tmp havei tmp havei ifgot need="0){" return t="got[0]" need fori="s" i i s="tmp[i];" ift needi="got[i]){" return ifs>= best || s == 0){ return; } memcpy(ans, tmp, sizeof(ans)); best = s; last_ans = t; } void srch(int now) { int i; if(now == 3){ check(); return; } for(i = 0; i <100 i srchnow tmpnow tmpnow="0;" int mainvoid int i freopenratiosin r stdin freopenratiosout w stdout scanfddd need need need fori="0;" i i scanfddd havei havei havei srch iflast_ans="= 0){" printfNONEn return printfd d d ans ans ans printfdn last_ans return code>

发表回复

您的电子邮箱地址不会被公开。