第二个测试点在本地编译器正确,在洛谷错误
查看原帖
第二个测试点在本地编译器正确,在洛谷错误
773266
VictorMao楼主2024/7/10 21:13

这个代码过不了P1011的第二个测试点,但是在DEV-CPP里是对的。输入1 6 7 4输出4 管理员能帮忙看下吗?谢谢你

#include <bits/stdc++.h>
using namespace std;

int main() {
int a, n, x, b, m;
scanf ("%d%d%d%d", &a, &n, &m, &x);

if (x==1) {cout << a; return 0;}
else if (x==2) {cout << a; return 0;}
else if (x==3) {cout << 2 * a; return 0;}

int ycst[n+20]{0, a, a, 2*a}, yxs[n+20], zcst[n+20], zxs[n+20]{0, 0, 1, 1}, xcst[n+20]{0, a, 0, a}, xxs[n+20]{0, 0, 1, 1};
	
for (int i = 4; i <= (n-1); i++) {
ycst[i] = ycst[i-1] + zcst[i-1];
yxs[i] = yxs[i-1] + zxs[i-1];
zcst[i] = xcst[i-1];
zxs[i] = xxs[i-1];
xcst[i] = xcst[i-2] + xcst[i-1];
xxs[i] = xxs[i-2] + xxs[i-1];
}

b = (m - ycst[n-1]) / yxs[n-1];
cout << (ycst[x] + (yxs[x]*b));
return 0;

}
2024/7/10 21:13
加载中...