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求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- 如何用myeclispe远程调试tomcat
如何用myeclispe远程调试tomcat 在工作开发中,通常用本机进行代码编写,然后将编好的工程部署到测试服务器进行测试.往往测试服务器并不是自己的本机,因此对调试带来众多不便.今天学习可以用my ...
- android中的“visible ”、“invisible”、“gone”的区别(转载)
在Android开 发中,大部分控件都有visibility这个属性,其属性有3个分别为“visible ”.“invisible”.“gone”.主要用来设置控制控件的显示和隐藏.有些人可能会疑惑I ...
- Phpstorm开发记
Phpsotrm虽然付费项目,但网上有免费的激活码,也可以免费用不是. 1.首先是svn,windows项目下用Phpsotrm需要安装svn时,支付svn命令的,否则会提示找不到svn命令.2.建项 ...
- 【BZOJ】【1021】【SHOI2008】Dept循环的债务
DP 去膜拜题解了>_>玛雅原来是动规…… 让我先理解一下为什么要用动规:这个题根据钱数推方案其实是无从下手的……(线性规划?……事实证明我想多了) 啦-我们先来看个超级简化版的问题:怎么 ...
- 【BZOJ】【1640】【USACO2007 Nov】/【1692】【USACO2007 Dec】队列变换
后缀数组/贪心 每次从等待序列的头或尾拿出一个放到答案序列的末尾,那么每次贪心比较头和尾的字典序大小即可…… TAT贪心很好想,但是我一开始没想到是可以直接比较字符串大小……而是一位一位判的,WA了… ...
- SQL Server 2008中新增的 1.变更数据捕获(CDC) 和 2.更改跟踪
概述 1.变更数据捕获(CDC) 每一次的数据操作都会记录下来 2.更改跟踪 只会记录最新一条记录 以上两种的区别: http://blog.csdn.n ...
- websphere变成英文了
ebsphere页面怎么变成中文? 浏览器 -- internet选项 -- 常规 -- "语言" -- 打开后: 1. 如果只有"英语(美国)[en-US]" ...
- 用c语言产生随机数的方法
用c语言产生随机数的方法 在C语言中,rand()函数可以用来产生随机数,但是这不是真正意义上的随机数,是一个伪随机数,是根据一个数,我们可以称它为种子,为基准以某个递推公式推算出来的一系数,当这系列 ...
- Http Module 介绍
引言 Http 请求处理流程 和 Http Handler 介绍 这两篇文章里,我们首先了解了Http请求在服务器端的处理流程,随后我们知道Http请求最终会由实现了IHttpHandler接口的类进 ...
- 禁止触屏滑动touchmove方法介绍
在移动端页面开发中,有时需要禁止用户滑动屏幕,搜索了好久才找到移动终端的touch事件,touchstar,touchmove,touchend. 阻止滚动 一些移动设备有缺省的touchmove行为 ...