美文网首页
Python刷题|Jugs

Python刷题|Jugs

作者: kami1护 | 来源:发表于2019-04-04 16:56 被阅读0次

1、题目

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1005

2、分析

关键假设:“You may assume that the input you are given does have a solution.”

所以乱七八糟的input就不要来凑热闹了。

所以,总的两条路,首先fill A 或者首先fill B ,那首先注满谁? 大于目标且邻近!然后就一直往另外一个pour,直到jug B里面的与目标相等。

3、解答

定义俩函数,也就是上面说的两条路

然后mian()判断,到底走哪条路

相关文章

  • Python刷题|Jugs

    1、题目 http://acm.zju.edu.cn/onlinejudge/showProblem.do?pro...

  • python刷题

  • TwoSum

    刷题当然要从TwoSum开始了~~python刷题果然容易~~~class Solution(object):de...

  • [LeetCode]7-反转整数

    前言 本次所选题库为 腾讯 2018 秋招精选(50 题) 题库.第一次刷题, 从简单题开始.Python, 以刷...

  • python刷题笔记

    知识点: 1、range(start,stop)函数默认从0开始,左闭右开,不包括stop。如range(5)表示...

  • leetcode 刷题之路

    作者按:以此记录leetcode刷题之路。python语言。题号是按作者自己刷题的个数累加的。与leetcode中...

  • 零基础python刷leetcode -- 1. Two Sum

    算法很重要,但是每天也需要学学python,于是就想用python刷leetcode 的算法题,从第一题开始,从简...

  • LeetCode12.23

    近一年左右没更新,开始刷LeetCode的Python3的题,坚持每天刷一点。我是刷LeetCode国外版本的题(...

  • Python趣味实战项目:抢红包提醒助手!

    Python资源共享群:626017123 最近后台有朋友问我学Python去哪刷题?我觉得看完Python的基础...

  • python leetcode 628

    这是用python刷的第一道算法题。原题:Given an integer array, find three n...

网友评论

      本文标题:Python刷题|Jugs

      本文链接:https://www.haomeiwen.com/subject/czrqiqtx.html