https://www.nowcoder.com/exam/test/65717435/detail?pid=16516564&examPageSource=Company&testCallback=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Fcompany%3FcurrentTab%3Drecommand%26jobId%3D100%26selectStatus%3D0%26tagIds%3D665&testclass=%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91
找规律,发现每次跳跃到下一阶段,能量都会变为:2*E-H(k+1)
#include <iostream> #include <vector> using namespace std;int main() { int N; cin>>N; vector<int> H(N+1,0); int i = 1; while (cin >> H[i++]) { // 注意 while 处理多个 case } long long res = 0; for(i= N;i>0;i--){ res = res + H[i]; res = (res + 1) / 2; } cout<<res<<'\n'; return 0; } // 64 位输出请用 printf("%lld")
标签:int,res,机器人,long,问题,E5%,while,跳跃 From: https://www.cnblogs.com/starter-songudi/p/17134096.html