后三测试点RE求助
查看原帖
后三测试点RE求助
1123452
czh___楼主2024/4/6 06:49
#include<bits/stdc++.h>
#define int long long
using namespace std;
string a,b;
int cnt=1,k,i;
signed main(){
  	while(cin>>a[cnt])
		cnt++;
	cnt--;
	k=3-cnt%3;
	if(!(cnt%3))
		k=0;
	for(i=1;i<=k;i++)
		b[i]='0';
	for(int i=k+1;i<=cnt+k;i++)
		b[i]=a[i-k];
	i=1;
	while(i<=cnt){
		string t="";
		for(int j=1;j<=3;j++){
			t+=b[i];
			i++;
		}
		if(t=="000") cout<<"0";
		else if(t=="001") cout<<"1";
		else if(t=="010") cout<<"2";
		else if(t=="011") cout<<"3";
		else if(t=="100") cout<<"4";
		else if(t=="101") cout<<"5";
		else if(t=="110") cout<<"6";
		else if(t=="111") cout<<"7";
	}
  	return 0;
}
2024/4/6 06:49
加载中...