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求余数. 题目给你两个字符串,其中的字 ...
随机推荐
- Xamarin.Android之山有木兮之木有枝,心悦君兮君不知。
Xamarin.Android之山有木兮之木有枝,心悦君兮君不知. 第一步,写项目中的第一个界面. <?xml version="1.0" encoding =" ...
- C#打印页面的纸张设置问题Spread表格控件
这段时间学习spread控件,用到打印设置上边,其他的设置都还好说,但是打印纸张的大小,纸张类型等把我折腾的够呛,找了半天才找到,记录下来备查. 1.打印纸张类型: System.Drawing.Pr ...
- 阿里云无线&前端团队是如何基于webpack实现前端工程化的
背景 前端经历了初期的野蛮生长(切图,写简单的特效)——为了兼容浏览器兼容性而出现的各种类库(JQUERY,YUI等——mv*(饱暖思淫欲,代码多了,也就想到怎样组织代码结构,backbone,ang ...
- Django:快速搭建简单的Blog
一,创建项目 1, 为blog创建名为mysite的工程项目: django-admin.py startproject mysite 2, 项目结构如下: mysite ├── manage.py ...
- MySQL用程序代码建表(1)
一.创建表格代码格式 create table <表名>( <列名> <数据类型及长度> [not null], <列名> <数据类型及长度> ...
- Matlab中颜色线形和形状
1.颜色字符串有'c', 'm', 'y', 'r', 'g', 'b', 'w',和'k'.分别表示青,红紫,黄,红,绿,白和黑. 2.线型字符串有:'-' 为实线, '--' 为虚线, ':' 为 ...
- NYOJ-244 16进制的简单运算 AC 分类: NYOJ 2014-01-17 21:11 195人阅读 评论(0) 收藏
#include<stdio.h> int main() { long x,y; char op; int t; scanf("%d ", &t); while ...
- Metasploit命令大全
Metasploit是一款开源的安全漏洞检测工具,可以帮助安全和IT专业人士识别安全性问题,验证漏洞的缓解措施,并管理专家驱动的安全性进行评估,提供真正的安全风险情报.这些功能包括智能开发,密码审计, ...
- 使用css3伪元素制作时间轴并且实现鼠标选中高亮效果
利用css3来制作时间轴的知识要点:伪元素,以及如何在伪元素上添加锚伪类 1)::before 在元素之前添加内容. 2)::after 在元素之后添加内容. 提示:亦可写成 :before :aft ...
- Long和Date数据类型之间相互转换代码
static final SimpleDateFormat DATETIME_SEC_STR = new SimpleDateFormat("yyyyMMddHHmmss"); 1 ...