题面在这里! 好久没有体会这种A题的快感了23333 一开始看错了,以为权值是从1开始的,不过这样不要紧,最后把算的答案减去两行数的和就是正确的答案了. 然后发现位于一个角上的时候,我们其实只有两种选择,一种是先一直走这一行走到头再返回来走,这样就走完了:另一种是走到这一列的另一行上然后再往右走一列. 第一种可以直接算,第二种dp一下就好啦,两种取一下最优. #include<bits/stdc++.h> #define ll long long using namespace std; co…
Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b. Vasya has two numbers x and y, and he wants to calculate f(x, y).…
C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and marks the distances from whi…
Codeforces 1107G 线段树最大子段和 + 单调栈 G. Vasya and Maximum Profit Description: Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit. Vasya has \(n\) problems to choo…