solution-p8925
Paris_Commune · · 题解
分析
以样例
很明显
同理,设
这时再仔细看下图片,就可以找到其中的规律,我们设
使用题目中的给定数据最终得到:当
AC 代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
int t,l,r;
signed main(){
cin>>t>>l>>r;
while(t--){
int k;
char lr;
cin>>lr>>k;
if(lr=='L'){
if(k%2==1){
cout<<0-((l+r)*(k-1)+2*l)<<'\n';
}
else cout<<0-(l+r)*k<<'\n';
}
else{
if(k%2==1){
cout<<(l+r)*(k-1)+2*r<<'\n';
}
else cout<<(l+r)*k<<'\n';
}
}
return 0;
}