Задача B автор Шумейко Максим
#include<iostream>
#include<string>
using namespace std;
int main ()
{
string a,b,c,d="ABCDEFG";
int n,x,y,z=0,k,m[7],l,h=0,r,o=0;
cin>>n>>a>>b;r=a.size()-b.size();
for (int i=0;i<=6;i++) m[i]=10+i;
for (int i=1;i<=r;i++) b='0'+b;
for (int i=a.size()-1;i>=0;i--)
{
k=0;
for (int j=0;j<7;j++) if (a[i]==d[j]) {k++;x=10+j;break;} if (k==0) x=a[i]-48;k=0;
for (int j=0;j<7;j++) if (b[i]==d[j]) {k++;y=10+j;break;} if (k==0) y=b[i]-48;k=0;
if (x-z<y) {x+=n;l=x-y-z;z=1;} else {l=x-y-z;z=0;}
if (l<n) {for (int j=0;j<7;j++) if (l==m[j]) {k++;c=d[j]+c;break;} if (k==0) c=char(l+48)+c;k=0;}
else {for (int j=0;j<7;j++) if (n-1==m[j]) {k++;c=d[j]+c;break;} if (k==0) c=char(n-1+48)+c;}
}
for (int i=0;i<c.size();i++) {if (h==0) {if (c[i]!='0') {h++;cout<<c[i];o++;}} else {cout<<c[i];o++;}} if (o==0) cout<<'0';
}
Задача C автор Сорока Дмитро
var a,b:array[0..3000]of integer;
res:array[0..6010]of integer;
n,i,j,m1,m2,c,mm,k:integer;
s1,s2:ansistring;
procedure int;
begin
readln(n);
readln(s1);
readln(s2);
m1:=length(s1);
m2:=length(s2);
for i:=m1 downto 1 do
begin
if s1[i] in ['A'..'Z'] then a[m1-i+1]:=ord(s1[i])-ord('A')+10 else
a[m1-i+1]:=ord(s1[i])-48;
end;
for i:=m2 downto 1 do
begin
if s2[i] in ['A'..'Z'] then b[m2-i+1]:=ord(s2[i])-ord('A')+10 else
b[m2-i+1]:=ord(s2[i])-48;
end;
end;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(res,sizeof(res),0);
int;
c:=0;
res[0]:=1;
for i:=1 to m1 do
for j:=1 to m2 do
begin
c:=a[i]*b[j];
k:=i+j-1;
while c<>0 do
begin
c:=c+res[k];
res[k]:=c mod n;
c:=c div n;
if k>mm then mm:=k;
inc(k);
end;
end;
if mm=0 then write(0);
for j:=mm downto 1 do
if res[j]>9 then write(chr(ord('A')+res[j]-10)) else write(res[j]);
end.
Задача D автор Савчук Владислав
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int A[600],B[600],C[600],R[600],V[20][600],LV[20],lc,la,lb,k,sys;
bool check(int ii)
{
int i,j;
for (i=0;i<=lc;++i) {
if (V[ii][LV[ii]-i]>C[i]) return true;
else if (V[ii][LV[ii]-i]<C[i]) return false; }
return false;
}
void Riz(int ii)
{
int i,j,T[500];
for (i=0;i<=lc;i++) T[i]=C[lc-i]-V[ii][i];
for (i=0;i<=lc;i++) if (T[i]<0) {T[i+1]--; T[i]+=sys;}
j=lc;
while ((T[j]==0)&&(j>0)) j--;
for (i=j;i>=0;i--) C[j-i]=T[i];
lc=j;
}
int main()
{
string s1,s2;
cin>>sys>>s1>>s2;
int i,j;
la=s1.length()-1;
for (i=0;i<=la;++i) A[i]=(int(s1[i])<65?int(s1[i])-48:int(s1[i])-55);
lb=s2.length()-1;
for (i=0;i<=lb;++i) B[i]=(int(s2[i])<65?int(s2[i])-48:int(s2[i])-55);
int t;
for (i=0;i<=lb;++i) V[1][lb-i]=B[i]; LV[1]=lb;
for (k=2;k<=sys-1;++k) {
for (i=0;i<=LV[1];++i)
{t=V[k][i]+B[LV[1]-i]*k; V[k][i+1]=t/sys; V[k][i]=t%sys;}
i=LV[1];
while (V[k][i+1]>0) {i++; V[k][i+1]+=V[k][i]/sys; V[k][i]%=sys;}
LV[k]=i;
}
lc=-1;
k=0;
while (k<=la) {
if ((C[lc]==0)&&(lc==0)&&(A[k]==0)) {C[lc]=A[k];} else
if ((C[lc]==0)&&(lc==0)) {C[lc]=A[k];} else {lc++; C[lc]=A[k];}
for (i=1;i<=sys-1;++i) {
if (LV[i]>lc) break;
if ((LV[i]==lc)&&(check(i)==true)) break;
}
i--;
R[k]=i;
if (i!=0) Riz(i);
k++;
}
j=0;
while ((R[j]==0)&&(j<la)) j++;
for (i=j;i<=la;i++) cout<<(R[i]>9?char(R[i]+55):char(R[i]+48)); cout<<endl;
}