健忘云朵

文章
9
资源
0
加入时间
3年1月12天

Educational Codeforces Round 117 (Rated for Div. 2)

a稍微进行分类讨论#include <iostream>using namespace std;#define eps 1e-8const int maxn = 1e6; void solve(){ int a, b, x, y; // c(x, y); // A(0,0) B(x,y) scanf("%d %d", &a, &b); int dis_ac = x + y; // 2x + 2y = a + b;

Catch That Cow

农夫知道一头牛的位置,想要抓住它。农夫和牛都于数轴上 ,农夫起始位于点 N(0<=N<=100000) ,牛位于点 K(0<=K<=100000) 。农夫有两种移动方式: 1、从 X移动到 X-1或X+1 ,每次移动花费一分钟 2、从 X移动到 2*X ,每次移动花费一分钟 假设牛没有意识到农夫的行动,站在原地不。最少要花多少时间才能抓住牛? Input 一行: 以空格...

使用next遍历迭代器

不使用for遍历可迭代对象,而使用 next() 函数并在代码中捕获 StopIteration 异常。 比如,下面的例子手动读取一个文件中的所有行:def manual_iter(): with open('test.txt', "r") as f: try: while True: line = next(f)...