Задача B автор Сорока Дмитро
program zad2;
{$APPTYPE CONSOLE}
var s,n:extended;
begin
read(s);
write(trunc((-1+sqrt(1+8*s))/2));
end.
Задача C автор Шумейко Максим
#include<iostream>
using namespace std;
unsigned long long gcd (unsigned long long a, unsigned long long b)
{
while(b) b^=a^=b^=a%=b;
return a;
}
int main ()
{
unsigned long long n,m;
cin>>n>>m;
cout<<gcd(n,m);
}
Задача D автор Шевчук Олександр
var f:Text;
n,m,k:int64;
i:longint;
b:array[1..600]of boolean;
q:array[1..10]of longint;
a:array[1..600]of int64;
function kil(t:int64):int64;
var i,j,e,l,y:longint;
r:int64;
begin
b[1]:=true;
a[1]:=t;
e:=2;
r:=t;
y:=1;
for i:=1 to k do
begin
l:=1;
while l<=y do
begin
a[e]:=a[l] div q[i];
b[e]:=not b[l];
if b[e]=true then inc(r,a[e]) else dec(r,a[e]);
inc(e);
inc(l);
end;
y:=y*2;
end;
kil:=r;
end;
begin
assign(f,'prosto.in');
reset(f);
read(f,n,m);
read(f,k);
for i:=1 to k do
read(f,q[i]);
close(f);
writeln(kil(m)-kil(n-1));
end.
Задача E автор Глембоцький Владислав
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <memory.h>
#include <list>
#include <ctime>
using namespace std;
const long long inf = 1e9+7;
const long long mod = 1e9+7;
const double eps = 1e-9;
const double PI = 2*acos(0.0);
const double E = 2.71828;
typedef long long ll ;
typedef double ld ;
const ll MaxN = 4LL * 4LL * 100005LL ;
struct event {
ll x,y,Y,good ;
friend bool operator < (event a, event b) {
return a.x < b.x || (a.x == b.x && a.good < b.good) ;
}
} v[MaxN / 4] ;
ll t[MaxN] , tadd[MaxN] ;
ll Max(ll pos,ll l,ll r,ll left, ll right) {
if(l > right || r < left) return 0 ;
if(l <= left && r >= right) return t[pos] + tadd[pos] ;
tadd[pos*2] += tadd[pos] ;
tadd[pos*2+1] += tadd[pos] ;
tadd[pos] = 0 ;
ll mid = ( left + right ) / 2 ;
ll r1 = Max(pos*2,l,r,left,mid) ;
ll r2 = Max(pos*2+1,l,r,mid+1,right) ;
return max(r1,r2) ;
}
void up(ll pos,ll l,ll r,ll left,ll right,ll value) {
if(l > right || r < left) return ;
if(l <= left && r >= right) {
tadd[pos] += value ;
return ;
}
tadd[pos*2] += tadd[pos] ;
tadd[pos*2+1] += tadd[pos] ;
tadd[pos] = 0 ;
ll mid = ( left + right ) / 2 ;
up(pos*2,l,r,left,mid,value) ;
up(pos*2+1,l,r,mid+1,right,value) ;
t[pos] = max(t[pos*2] + tadd[pos*2] , t[pos*2+1] + tadd[pos*2+1]) ;
}
int main(void) {
freopen("windows.in","rt",stdin);
ll n ;
cin >> n ;
ll size = 0 ;
for(int i=0;i<n;i++) {
ll x,y,X,Y ;
cin >> x >> y >> X >> Y ;
if(x > X) swap(x,X) ;
if(y > Y) swap(y,Y) ;
x += 200000LL ;
y += 200000LL ;
X += 200000LL ;
Y += 200000LL ;
v[size++] = {x,y,Y,0} ;
v[size++] = {X,y,Y,1} ;
}
sort(v,v+size) ; ll rez = 0 ;
for(int i=0;i<size;i++) {
ll x,y,Y,good ;
x = v[i].x ; y = v[i].y ; Y = v[i].Y ; good = v[i].good ;
if( !good ) {
up(1LL,y,Y,0LL,400005LL,1LL) ;
rez = max(Max(1LL,0LL,400005LL,0LL,400005LL),rez) ;
} else {
up(1LL,y,Y,0LL,400005LL,-1LL) ;
}
}
cout << rez << endl ;
return 0 ;
}
Задача F автор Сорока Дмитро
program zad6;
{$APPTYPE CONSOLE}
uses SysUtils,math;
var s:ansistring;
n,i,j,l,r,k:longint;
d1,d2:array[1..200000]of longint;
ans:int64;
begin
assign(input,'palind.in');reset(input);
read(s);
n:=length(s);
fillchar(d1,sizeof(d1),0);
fillchar(d2,sizeof(d2),0);
l:=1; r:=0;
for i:=2 to n do
begin
if i>r then k:=1 else k:=min(d1[l+r-i],r-i)+1;
while (i+k<=n)and(i-k>0)and(s[i+k]=s[i-k]) do inc(k);dec(k);
d1[i]:=k;
if i+k>r then
begin
l:=i-k;
r:=i+k;
end;
end;
l:=1; r:=0;
for i:=1 to n do
begin
if i>r then k:=1 else k:=min(d2[l+r-i+1],r-i+1)+1;
while (i+k-1<=n)and(i-k>0)and(s[i+k-1]=s[i-k]) do inc(k);dec(k);
d2[i]:=k;
if i+k-1>r then
begin
l:=i-k;
r:=i+k-1;
end;
end;
ans:=0;
for i:=1 to n do ans:=ans+d1[i]+d2[i];
write(ans);
close(input);
end.