Const Letters = ['a'..'z', 'A'..'Z']; LineEnds = [#13, #10, #0, '.']; MAX_LEN = 255; var txt: array [0..MAX_LEN] of char; bnd: array [0..MAX_LEN, 0..1] of integer; tsz, bsz: integer; // размеры массивов isLetter, isWord, f1, f2: boolean; i, j: integer; begin repeat read(txt[tsz]);
// Определение границ слов isLetter := txt[tsz] in Letters; if isLetter and not isWord then bnd[bsz, 0] := tsz; if isWord and not isLetter then begin bnd[bsz, 1] := tsz; bsz := bsz + 1; end;
isWord := isLetter; tsz := tsz + 1; until txt[tsz-1] in LineEnds;
if bsz > 1 then begin for i := 0 to bsz-2 do begin j := 0; f2 := true; f1 := (bnd[bsz-1, 1] - bnd[bsz-1, 0]) = (bnd[i, 1]-bnd[i, 0]); // совпадение длин
while (j < bnd[i, 1] - bnd[i, 0]) and f2 do begin f1 := f1 and (txt[bnd[i, 0] + j] = txt[bnd[bsz-1, 0] + j]); f2 := f2 and (LowCase(txt[bnd[i, 0] + j]) = Chr(Ord('a') + j)); j := j + 1; end;
// вывод if f2 and not f1 then begin for j := bnd[i, 0] to bnd[i, 1] - 1 do write(txt[j]); writeln; end; end; end; end.
Letters = ['a'..'z', 'A'..'Z'];
LineEnds = [#13, #10, #0, '.'];
MAX_LEN = 255;
var
txt: array [0..MAX_LEN] of char;
bnd: array [0..MAX_LEN, 0..1] of integer;
tsz, bsz: integer; // размеры массивов
isLetter, isWord, f1, f2: boolean;
i, j: integer;
begin
repeat
read(txt[tsz]);
// Определение границ слов
isLetter := txt[tsz] in Letters;
if isLetter and not isWord then
bnd[bsz, 0] := tsz;
if isWord and not isLetter then begin
bnd[bsz, 1] := tsz;
bsz := bsz + 1;
end;
isWord := isLetter;
tsz := tsz + 1;
until txt[tsz-1] in LineEnds;
if bsz > 1 then begin
for i := 0 to bsz-2 do begin
j := 0; f2 := true;
f1 := (bnd[bsz-1, 1] - bnd[bsz-1, 0]) = (bnd[i, 1]-bnd[i, 0]); // совпадение длин
while (j < bnd[i, 1] - bnd[i, 0]) and f2 do begin
f1 := f1 and (txt[bnd[i, 0] + j] = txt[bnd[bsz-1, 0] + j]);
f2 := f2 and (LowCase(txt[bnd[i, 0] + j]) = Chr(Ord('a') + j));
j := j + 1;
end;
// вывод
if f2 and not f1 then begin
for j := bnd[i, 0] to bnd[i, 1] - 1 do
write(txt[j]);
writeln;
end;
end;
end;
end.
#include <iostream>
typedef long long ll;
using namespace std;
bool ll_is_valid(ll t, ll N, ll x, ll y)
{
return t / x + (t - x) / y >= N;
}
ll f(ll N, ll x, ll y)
{
ll R = 1;
while (!ll_is_valid(R,N,x,y)) R *= 2;
ll L = R / 2;
while(R - L > 1)
{
ll M = (L + R) / 2;
if (!ll_is_valid(M,N,x,y)) {L = M;}
else {R = M;}
}
return R;
}
int main()
{
ll N,x,y;
cin >> N >> x >> y;
if(x > y) swap( x, y );
cout << f(N, x, y) << std::endl;
}