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求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- Crtmp 源码分析
Crtmp Server接收rtmp音视频流,并实现音视频并发,可以作为直播后台的服务.整套代码量并不大,算是轻量级的服务. 花了些时间研究源码,现将研究的结果,记录下来,方便以后查阅. 先不从架构上 ...
- 深入浅出谈4G ─ 4G LTE网速到底有多快?
常说4G网速能达100MHz,实际感受远远没有这么快.今天和大家一起算算帐,算算4G LTE网速到底有多快. 基本概念1:资源粒子 个资源粒子就是用个子载波传送个OFDM符号. 1个子载波的带宽是15 ...
- php sso单点登录原理阐述
原理:就是用户登录了单点登录系统(sso)之后,就可以免登录形式进入相关系统: 实现: 点击登录跳转到SSO登录页面并带上当前应用的callback地址 登录成功后生成COOKIE并将COOKIE传给 ...
- Linux网络编程实例解析
**************************************************************************************************** ...
- javascript禁止复制网页内容,兼容三大浏览器
javascript禁止复制网页内容可以通过以下方式实现:禁止鼠标右键+禁止选中文本. 代码很简单,只需要在head标签的javascript内加入以下两行代码即可. document.onconte ...
- 如何将控制台程序包装成windows服务
1. 新建一个项目,或者从选择当前解决方案--右键-添加--新建项目 2. 选择(项目类型)Visual C#项目,(模板)Windows 服务,填写要创建的服务名称(修改默认的WindowServi ...
- LCA 笔记
简述这几天的LCA 心得: LCA有两种做法:离线 or 在线 先学的离线: 原理博客很多. 我写得两道题,已经模板. HDU:http://acm.hdu.edu.cn/showproblem.ph ...
- HDOJ 1069 DP
开启DP之路 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1069 描述一下: 就是给定N(N<=20)个方体,让你放置,求放置的最高高度,限制条件 ...
- OpenLayers3 online build
openlayers3使用了一个比较复杂的build工具,从github上下载下来的代码中并没有build之后的版本,要配置build环境又比较繁琐,好在官方的example中提供了在线的版本,下面就 ...
- Red hat Linux 安装Node.js 源码安装
1. 下载源码包 http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz 2.准备安装环境,>python2.6, gcc, g++ pytho ...