USACO Section 3.2: Feed Ratios
直接暴力搜
/* ID: yingzho1 LANG: C++ TASK: ratios */ #include <iostream> #include <fstream> #include <string> #include <map> #include <vector> #include <set> #include <algorithm> #include <stdio.h> #include <queue> #include <cstring> #include <cmath> #include <list> #include <cstdio> #include <cstdlib> using namespace std; ifstream fin("ratios.in"); ofstream fout("ratios.out"); struct node { int x, y, z; node(int a, int b, int c) : x(a), y(b), z(c) { } node() : x(), y(), z() { } }; ; //int f[101][101][101]; int main() { node target, s[]; fin >> target.x >> target.y >> target.z; ; i < ; i++) fin >> s[i].x >> s[i].y >> s[i].z; /*for (int i = 0; i < 101; i++) for (int j = 0; j < 101; j++) for (int k = 0; k < 101; k++) f[i][j][k] = inf;*/ int minnum = inf; int recx, recy, recz; ; i < ; i++) { ; j < ; j++) { ; k < ; k++) { ].x+j*s[].x+k*s[].x; ].y+j*s[].y+k*s[].y; ].z+j*s[].z+k*s[].z; || xx%target.x == ) && (target.y == || yy%target.y == ) && (target.z == || zz%target.z == ) && xx*target.y == yy*target.x && yy*target.z == zz*target.y) { int tmp = inf; if (target.x && xx) tmp = xx/target.x; else if (target.y && yy) tmp = yy/target.y; else if (target.z && zz) tmp = zz/target.z; if (tmp < minnum) { minnum = tmp; recx = i, recy = j, recz = k; } } } } } if (minnum < inf) fout << recx << " " << recy << " " << recz << " " << minnum << endl; else fout << "NONE" << endl; ; }
USACO Section 3.2: Feed Ratios的更多相关文章
- 洛谷P2729 饲料调配 Feed Ratios
P2729 饲料调配 Feed Ratios 36通过 103提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 暂时没有讨论 题目背景 农夫约翰从来只用调 ...
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 4.2 Drainage Ditches(最大流)
最大流问题.ISAP算法.注意可能会有重边,不过我用的数据结构支持重边.距离d我直接初始化为0,也可以用BFS逆向找一次. -------------------------------------- ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- 20、android解决方案(转载)
目录: 1.广告 2.推送 3.云 4.统计 5.后端存储 6.地图 7.测试 8.托管 9.支付 10.音视频 11.社会化分享 12.存储 13.自动更新 14.轻开发 15.安全 16.图像 1 ...
- Spring MVC 学习笔记 data binding
最近在实验Spring的时候遇到了一个问题: SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with ...
- netty 粘包问题处理
netty 粘包问题处理 key words: netty 粘包 解包 半包 TCP 一般TCP粘包/拆包解决办法 定长消息,例如每个报文长度固定,不够补空格 使用回车换行符分割,在包尾加上分割符,例 ...
- JS 学习笔记--4---运算符
1.JS 中包含的运算符有:一元运算符.二元运算符.三元运算符.算术运算符.关系运算符.逻辑运算符.位运算符.赋值运算符.其他的运算符等. 2.表达式:简单来讲就是一句代码(分号隔开),解释器会把它翻 ...
- angularJs 问题
1. IE不能渲染指令中的 style="background-color",而chrome和firefox可以 <!DOCTYPE html> <html ng ...
- thinkPHP生成静态分页列表
改造分页类Pagehtml.class.php <?php // 静态分页列表类 class Pagehtml extends Think { //分页url public $pageUrl; ...
- 学习NAnt Build .CS+Solution+MSBuild+SVN+NUnit+NUnitReport
NAnt help:http://nant.sourceforge.net/release/latest/help/tasks/NAntContrib help:http://nantcontrib. ...
- CSS Hack大全-可区分出IE6-IE10、FireFox、Chrome、Opera
今天把一些常用的CSS Hack整理了一下,包括常用的IE hack以及火狐.Chrome.Opera浏览器的Hack,并把这些CSS Hack综合的一起,写了一个小的浏览器测试器.如图所示: 下面就 ...
- Scala学习——数组/映射/元组
[<快学Scala>笔记] 数组 / 映射 / 元组 一.数组 1.定长数组 声明数组的两种形式: 声明指定长度的数组 val 数组名= new Array[类型](数组长度) 提供数组初 ...
- C#&java重学笔记(面向对象)
C#部分 1.C#有一个internal关键字,指字段可以同一个程序集中访问,出了程序集不行.还有一个protected internal(没有先后之分)修饰词,指只能在同一个程序集中的子类访问 2. ...