P9736 [COCI2022-2023#2] Ekspert 题解
考虑一下式子
#include<bits/stdc++.h>
using namespace std;
long long x,y;
vector<string> opt;
int main(){
cin>>x>>y;
long long a,b,c;
a=x,b=y,c=0;//这里没有用到D
//枚举较小的数
if(x<y){
while(x){
if(x%2){
//如果当前x的位为一才累加进答案
opt.push_back("B C C");
c=b+c;
}
opt.push_back("B B B");
//2^i*x+2^i*x=2^(i+1)*x
b=b*2;
x=x/2;
}
}
else{
while(y){
if(y%2){
opt.push_back("A C C");
c=a+c;
}
opt.push_back("A A A");
a=a*2;
y=y/2;
}
}
cout<<opt.size()<<endl;
for(auto i:opt){
cout<<i<<endl;
}
cout<<"C"<<endl;
return 0;
}
提交记录