文章目录
牛客周赛 Round 62(期望、DFS、主席树、DP、逆推DP)
A. 小红的字符移动
交换前两个元素的位置即可。
#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
swap(s[0], s[1]);
cout << s << endl;
return 0;
}
B. 小红的数轴移动
根据题意模拟即可。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n, x;
cin >> n >> x;
ll res = 0, s;
while(n--){
if(x == 0) break;
cin >> s;
res += s;
if(x > 0) x -= s;
else x += s;
}
cout << res << endl;
return 0;
}
C. 小红的圆移动
对于原点不在圆内的圆,设圆心为(x,y),其移动的代价为: ( r − x 2 + y 2 ) ∗ Π ∗ r 2 (r - \sqrt{x^2+y^2}) * Π * r^2 (r−x2+y2

最低0.47元/天 解锁文章
1314

被折叠的 条评论
为什么被折叠?



