28pts 求助
查看原帖
28pts 求助
310773
PCCP楼主2023/10/15 08:39

RT,思路是类似于快速幂的二分,但是最后一个 subtask 有两个点显示 too long 特来请求各位大佬的帮助!

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<set>
using namespace std;
const int N=5e4+10;
const int MOD=998244853;
int n;
long long p[5];
struct node{
	int x,y,z;
}act[N];
void ksm(long long x,long long y){
	while(y>1){
		if(y&1){
			act[++n]={3,0,0};
		}
		act[++n]={0,0,0};
		y>>=1;
	}
}
signed main(){
	cin>>p[0]>>p[1];
	p[2]=0,p[3]=1;
	ksm(p[0],p[1]);
	act[++n]={0,2,3};
	cout<<n<<endl;
	for(int i=n;i>=1;i--){
		char x=act[i].x+'A',y=act[i].y+'A',z=act[i].z+'A';
		cout<<x<<" "<<y<<" "<<z<<endl;
	}
	cout<<"A"<<endl;
}
2023/10/15 08:39
加载中...