USACO Bronze 2017 Open - The Lost Cow
Authors: Jesse Choe, Ananth Kashyap, Brad Ma
Implementation
Time Complexity:
C++
// Created by Jesse Choe - Bronze Template#include <bits/stdc++.h>using namespace std;// Type aliasesusing ll = long long;using str = string;using vi = vector<int>;
Python
# Take in the input data using python standard file I/O systemfile_in = open("lostcow.in")data = file_in.read().strip().split("\n")x, y = map(int, data[0].split(" "))# Compute the number of times Farmer John must change directionif y > x:p = 0while (2**p) + x < y:p += 2
Java
import java.io.*;import java.util.StringTokenizer;public class theLostCow {public static void main(String[] args) throws IOException {Kattio io = new Kattio("lostcow");int x = io.nextInt();int y = io.nextInt();int direction = 1;
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!