首页 > 其他分享 >2022.10.2

2022.10.2

时间:2022-10-02 14:12:16浏览次数:56  
标签:ch const int printf && ans 2022.10

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

const int N=1e5+50;
const int M=1e5+50;
const int Mod=1e9+7;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int n;

int v[N];

// string s1,s2;
char s1[N],s2[N];

char c1[N],c2[N];

char ans[N];

int to(char x){
	if(x>='0'&&x<='9') return x-'0'; else return x-'A'+10;
}

char ot(int x){
	if(x>=0&&x<=9) return x+'0'; else return x-10+'A';
}

int main()
{
	n=read();
	for(int i=0;i<n;++i) v[i]=read(),c1[i]='0',c2[i]='0';
	cin>>s1>>s2;
	int l1=strlen(s1)-1;
	int l2=strlen(s2)-1;
	for(int i=0;i<=l1;++i) c1[l1-i]=s1[i];
	for(int i=0;i<=l2;++i) c2[l2-i]=s2[i];
	// for(int i=0;i<n;++i) cout<<c1[i];
	// for(int i=0;i<n;++i) cout<<c2[i];
	for(int i=0;i<n;++i){
		ans[i]='0';
		int _=to(c1[i])+to(c2[i]);
		// cout<<c1[1]<<" "<<c2[1]<<endl;
		// cout<<_<<endl;
		c1[i+1]+=_/v[i];
		ans[i]=ot(_%v[i]);
	}
	bool f=0;
	for(int i=n-1;i>=0;--i){
		if(ans[i]=='0'&&!f) continue;
		if(ans[i]!='0') f=1;
		printf("%c",ans[i]); 
	}
	printf("\n");
	return 0;
}

标签:ch,const,int,printf,&&,ans,2022.10
From: https://www.cnblogs.com/R-V-G/p/16748703.html

相关文章

  • 【闲话】2022.10.01
    今天早上下雨充分证明了\(\texttt{雨假同期命题}\)的正确性但是国庆没有放假老天爷:玩我呢早上:\(\textsf{bikuhiku}\):完蛋,早上没外套,我再拿一件吧早操前:\(\texts......
  • 2022.10.1
    B.CrazyBinaryString给01串,问最长的01数量相等的子串和子序列长度。#include<bits/stdc++.h>usingnamespacestd;map<int,int>M;intn;chars[100005];intma......