180. 地铁站

会奔跑的bug

one_s = [int(one_num) for one_num in input().split(‘ ‘)]
a , n , m , x = one_s[0],one_s[1],one_s[2],one_s[3]
if x == 1 or x == 2:
print(a)
elif x==3:
print(2a)
elif x == n or x == n-1:
print(m)
else:
one_sss = [[1,0],[0,1]]
x_a = 0
x_b = 0
my_a = 0
my_b = 0
for i in range(2,n-1):
one_sss.append([one_sss[i-2][0]+one_sss[i-1][0],one_sss[i-2][1]+one_sss[i-1][1]])
my_a = my_a + one_sss[i-2][0]
my_b = my_b + one_sss[i-2][1]
if i == x-1:
x_a = my_a
x_b = my_b
b = (m-my_a
a-a)/my_b
my_num = a + x_aa + x_bb
print(int(my_num))

Komeiji_Satori

include

include

using namespace std;
typedef long long ll;
ll feb[22];
ll febsum[22];
void getfeb() {
feb[0] = feb[1] = 1;
febsum[0] = 1, febsum[1] = 2;
for (int i = 2; i < 22; i++)feb[i] = feb[i - 1] + feb[i - 2], febsum[i] = febsum[i - 1] + feb[i];
return;
}
int main() {
getfeb();
int a, n, m, x,b;
cin >> a >> n >> m >> x;
if (n <= 5) {
if (x == 4)cout << m << endl;
else cout << ((x + 1) / 2) * a << endl;
}
else {
b = (m - a * (2 + febsum[n - 6])) / febsum[n - 5];//m实际为n-1站发车的人数
if (x < 4)cout << ((x + 1) / 2) * a << endl;
else if (x == 4)cout << 2 * a + b << endl;
else cout << (2 + febsum[x - 5]) * a + febsum[x - 4] * b;
}
return 0;
}

你当前正在回复 博客/题目
存在问题!