Вітаю Вас, Гість

Авторський – Задача А

def calc(n,m):
    k=0
    while n: n//=m; k+=n
    return k

n,m=map(int,input().split())
p=set()
nn=m
for i in range(2,int(nn**0.5)+1):
  while nn%i==0: p.add(i); nn//=i
if nn>1: p.add(nn)
p=list(p)
l=[0]*len(p)
for i in range(len(p)):
  t=m
  while t%p[i]==0: l[i]+=1; t//=p[i]
s=[calc(n,p[i])//l[i] for i in range(len(p))]
print(min(s))

Авторський – Задача В

ans=[]
n=int(input())
s=[(input()+"~",i) for i in range(n)]
while True:
    mi,i=min(s)
    if mi[0]=="~": break
    ans+=[mi[0]]
    s[i]=(mi[1:],i)
print("".join(ans))

Очеретний Вячеслав  – Задача С

#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define ld long double
#define ll long long
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define inf (int)1e9
#define pi pair<int,int>
#define y1 fdfs
using namespace std;
const int md=1e9+9;
typedef vector<vector<int> > vii;
int n,ans;
vii a(100,vector<int>(100));
void add(int &a,int b)
{
    a+=b;
    if(a>=md) a-=md;
}
vii mul(vii a,vii b)
{
    vii c(a.size(),vector<int>(b[0].size()));
    for(int i=0;i<a.size();++i)
    for(int j=0;j<b[0].size();++j)
    for(int t=0;t<100;++t)
        c[i][j]=(c[i][j]+a[i][t]*1ll*b[t][j])%md;
    return c;
}
vii bin(vii a,int n)
{
    if(!n) {
            vii a(100,vector<int>(100));
            for(int i=0;i<100;++i)
                a[i][i] = 1;
            return a;
    }
    if(n&1) return mul(bin(a,n-1),a);
    vii c(100,vector<int>(100));
    c=bin(a,n>>1);
    return mul(c,c);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int d1=0;d1<10;++d1)
    for(int d2=0;d2<10;++d2)
    for(int d3=0;d3<10;++d3)
    {
        if(d3+d2==0||d2+d1==0) continue;
        if(d1==d3&&!(d1==9&&d2==9&&d3==9)) continue;
        a[d1*10+d2][d2*10+d3]=1;
    }
    a=bin(a,n-2);
    vii b(1,vector<int>(100));
    for(int i=0;i<100;++i)
        if(i<10) b[0][i]=0;else b[0][i]=1;
    b=mul(b,a);
    for(int i=0;i<100;++i)
        add(ans,b[0][i]);
    cout<<ans;
}

Очеретний Вячеслав  – Задача D

#include <bits/stdc++.h>
#define files(x) freopen(x ".in", "r", stdin); freopen(x ".out", "w", stdout);
#define all(a) (a).begin(),(a).end()
#define ld long double
#define ll long long
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define inf (int)1e9
#define pi pair<int,int>
#define y1 fdfs
using namespace std;
const int md = 1e9+7,N= 3000;
int n,a,dp[N][N+10],ans;
void add(int &a,int b)
{
    a+=b;
    if(a>=md) a%=md;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>a;
    dp[0][0+10] = 1;
    for(int i=0;i<=n;++i)
    {
        for(int j=-3;j<=i;++j){
            add(dp[i+1][j+1+10],dp[i][j+10]);
            add(dp[i+1][j-1+10],dp[i][j+10]);
        }
    }
    for(int i=1;i<=n;++i)
        add(ans,dp[n][i+10]);
    cout<<ans;
}

Авторський – Задача Е

#include <bits\stdc++.h>

using namespace std;

#define F first
#define S second

int n,m,l,r,prnt;
string s;
struct node {int cnt,prior,data; node *l,*r;int reversed;long long sum;
             node(int nom): data(nom){
                      cnt = 1;prior = rand();reversed = 0; sum = 0;l = r = NULL;}
             } ;

int getcnt(node *t){if (t) return t->cnt; else return 0;}
long long getsum(node *cur){ if (cur) return cur -> sum; else return 0;}
void change(node *cur)
{
     if (!cur) return;
     cur -> reversed = 1 - cur -> reversed;
}
void push(node *cur)
{
    if (!cur) return;
    if (cur -> reversed){
            cur -> reversed = 1 - cur->reversed;
            swap(cur -> r,cur -> l);
            change(cur -> l);
            change(cur -> r);
            }
}
node *merge(node *tl,node *tr)
{   if (!tl) return tr;
    if (!tr) return tl;
    node *ans;
    push(tl);
    push(tr);
    if (tl -> prior < tr -> prior) {tl->r = merge(tl->r,tr); ans = tl;}
     else{
           tr->l=merge(tl,tr->l);
           ans=tr;
           }
    ans -> cnt=getcnt(ans -> l)+getcnt(ans -> r) + 1;
    ans -> sum = getsum(ans -> l ) + getsum(ans -> r);

    return ans;
}
void split(node *cur,int need, node* &before,node* &after)
{
    if (!cur) {before = after = 0;return;}
    push(cur);
    if (cur -> cnt == need) { before = cur; after = 0; return;}
    if (getcnt(cur -> l) >= need) {
                   split( cur -> l ,need , before , after );
                   cur -> l = after;  after = cur;}
    else {
          split(cur -> r , need - getcnt(cur -> l) - 1 , before , after );
          cur -> r = before;  before = cur;
          }
    cur -> cnt = getcnt(cur -> l) + getcnt(cur -> r) + 1;
    cur -> sum = getsum(cur -> l) + getsum(cur -> r) + cur -> data;
}
void out(node *cur)
{
    if (!cur) return;
    push(cur);
    out(cur -> l);
    if (prnt) cout<<" "; else prnt=1;
    cout<< cur->data;
    out(cur -> r);
}
int main()
{
    cin >> n;
    node *root = new node(1);
    for (int i = 1; i < n; ++i){node *tmp = new node(i+1); root = merge(root,tmp);}
    while (cin >> l>> r){
        node *before,*ts,*after;
        split(root,r,root,after);
        split(root,l-1,before,ts);
        ts -> reversed = 1 - ts -> reversed;
        root=merge(before,ts);
        root=merge(root,after);
        }
    out(root);cout<<"\n";
}