From 7de121c4b4ef888a0d1990c27144a7f9dd8c5f94 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sun, 6 Nov 2016 11:13:14 +0700 Subject: Thêm đề HSG 12 huyện Vĩnh Tường, Vĩnh Phúc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.md" | 72 +++++++++++++++++ .../cau1.c" | 20 +++++ .../cau2.c" | 39 +++++++++ .../cau3.c" | 40 +++++++++ .../cau4.c" | 26 ++++++ 12/TP-2008/R1/.BL4.pas.swp | Bin 12288 -> 0 bytes 12/TP-2008/R1/BL1.PAS | 26 ------ 12/TP-2008/R1/BL2.PAS | 57 ------------- 12/TP-2008/R1/BL3.PAS | 45 ----------- 12/TP-2008/R1/BL4.pas | 26 ------ 12/TP-2008/R1/CLB.IN | 4 - 12/TP-2008/R1/CLB.OU | 0 12/TP-2008/R1/R1.DOC | Bin 79872 -> 0 bytes 12/TP-2008/R2/.DG.pas.swp | Bin 12288 -> 0 bytes 12/TP-2008/R2/DG | Bin 133348 -> 0 bytes 12/TP-2008/R2/DG.INP | 6 -- 12/TP-2008/R2/DG.OUT | 1 - 12/TP-2008/R2/DG.o | Bin 9392 -> 0 bytes 12/TP-2008/R2/DG.pas | 83 ------------------- 12/TP-2008/R2/HC.pas | 23 ------ 12/TP-2008/R2/R2.doc | Bin 64512 -> 0 bytes 12/TP-2008/R2/TBC.PAS | 69 ---------------- 12/TP-2009/R1/BTN.PAS | 87 -------------------- 12/TP-2009/R1/HEXA.PAS | 75 ----------------- 12/TP-2009/R1/PS.PAS | 80 ------------------ 12/TP-2009/R1/R1.pdf | Bin 65142 -> 0 bytes 12/TP-2009/R2/BAI1.PAS | 90 --------------------- 12/TP-2009/R2/BAI3.PAS | 87 -------------------- 12/TP-2009/R2/R2.pdf | Bin 103168 -> 0 bytes 12/TP-2010/BAI1.PAS | 30 ------- 12/TP-2010/BAI2.PAS | 40 --------- 12/TP-2010/BAI3 | Bin 132580 -> 0 bytes 12/TP-2010/BAI3.INP | 1 - 12/TP-2010/BAI3.OUT | 0 12/TP-2010/BAI3.o | Bin 4344 -> 0 bytes 12/TP-2010/BAI3.pas | 73 ----------------- 12/TP-2010/README.md | 1 - 12/TP-2010/TP-2010.png | Bin 1251665 -> 0 bytes 12/TP-2010/_BAI3.pas | 73 ----------------- 12/TP-HN-2008/R1/BL1.PAS | 26 ++++++ 12/TP-HN-2008/R1/BL2.PAS | 57 +++++++++++++ 12/TP-HN-2008/R1/BL3.PAS | 45 +++++++++++ 12/TP-HN-2008/R1/BL4.pas | 26 ++++++ 12/TP-HN-2008/R1/CLB.IN | 4 + 12/TP-HN-2008/R1/CLB.OU | 0 12/TP-HN-2008/R1/R1.DOC | Bin 0 -> 79872 bytes 12/TP-HN-2008/R2/DG | Bin 0 -> 133348 bytes 12/TP-HN-2008/R2/DG.INP | 6 ++ 12/TP-HN-2008/R2/DG.OUT | 1 + 12/TP-HN-2008/R2/DG.o | Bin 0 -> 9392 bytes 12/TP-HN-2008/R2/DG.pas | 83 +++++++++++++++++++ 12/TP-HN-2008/R2/HC.pas | 23 ++++++ 12/TP-HN-2008/R2/R2.doc | Bin 0 -> 64512 bytes 12/TP-HN-2008/R2/TBC.PAS | 69 ++++++++++++++++ 12/TP-HN-2009/R1/BTN.PAS | 87 ++++++++++++++++++++ 12/TP-HN-2009/R1/HEXA.PAS | 75 +++++++++++++++++ 12/TP-HN-2009/R1/PS.PAS | 80 ++++++++++++++++++ 12/TP-HN-2009/R1/R1.pdf | Bin 0 -> 65142 bytes 12/TP-HN-2009/R2/BAI1.PAS | 90 +++++++++++++++++++++ 12/TP-HN-2009/R2/BAI3.PAS | 87 ++++++++++++++++++++ 12/TP-HN-2009/R2/R2.pdf | Bin 0 -> 103168 bytes 12/TP-HN-2010/BAI1.PAS | 30 +++++++ 12/TP-HN-2010/BAI2.PAS | 40 +++++++++ 12/TP-HN-2010/BAI3 | Bin 0 -> 132580 bytes 12/TP-HN-2010/BAI3.INP | 1 + 12/TP-HN-2010/BAI3.OUT | 0 12/TP-HN-2010/BAI3.o | Bin 0 -> 4344 bytes 12/TP-HN-2010/BAI3.pas | 73 +++++++++++++++++ 12/TP-HN-2010/README.md | 1 + 12/TP-HN-2010/TP-2010.png | Bin 0 -> 1251665 bytes 12/TP-HN-2010/_BAI3.pas | 73 +++++++++++++++++ 71 files changed, 1174 insertions(+), 977 deletions(-) create mode 100644 "12/Q-V\304\251nhT\306\260\341\273\235ng-2006/README.md" create mode 100644 "12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau1.c" create mode 100644 "12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau2.c" create mode 100644 "12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau3.c" create mode 100644 "12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau4.c" delete mode 100755 12/TP-2008/R1/.BL4.pas.swp delete mode 100755 12/TP-2008/R1/BL1.PAS delete mode 100755 12/TP-2008/R1/BL2.PAS delete mode 100755 12/TP-2008/R1/BL3.PAS delete mode 100755 12/TP-2008/R1/BL4.pas delete mode 100755 12/TP-2008/R1/CLB.IN delete mode 100755 12/TP-2008/R1/CLB.OU delete mode 100755 12/TP-2008/R1/R1.DOC delete mode 100644 12/TP-2008/R2/.DG.pas.swp delete mode 100755 12/TP-2008/R2/DG delete mode 100755 12/TP-2008/R2/DG.INP delete mode 100755 12/TP-2008/R2/DG.OUT delete mode 100755 12/TP-2008/R2/DG.o delete mode 100755 12/TP-2008/R2/DG.pas delete mode 100644 12/TP-2008/R2/HC.pas delete mode 100755 12/TP-2008/R2/R2.doc delete mode 100755 12/TP-2008/R2/TBC.PAS delete mode 100755 12/TP-2009/R1/BTN.PAS delete mode 100755 12/TP-2009/R1/HEXA.PAS delete mode 100755 12/TP-2009/R1/PS.PAS delete mode 100755 12/TP-2009/R1/R1.pdf delete mode 100755 12/TP-2009/R2/BAI1.PAS delete mode 100755 12/TP-2009/R2/BAI3.PAS delete mode 100755 12/TP-2009/R2/R2.pdf delete mode 100755 12/TP-2010/BAI1.PAS delete mode 100755 12/TP-2010/BAI2.PAS delete mode 100755 12/TP-2010/BAI3 delete mode 100755 12/TP-2010/BAI3.INP delete mode 100755 12/TP-2010/BAI3.OUT delete mode 100755 12/TP-2010/BAI3.o delete mode 100755 12/TP-2010/BAI3.pas delete mode 100644 12/TP-2010/README.md delete mode 100755 12/TP-2010/TP-2010.png delete mode 100644 12/TP-2010/_BAI3.pas create mode 100755 12/TP-HN-2008/R1/BL1.PAS create mode 100755 12/TP-HN-2008/R1/BL2.PAS create mode 100755 12/TP-HN-2008/R1/BL3.PAS create mode 100755 12/TP-HN-2008/R1/BL4.pas create mode 100755 12/TP-HN-2008/R1/CLB.IN create mode 100755 12/TP-HN-2008/R1/CLB.OU create mode 100755 12/TP-HN-2008/R1/R1.DOC create mode 100755 12/TP-HN-2008/R2/DG create mode 100755 12/TP-HN-2008/R2/DG.INP create mode 100755 12/TP-HN-2008/R2/DG.OUT create mode 100755 12/TP-HN-2008/R2/DG.o create mode 100755 12/TP-HN-2008/R2/DG.pas create mode 100644 12/TP-HN-2008/R2/HC.pas create mode 100755 12/TP-HN-2008/R2/R2.doc create mode 100755 12/TP-HN-2008/R2/TBC.PAS create mode 100755 12/TP-HN-2009/R1/BTN.PAS create mode 100755 12/TP-HN-2009/R1/HEXA.PAS create mode 100755 12/TP-HN-2009/R1/PS.PAS create mode 100755 12/TP-HN-2009/R1/R1.pdf create mode 100755 12/TP-HN-2009/R2/BAI1.PAS create mode 100755 12/TP-HN-2009/R2/BAI3.PAS create mode 100755 12/TP-HN-2009/R2/R2.pdf create mode 100755 12/TP-HN-2010/BAI1.PAS create mode 100755 12/TP-HN-2010/BAI2.PAS create mode 100755 12/TP-HN-2010/BAI3 create mode 100755 12/TP-HN-2010/BAI3.INP create mode 100755 12/TP-HN-2010/BAI3.OUT create mode 100755 12/TP-HN-2010/BAI3.o create mode 100755 12/TP-HN-2010/BAI3.pas create mode 100644 12/TP-HN-2010/README.md create mode 100755 12/TP-HN-2010/TP-2010.png create mode 100644 12/TP-HN-2010/_BAI3.pas (limited to '12') diff --git "a/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/README.md" "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/README.md" new file mode 100644 index 0000000..a4c8dad --- /dev/null +++ "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/README.md" @@ -0,0 +1,72 @@ +# ĐỀ THI HSG LỚP 12 HUYỆN VĨNH TƯỜNG NĂM HỌC 2006-2007 + +Môn: Tin học +Thời gian: 150 phút (không kể thời gian giao đề). + +## Câu 1 (5 điểm) + +Nhập vào một số nhị phân có `n` chữ số (`n` < 100). Hãy in ra số dư khi chia số +đó cho 3. + +Ví dụ: + +n | Số nhị phân | Kết quả +-- | --------------- | ------- +3 | 101 | 2 +8 | 10100111 | 2 +12 | 100000001101 | 0 +14 | 11001111101110 | 1 +6 | 111111 | 0 +15 | 111111111111110 | 0 + +## Câu 2 (4 điểm) + +Nhập vào số nguyên dương `n`. Hãy in ra số nguyên tố nhỏ nhất lớn hơn `n`. + +Ví dụ: + + n | Kết quả +---- | ------- +10 | 11 +7 | 11 +44 | 47 +992 | 997 +2332 | 2333 + +## Câu 3 (8 điểm) + +Nhập vào từ số nguyên dương `n` (`n` < 1000). + +1. Phân tích `n` thành tích các thừa số nguyên tố. +2. Tìm các số tự nhiên nhỏ hơn hoặc bằng `n` mà sau khi làm phép phân tích ở + phần 1 có nhiều nhân tử nhất. + +Ví dụ: + + n | Kết quả +--- | ------- +9 | 3 3 + | 8 +15 | 3 5 + | 8 12 +21 | 3 7 + | 16 +70 | 2 5 7 + | 64 +150 | 2 3 5 5 + | 128 + +## Câu 4 + +Nhập vào một mảng gồm `n` (`n` < 20) số nguyên dương. Hãy đếm xem trong mảng có +bao nhiêu số bậc thang. Biết một số được gọi là số bậc thang nếu biểu diễn thập +phân của nó có nhiều hơn một chữ số đồng thời theo chiều từ trái qua phải, chữ +số đứng sau không nhỏ hơn chữ số đứng trước. + +Ví dụ: + +n | Dãy số | Kết quả +- | ------------------------ | ------- +7 | 1 4 7 5 8 9 3 | 0 +5 | 123 102 10023 9 21 | 1 +6 | 115 110 11112 31 14 1109 | 3 diff --git "a/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau1.c" "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau1.c" new file mode 100644 index 0000000..173e7c2 --- /dev/null +++ "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau1.c" @@ -0,0 +1,20 @@ +#include +#include + +int main() +{ + char b[100], i; + short a = 0; + + scanf("%s", b); + + for (i = strlen(b) - 1; i >= 0; i -= 2) + a += b[i] - 48; + + for (i = strlen(b) - 2; i >= 0; i -= 2) + a += b[i] * 2 - 96; + + printf("%d\n", a % 3); + + return 0; +} diff --git "a/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau2.c" "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau2.c" new file mode 100644 index 0000000..4ad1c3b --- /dev/null +++ "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau2.c" @@ -0,0 +1,39 @@ +#include +#include + +char prime(unsigned long long m) +{ + unsigned long i; + + for (i = 3; i <= sqrt(m); i += 2) + if (m % i == 0) + return 0; + + return 1; +} + +int main() +{ + unsigned long long n, i; + + scanf("%lld", &n); + + if (n == 1) { + puts("2"); + + return 0; + } + + i = (n % 2) ? n : n - 1; + + while (i <= 18446744073709551615ULL) { + i += 2; + + if (!prime(i)) + continue; + + printf("%lld\n", i); + + return 0; + } +} diff --git "a/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau3.c" "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau3.c" new file mode 100644 index 0000000..136f154 --- /dev/null +++ "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau3.c" @@ -0,0 +1,40 @@ +#include +#include + +const char PRIMES[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}; + +int main() +{ + char i; + short n, n0; + + scanf("%hd", &n); + + if (n < 2) { + printf("\n%hd\n", n); + + return 0; + } + + n0 = n; + + for (i = 0; i < 11; i++) + while (n0 % PRIMES[i] == 0) { + n0 /= PRIMES[i]; + printf("%hd ", PRIMES[i]); + } + + if (n0 - 1) + printf("%hd\n", n0); + else + putchar(10); + + n0 = pow(2, (int) log2(n) - 1); + + if (n0 * 3 > n) + printf("%hd\n", n0 * 2); + else + printf("%hd %hd\n", n0 * 2, n0 * 3); + + return 0; +} diff --git "a/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau4.c" "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau4.c" new file mode 100644 index 0000000..d971927 --- /dev/null +++ "b/12/Q-V\304\251nhT\306\260\341\273\235ng-2006/cau4.c" @@ -0,0 +1,26 @@ +#include +#include + +int main() +{ + char n, count = 0, s[21], c, i; + unsigned long long m; + + for (n = 1; n < 20 && scanf("%lld", &m) != EOF; n++) { + if (m < 10) + continue; + + sprintf(s, "%lld", m); + c = s[0]; + + for (i = 1; i < strlen(s) && c; i++) + c = (c > s[i]) ? 0 : s[i]; + + if (c) + count++; + } + + printf("%hhd\n", count); + + return 0; +} diff --git a/12/TP-2008/R1/.BL4.pas.swp b/12/TP-2008/R1/.BL4.pas.swp deleted file mode 100755 index 013c8d2..0000000 Binary files a/12/TP-2008/R1/.BL4.pas.swp and /dev/null differ diff --git a/12/TP-2008/R1/BL1.PAS b/12/TP-2008/R1/BL1.PAS deleted file mode 100755 index 6931b1b..0000000 --- a/12/TP-2008/R1/BL1.PAS +++ /dev/null @@ -1,26 +0,0 @@ -uses math; - -var - f : text; - m, n, i : byte; - a, b : double; -j -begin - assign(f, 'LT.IN'); - reset(f); - read(f, n, m); - close(f); - a := 1; - for i := 1 to n do - a := a * 2; - b := 1; - for i := 1 to m do - b := b * 3; - a := a + b; - for i := 1 to trunc(log10(a)) do - a := a / 10; - assign(f, 'LT.OU'); - rewrite(f); - writeln(f, trunc(a)); - close(f) -end. diff --git a/12/TP-2008/R1/BL2.PAS b/12/TP-2008/R1/BL2.PAS deleted file mode 100755 index e228240..0000000 --- a/12/TP-2008/R1/BL2.PAS +++ /dev/null @@ -1,57 +0,0 @@ -type - rect = record - a : longint; - b : longint - end; - arec = array of rect; - -var - f : text; - c, d, e : rect; - -function join(g, h : rect) : arec; - var n : byte = 0; - procedure j01n(p, q : longint); - begin - inc(n); - setlength(join, n); - join[n - 1].a := p; - join[n - 1].b := q - end; - begin - if g.a = h.a then j01n(g.a, g.b + h.b); - if g.a = h.b then j01n(g.a, g.b + h.a); - if g.b = h.a then j01n(g.b, g.a + h.b); - if g.b = h.b then j01n(g.b, g.a + h.a); - end; - -procedure out(m : longint); - begin - assign(f, 'GH.OU'); - rewrite(f); - writeln(f, m); - close(f); - halt - end; - -procedure libl2(x, y, z : rect); - var i, j : rect; - begin - for i in join(x, y) do - for j in join(z, i) do - if (j.a = j.b) and (j.a <> 0) then - out(j.a) - end; - -begin - assign(f, 'GH.IN'); - reset(f); - readln(f, c.a, c.b); - readln(f, d.a, d.b); - readln(f, e.a, e.b); - close(f); - libl2(c, d, e); - libl2(d, e, c); - libl2(e, c, d); - out(0) -end. diff --git a/12/TP-2008/R1/BL3.PAS b/12/TP-2008/R1/BL3.PAS deleted file mode 100755 index a49b4d6..0000000 --- a/12/TP-2008/R1/BL3.PAS +++ /dev/null @@ -1,45 +0,0 @@ -type ar = array[0..3] of longint; - -var - f : text; - m, n, i, j : shortint; - a : array[1..101, -1..102] of longint; - tmp, max : longint; - -function next(x, y : shortint) : ar; - begin - next[0] := a[x + 1, y - 2]; - next[1] := a[x + 1, y + 2]; - next[2] := a[x + 2, y - 1]; - next[3] := a[x + 2, y + 1] - end; - -begin - for i := 1 to 101 do - for j := -1 to 102 do - a[i, j] := 0; - assign(f, 'QM.IN'); - reset(f); - readln(f, m, n); - for i := 1 to m do - for j := 1 to n do - read(f, a[i, j]); - close(f); - for i := m - 1 downto 1 do - for j := 1 to n do - begin - max := 0; - for tmp in next(i, j) do - if tmp > max then - max := tmp; - a[i, j] := a[i, j] + max; - end; - assign(f, 'QM.OU'); - rewrite(f); - max := 0; - for i := 1 to n do - if a[1, i] > max then - max := a[1, i]; - writeln(f, max); - close(f); -end. diff --git a/12/TP-2008/R1/BL4.pas b/12/TP-2008/R1/BL4.pas deleted file mode 100755 index 94dd3ba..0000000 --- a/12/TP-2008/R1/BL4.pas +++ /dev/null @@ -1,26 +0,0 @@ -var - f : text; - n : word; - a, b : array of longword; - tmp0, tmp1 : longword; - -procedure ins(var l : array of longword; x : longword); - begin - setlength(l, length(l) + 1); - l[length(l) - 1] := x - end; - -begin - setlength(a, 0); - setlength(b, 0); - assign(f, 'CLB.IN'); - reset(f); - readln(f, n); - for i := 1 to n do - begin - readln(f, tmp0, tmp1); - ins(a, tmp0); - ins(b, tmp1) - end; - close(f); - diff --git a/12/TP-2008/R1/CLB.IN b/12/TP-2008/R1/CLB.IN deleted file mode 100755 index 662c775..0000000 --- a/12/TP-2008/R1/CLB.IN +++ /dev/null @@ -1,4 +0,0 @@ -3 -7 9 -3 8 -10 20 diff --git a/12/TP-2008/R1/CLB.OU b/12/TP-2008/R1/CLB.OU deleted file mode 100755 index e69de29..0000000 diff --git a/12/TP-2008/R1/R1.DOC b/12/TP-2008/R1/R1.DOC deleted file mode 100755 index 5e29da2..0000000 Binary files a/12/TP-2008/R1/R1.DOC and /dev/null differ diff --git a/12/TP-2008/R2/.DG.pas.swp b/12/TP-2008/R2/.DG.pas.swp deleted file mode 100644 index 7227844..0000000 Binary files a/12/TP-2008/R2/.DG.pas.swp and /dev/null differ diff --git a/12/TP-2008/R2/DG b/12/TP-2008/R2/DG deleted file mode 100755 index ad902a1..0000000 Binary files a/12/TP-2008/R2/DG and /dev/null differ diff --git a/12/TP-2008/R2/DG.INP b/12/TP-2008/R2/DG.INP deleted file mode 100755 index fb3ca57..0000000 --- a/12/TP-2008/R2/DG.INP +++ /dev/null @@ -1,6 +0,0 @@ -4 -0 1 -1 0 -0 -1 --1 0 --2 0 0 0 diff --git a/12/TP-2008/R2/DG.OUT b/12/TP-2008/R2/DG.OUT deleted file mode 100755 index c227083..0000000 --- a/12/TP-2008/R2/DG.OUT +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file diff --git a/12/TP-2008/R2/DG.o b/12/TP-2008/R2/DG.o deleted file mode 100755 index cf2e3e1..0000000 Binary files a/12/TP-2008/R2/DG.o and /dev/null differ diff --git a/12/TP-2008/R2/DG.pas b/12/TP-2008/R2/DG.pas deleted file mode 100755 index 2313685..0000000 --- a/12/TP-2008/R2/DG.pas +++ /dev/null @@ -1,83 +0,0 @@ -type bigboo = [-1..1]; - -var - f : text; - n, i, j : byte; - inp : array[0..100] of PointType; - P, Q : PointType; - P_out, Q_out : boolean; - s : int64 = 0; - -function stri2(A, B, C : PointType) : int64; - begin - stri2 := (C.y - A.y) * (A.x - B.x) - (C.x - A.x) * (A.y - B.y) - end; - -function outpoly(M : PointType) : int64; - begin - outpoly := s; - for i := 0 to n - 1 do - begin - outpoly := outpoly - abs(stri2(M, inp[i], inp[i + 1])) - end - end; - -function sign(x : smallint) : bigboo; - begin - case true of - x > 0 : exit(1); - x = 0 : exit(0); - x < 0 : exit(-1) - end - end; - -function intersect(A, B : PointType) : bigboo; - var b00, b01 : bigboo; - begin - b00 := sign(stri2(P, Q, A)); - b01 := sign(stri2(P, Q, A)); - if b00 = b01 then - if b00 = 0 then exit(0) - else exit(-1); - b00 := sign(stri2(A, B, P)); - b01 := sign(stri2(A, B, Q)); - if b00 = b01 then - if b00 = 0 then exit(0) - else exit(-1); - exit(1) - end; - -function lensqr(A, B : PointType) : int64; - begin - exit() - end; - -procedure out(M, N : PointType); - begin - assign(f, 'DG.OUT'); - rewrite(f); - write(f, trunc(sqrt(sqr(A.x - B.x) + sqr(A.y - B.y)) * 100)); - close(f); - halt - end; - -begin - assign(f, 'DG.INP'); - reset(f); - readln(f, n); - for i := 0 to n - 1 do - readln(f, inp[i].x, inp[i].y); - inp[n] := inp[0]; - readln(f, P.x, P.y, Q.x, Q.y); - close(f); - for i := 1 to n - 2 do - s := s + abs(stri2(inp[0], inp[i], inp[i + 1])); - if outpoly(P) = 0 then - P_out := false; - if outpoly(Q) = 0 then - Q_out := false; - if P_out and Q_out then - for i := 0 to n - 1 do - - out(P, Q) -end. diff --git a/12/TP-2008/R2/HC.pas b/12/TP-2008/R2/HC.pas deleted file mode 100644 index 8e6b182..0000000 --- a/12/TP-2008/R2/HC.pas +++ /dev/null @@ -1,23 +0,0 @@ -var - f : text; - m, n, i, j : byte; - a : array[1..200, 0..200] of smallint; - -function out - -begin - assign(f, 'HC.INP'); - reset(f); - readln(f, m, n); - for i := 1 to m do - begin - a[i, 0] := 0; - for j := 1 to n do - read(f, a[i, j]) - end; - close(f); - assign(f, 'HC.OUT'); - rewrite(f); - writeln(f, out(a)); - close(f) -end; diff --git a/12/TP-2008/R2/R2.doc b/12/TP-2008/R2/R2.doc deleted file mode 100755 index c804058..0000000 Binary files a/12/TP-2008/R2/R2.doc and /dev/null differ diff --git a/12/TP-2008/R2/TBC.PAS b/12/TP-2008/R2/TBC.PAS deleted file mode 100755 index 1a26a91..0000000 --- a/12/TP-2008/R2/TBC.PAS +++ /dev/null @@ -1,69 +0,0 @@ -var - f : text; - i, l, m, n : integer; - a : array[1..1000] of longint; - -procedure qsort(l, h : integer); - var - i, j : integer; - x, tmp : longint; - begin - i := l; - j := h; - x := a[(i + j) div 2]; - repeat - while a[i] < x do inc(i); - while x < a[j] do dec(j); - if i <= j then - begin - tmp := a[i]; - a[i] := a[j]; - a[j] := tmp; - inc(i); - dec(j) - end - until i > j; - if l < j then qsort(l, j); - if i < h then qsort(i, h) - end; - -function biin(n0 : integer) : boolean; - var l, h, m : integer; - begin - l := 1; - h := n; - repeat - m := (l + h) div 2; - if a[m] = n0 then exit(true); - if a[m] < n0 then l := m + 1 - else h := m - 1 - until l > h; - biin := false - end; - -function libtbc(n0 : integer) : boolean; - var i, j : integer; - begin - for i := 1 to n0 - 1 do - for j := n0 + 1 to n do - if biin(a[n0] * 3 - a[i] - a[j]) then - exit(true); - libtbc := false - end; - -begin - assign(f, 'TBC.INP'); - reset(f); - readln(f, n); - for i := 1 to n do readln(f, a[i]); - close(f); - qsort(1, n); - m := 0; - for l := 2 to n - 1 do - if libtbc(l) then - inc(m); - assign(f, 'TBC.OUT'); - rewrite(f); - writeln(f, m); - close(f) -end. diff --git a/12/TP-2009/R1/BTN.PAS b/12/TP-2009/R1/BTN.PAS deleted file mode 100755 index dbb022d..0000000 --- a/12/TP-2009/R1/BTN.PAS +++ /dev/null @@ -1,87 +0,0 @@ -type sni = record - s : ansistring; - n : integer -end; - -var - f : text; - s : ansistring; - op, cl : integer; - c : char; - -function cal(s : ansistring) : integer; - var - c : char; - tmp : integer = 0; - begin - cal := 0; - for c in s do - if c = '(' then - begin - inc(tmp); - if tmp > cal then - cal := tmp - end - else - begin - dec(tmp); - if tmp < 0 then exit(0) - end; - if tmp <> 0 then - exit(0) - end; - -function rplc( - s : ansistring; - c : char; - idx : integer -) : ansistring; - begin - exit(copy(s, 1, idx - 1) + c + copy(s, idx + 1, length(s) - idx + 1)) - end; - -function libtn( - s : ansistring; - op, cl, idx : integer -) : sni; - var - i : integer; - v0, v1 : sni; - begin - if (op = 0) and (cl = 0) then - begin - libtn.s := s; - libtn.n := cal(s); - exit - end; - i := idx; - while s[i] <> '?' do - inc(i); - if op = 0 then - exit(libtn(rplc(s, ')', i), 0, cl - 1, i + 1)); - if cl = 0 then - exit(libtn(rplc(s, '(', i), op - 1, 0, i + 1)); - v0 := libtn(rplc(s, '(', i), op - 1, cl, i + 1); - v1 := libtn(rplc(s, ')', i), op, cl - 1, i + 1); - if v0.n > v1.n then - exit(v0) - else exit(v1) - end; - -begin - assign(f, 'BTN.INP'); - reset(f); - read(f, s); - close(f); - op := length(s) div 2; - cl := length(s) div 2; - for c in s do - if c = '(' then - dec(op) - else if c = ')' then - dec(cl); - assign(f, 'BTN.OUT'); - rewrite(f); - writeln(f, libtn(s, op, cl, 1).s); - close(f) -end. diff --git a/12/TP-2009/R1/HEXA.PAS b/12/TP-2009/R1/HEXA.PAS deleted file mode 100755 index a2fd6ca..0000000 --- a/12/TP-2009/R1/HEXA.PAS +++ /dev/null @@ -1,75 +0,0 @@ -var - f : text; - n, n0, m, i, j, tmp : longint; - s : string; - -function dec2hex(deca : longint) : string; - var - a : array[0..7] of byte; - i, j : byte; - begin - dec2hex := ''; - i := 0; - while deca > 0 do - begin - a[i] := deca mod 16; - deca := deca div 16; - inc(i) - end; - dec(i); - for j := i downto 0 do - case a[j] of - 0 : dec2hex := dec2hex + '0'; - 1 : dec2hex := dec2hex + '1'; - 2 : dec2hex := dec2hex + '2'; - 3 : dec2hex := dec2hex + '3'; - 4 : dec2hex := dec2hex + '4'; - 5 : dec2hex := dec2hex + '5'; - 6 : dec2hex := dec2hex + '6'; - 7 : dec2hex := dec2hex + '7'; - 8 : dec2hex := dec2hex + '8'; - 9 : dec2hex := dec2hex + '9'; - 10 : dec2hex := dec2hex + 'A'; - 11 : dec2hex := dec2hex + 'B'; - 12 : dec2hex := dec2hex + 'C'; - 13 : dec2hex := dec2hex + 'D'; - 14 : dec2hex := dec2hex + 'E'; - 15 : dec2hex := dec2hex + 'F' - end - end; - -begin - assign(f, 'HEXA.INP'); - reset(f); - read(f, n); - close(f); - m := n; - i := 0; - while m > 0 do - begin - inc(i); - tmp := 1; - for j := 1 to i - 1 do tmp := tmp * 16; - m := m + i * (tmp - tmp * 16) - end; - m := i; - for i := 1 to m - 1 do - begin - tmp := 1; - for j := 1 to i - 1 do tmp := tmp * 16; - n := n + i * (tmp - tmp * 16) - end; - n0 := (n + m - 1) div m; - for i := 1 to m - 1 do - begin - tmp := 1; - for j := 1 to i - 1 do tmp := tmp * 16; - n0 := n0 + tmp * 16 - tmp - end; - s := dec2hex(n0); - if n mod m > 0 then m := n mod m; - assign(f, 'HEXA.OUT'); - rewrite(f); - writeln(f, s[m]); - close(f) -end. diff --git a/12/TP-2009/R1/PS.PAS b/12/TP-2009/R1/PS.PAS deleted file mode 100755 index 6cf2d09..0000000 --- a/12/TP-2009/R1/PS.PAS +++ /dev/null @@ -1,80 +0,0 @@ -var - f : text; - m, n : byte; - k, i, j, l, gcd0 : integer; - a, b : array[1..30] of integer; - c : array[0..1, 1..900] of integer; - -function gcd(d, e : integer) : integer; - var tmp : integer; - begin - while d > 0 do - begin - tmp := d; - d := e mod d; - e := tmp - end; - gcd := e - end; - -procedure qsort(b, e: integer); - var i, j, x, tmp: integer; - begin - i := b; - j := e; - x := (b + e) div 2; - repeat - while c[0, i] * c[1, x] < c[0, x] * c[1, i] do inc(i); - while c[0, x] * c[1, j] < c[0, j] * c[1, x] do dec(j); - if i <= j then - begin - tmp := c[0, i]; - c[0, i] := c[0, j]; - c[0, j] := tmp; - tmp := c[1, i]; - c[1, i] := c[1, j]; - c[1, j] := tmp; - inc(i); - dec(j) - end - until i > j; - if b < j then qsort(b, j); - if i < e then qsort(i, e) - end; - -begin - assign(f, 'PS.INP'); - reset(f); - read(f, m, n, k); - for i := 1 to m do read(f, a[i]); - for i := 1 to n do read(f, b[i]); - close(f); - l := 0; - for i := 1 to m do - for j := 1 to n do - begin - inc(l); - gcd0 := gcd(a[i], b[j]); - c[0, l] := a[i] div gcd0; - c[1, l] := b[j] div gcd0 - end; - qsort(1, l); - i := 1; - while i < l do - begin - inc(i); - if c[0, i] * c[1, i - 1] = c[0, i - 1] * c[1, i] then - begin - dec(l); - for j := i to l do - begin - c[0, j] := c[0, j + 1]; - c[1, j] := c[1, j + 1] - end - end - end; - assign(f, 'PS.OUT'); - rewrite(f); - writeln(f, c[0, k], ' ', c[1, k]); - close(f) -end. diff --git a/12/TP-2009/R1/R1.pdf b/12/TP-2009/R1/R1.pdf deleted file mode 100755 index b0834b3..0000000 Binary files a/12/TP-2009/R1/R1.pdf and /dev/null differ diff --git a/12/TP-2009/R2/BAI1.PAS b/12/TP-2009/R2/BAI1.PAS deleted file mode 100755 index b28ae0b..0000000 --- a/12/TP-2009/R2/BAI1.PAS +++ /dev/null @@ -1,90 +0,0 @@ -uses math; - -var - f : text; - n : longint; - lena, i : integer; - a : array[1..512] of longint; - -procedure insort(x : longint); - var i, j : integer; - begin - inc(lena); - a[lena] := x - 1; - for i := 1 to lena do - if a[i] < x then begin - for j := lena downto i + 1 do - a[j] := a[j - 1]; - a[i] := x; - exit - end - end; - -function notin(x : longint) : boolean; - var l, h, m : integer; - begin - l := 1; - h := lena; - repeat - m := (l + h) div 2; - if a[m] = x then exit(false); - if a[m] < x then h := m - 1 - else l := m + 1 - until l > h; - notin := true - end; - -procedure mklist(n0 : longint); - var - i, j : byte; - n10, m0 : longint; - begin - if n0 <> 0 then begin - insort(n0); - for i := 0 to trunc(log10(n0)) do - begin - n10 := 1; - for j := 1 to i do n10 := n10 * 10; - m0 := n0 div (n10 * 10) + n0 mod n10; - if notin(m0) then mklist(m0) - end - end - end; - -function prime(m : longint) : boolean; - var p, q : integer; - begin - if m < 2 then exit(false); - if m = 2 then exit(true); - if m = 3 then exit(true); - if m mod 2 = 0 then exit(false); - if m mod 3 = 0 then exit(false); - p := 5; - q := 2; - while p * p <= m do - begin - if m mod p = 0 then exit(false); - p := p + q; - q := 6 - q - end; - prime := true - end; - -begin - assign(f, 'BAI1.INP'); - reset(f); - read(f, n); - close(f); - lena := 0; - mklist(n); - assign(f, 'BAI1.OUT'); - rewrite(f); - for i := 1 to lena do - if prime(a[i]) then begin - writeln(f, a[i]); - close(f); - exit - end; - writeln(f, -1); - close(f) -end. diff --git a/12/TP-2009/R2/BAI3.PAS b/12/TP-2009/R2/BAI3.PAS deleted file mode 100755 index 30eecdf..0000000 --- a/12/TP-2009/R2/BAI3.PAS +++ /dev/null @@ -1,87 +0,0 @@ -type - ar = array of ansistring; - -var - f : text; - s0 : ansistring; - a0 : ar; - -function incre(s1, s2 : ansistring) : boolean; - var - i : smallint; - begin - if length(s1) < length(s2) then exit(true); - if length(s1) > length(s2) then exit(false); - for i := 1 to length(s1) do - begin - if ord(s1[i]) < ord(s2[i]) then exit(true); - if ord(s1[i]) > ord(s2[i]) then exit(false) - end; - exit(false) - end; - -function cal(a : ar) : smallint; - var - len, i, tmp : smallint; - begin - cal := 0; - i := 0; - len := length(a); - while (cal + i < len) and (i + 1 < len) do - begin - inc(i); - if incre(a[0], a[i]) then - begin - tmp := cal(copy(a, i, len - i)) + 1; - if tmp > cal then - cal := tmp - end - end - end; - -function putin( - aray : ar; - strng : ansistring; - len : smallint -) : ar; - begin - setlength(aray, length(aray) + 1); - aray[length(aray) - 1] := copy(strng, 1, len); - exit(aray) - end; - -function libai3( - s : ansistring; - a : ar; - n : smallint -) : smallint; - var - len, i, tmp : smallint; - begin - if s = '' then - exit(cal(a)); - libai3 := 0; - len := length(s); - i := 0; - while (i < n) and (i + libai3 < len) do - begin - inc(i); - tmp := libai3(copy(s, i + 1, len - i), putin(a, s, i), n + 1); - if tmp > libai3 then - libai3 := tmp - end - end; - -begin - assign(f, 'BAI3.INP'); - reset(f); - readln(f); - read(f, s0); - close(f); - setlength(a0, 1); - a0[0] := ''; - assign(f, 'BAI3.OUT'); - rewrite(f); - writeln(f, libai3(s0, a0, 1)); - close(f) -end. diff --git a/12/TP-2009/R2/R2.pdf b/12/TP-2009/R2/R2.pdf deleted file mode 100755 index 7af542a..0000000 Binary files a/12/TP-2009/R2/R2.pdf and /dev/null differ diff --git a/12/TP-2010/BAI1.PAS b/12/TP-2010/BAI1.PAS deleted file mode 100755 index 029201d..0000000 --- a/12/TP-2010/BAI1.PAS +++ /dev/null @@ -1,30 +0,0 @@ -var - f : text; - i : 1..30; - a : array[0..30] of qword; - -function gcd(a, b : qword) : qword; - var tmp : qword; - begin - while b > 0 do - begin - tmp := b; - b := a mod b; - a := tmp - end; - gcd := a - end; - -begin - assign(f, 'bai1.inp'); - reset(f); - readln(f, a[0]); - for i := 1 to a[0] do read(f, a[i]); - close(f); - for i := a[0] - 1 downto 1 do - a[i] := a[i] * a[i + 1] div gcd(a[i], a[i + 1]); - assign(f, 'bai1.out'); - rewrite(f); - writeln(f, a[1]); - close(f) -end. diff --git a/12/TP-2010/BAI2.PAS b/12/TP-2010/BAI2.PAS deleted file mode 100755 index d6639df..0000000 --- a/12/TP-2010/BAI2.PAS +++ /dev/null @@ -1,40 +0,0 @@ -var - f : text; - s : string; - len, i, j : byte; - count : integer = 0; - -function libai2(s0 : string) : boolean; - var - bo, boo, b0 : boolean; - c : char; - begin - b0 := false; - bo := false; - boo := false; - for c in s0 do - begin - case c of - '0' .. '9' : b0 := true; - 'a' .. 'z' : bo := true; - 'A' .. 'Z' : boo := true - end; - if b0 and bo and boo then exit(true) - end; - exit(false); - end; - -begin - assign(f, 'BAI2.INP'); - reset(f); - read(f, s); - close(f); - len := length(s); - for i := 1 to len - 5 do - for j := 6 to len - i + 1 do - if libai2(copy(s, i, j)) then inc(count); - assign(f, 'BAI2.OUT'); - rewrite(f); - writeln(f, count); - close(f) -end. diff --git a/12/TP-2010/BAI3 b/12/TP-2010/BAI3 deleted file mode 100755 index 7b83e7b..0000000 Binary files a/12/TP-2010/BAI3 and /dev/null differ diff --git a/12/TP-2010/BAI3.INP b/12/TP-2010/BAI3.INP deleted file mode 100755 index 3609812..0000000 --- a/12/TP-2010/BAI3.INP +++ /dev/null @@ -1 +0,0 @@ -5 5 0 diff --git a/12/TP-2010/BAI3.OUT b/12/TP-2010/BAI3.OUT deleted file mode 100755 index e69de29..0000000 diff --git a/12/TP-2010/BAI3.o b/12/TP-2010/BAI3.o deleted file mode 100755 index 7706cd6..0000000 Binary files a/12/TP-2010/BAI3.o and /dev/null differ diff --git a/12/TP-2010/BAI3.pas b/12/TP-2010/BAI3.pas deleted file mode 100755 index aedf9a0..0000000 --- a/12/TP-2010/BAI3.pas +++ /dev/null @@ -1,73 +0,0 @@ -type - board = array[0..31, 0..31] of boolean; - -var - f : text; - a : board; - i, j, k, l, m, n : byte; - -function king( - e : board; - x, y : byte -) : board; - var z, t : byte; - begin - for z := x - 1 to x + 1 do - for t := y - 1 to y + 1 do - e[z, t] := true; - exit(e) - end; - -function full(c : board) : boolean; - var d : boolean; - begin - for d in c do - if not(d) then - exit(false); - exit(true) - end; - -function libai3( - b : board; - x0, y0 : byte -) : byte; - type tmp = record - n, x, y : byte - end; - var - max : tmp; - t, x, y : byte; - begin - if full(b) then exit(0); - max.n := 0; - for x := x0 to m do - for y := y0 to n do - if not(b[x, y]) then - begin - t := libai3(king(b, x, y), x + 1, y + 1) + 1; - writeln(t); - if t > max.n then - begin - max.x := x; - max.y := y; - max.n := t - end - end; - exit(max.n) - end; - -begin - assign(f, 'BAI3.INP'); - reset(f); - readln(f, m, n, k); - for l := 1 to k do - begin - readln(f, i, j); - a := king(a, i, j) - end; - close(f); - assign(f, 'BAI3.OUT'); - rewrite(f); - writeln(libai3(a, 1, 1)); - close(f) -end. diff --git a/12/TP-2010/README.md b/12/TP-2010/README.md deleted file mode 100644 index 625312d..0000000 --- a/12/TP-2010/README.md +++ /dev/null @@ -1 +0,0 @@ -![](TP-2010.png) diff --git a/12/TP-2010/TP-2010.png b/12/TP-2010/TP-2010.png deleted file mode 100755 index 7eacc66..0000000 Binary files a/12/TP-2010/TP-2010.png and /dev/null differ diff --git a/12/TP-2010/_BAI3.pas b/12/TP-2010/_BAI3.pas deleted file mode 100644 index 09ec0ca..0000000 --- a/12/TP-2010/_BAI3.pas +++ /dev/null @@ -1,73 +0,0 @@ -type - board = array[0..1023] of boolean; - -var - f : text; - a : board; - i, j, k, l, m, n : byte; - -function king( - e : board; - x, y : byte -) : board; - var z, t : byte; - begin - for z := x - 1 to x + 1 do - for t := y - 1 to y + 1 do - e[z, t] := true; - exit(e) - end; - -function full(c : board) : boolean; - var d : boolean; - begin - for d in c do - if not(d) then - exit(false); - exit(true) - end; - -function libai3( - b : board; - x0, y0 : byte -) : byte; - type tmp = record - n, x, y : byte - end; - var - max : tmp; - t, x, y : byte; - begin - if full(b) then exit(0); - max.n := 0; - for x := x0 to m do - for y := y0 to n do - if not(b[x, y]) then - begin - t := libai3(king(b, x, y), x + 1, y + 1) + 1; - writeln(t); - if t > max.n then - begin - max.x := x; - max.y := y; - max.n := t - end - end; - exit(max.n) - end; - -begin - assign(f, 'BAI3.INP'); - reset(f); - readln(f, m, n, k); - for l := 1 to k do - begin - readln(f, i, j); - a := king(a, i, j) - end; - close(f); - assign(f, 'BAI3.OUT'); - rewrite(f); - writeln(libai3(a, 1, 1)); - close(f) -end. diff --git a/12/TP-HN-2008/R1/BL1.PAS b/12/TP-HN-2008/R1/BL1.PAS new file mode 100755 index 0000000..6931b1b --- /dev/null +++ b/12/TP-HN-2008/R1/BL1.PAS @@ -0,0 +1,26 @@ +uses math; + +var + f : text; + m, n, i : byte; + a, b : double; +j +begin + assign(f, 'LT.IN'); + reset(f); + read(f, n, m); + close(f); + a := 1; + for i := 1 to n do + a := a * 2; + b := 1; + for i := 1 to m do + b := b * 3; + a := a + b; + for i := 1 to trunc(log10(a)) do + a := a / 10; + assign(f, 'LT.OU'); + rewrite(f); + writeln(f, trunc(a)); + close(f) +end. diff --git a/12/TP-HN-2008/R1/BL2.PAS b/12/TP-HN-2008/R1/BL2.PAS new file mode 100755 index 0000000..e228240 --- /dev/null +++ b/12/TP-HN-2008/R1/BL2.PAS @@ -0,0 +1,57 @@ +type + rect = record + a : longint; + b : longint + end; + arec = array of rect; + +var + f : text; + c, d, e : rect; + +function join(g, h : rect) : arec; + var n : byte = 0; + procedure j01n(p, q : longint); + begin + inc(n); + setlength(join, n); + join[n - 1].a := p; + join[n - 1].b := q + end; + begin + if g.a = h.a then j01n(g.a, g.b + h.b); + if g.a = h.b then j01n(g.a, g.b + h.a); + if g.b = h.a then j01n(g.b, g.a + h.b); + if g.b = h.b then j01n(g.b, g.a + h.a); + end; + +procedure out(m : longint); + begin + assign(f, 'GH.OU'); + rewrite(f); + writeln(f, m); + close(f); + halt + end; + +procedure libl2(x, y, z : rect); + var i, j : rect; + begin + for i in join(x, y) do + for j in join(z, i) do + if (j.a = j.b) and (j.a <> 0) then + out(j.a) + end; + +begin + assign(f, 'GH.IN'); + reset(f); + readln(f, c.a, c.b); + readln(f, d.a, d.b); + readln(f, e.a, e.b); + close(f); + libl2(c, d, e); + libl2(d, e, c); + libl2(e, c, d); + out(0) +end. diff --git a/12/TP-HN-2008/R1/BL3.PAS b/12/TP-HN-2008/R1/BL3.PAS new file mode 100755 index 0000000..a49b4d6 --- /dev/null +++ b/12/TP-HN-2008/R1/BL3.PAS @@ -0,0 +1,45 @@ +type ar = array[0..3] of longint; + +var + f : text; + m, n, i, j : shortint; + a : array[1..101, -1..102] of longint; + tmp, max : longint; + +function next(x, y : shortint) : ar; + begin + next[0] := a[x + 1, y - 2]; + next[1] := a[x + 1, y + 2]; + next[2] := a[x + 2, y - 1]; + next[3] := a[x + 2, y + 1] + end; + +begin + for i := 1 to 101 do + for j := -1 to 102 do + a[i, j] := 0; + assign(f, 'QM.IN'); + reset(f); + readln(f, m, n); + for i := 1 to m do + for j := 1 to n do + read(f, a[i, j]); + close(f); + for i := m - 1 downto 1 do + for j := 1 to n do + begin + max := 0; + for tmp in next(i, j) do + if tmp > max then + max := tmp; + a[i, j] := a[i, j] + max; + end; + assign(f, 'QM.OU'); + rewrite(f); + max := 0; + for i := 1 to n do + if a[1, i] > max then + max := a[1, i]; + writeln(f, max); + close(f); +end. diff --git a/12/TP-HN-2008/R1/BL4.pas b/12/TP-HN-2008/R1/BL4.pas new file mode 100755 index 0000000..94dd3ba --- /dev/null +++ b/12/TP-HN-2008/R1/BL4.pas @@ -0,0 +1,26 @@ +var + f : text; + n : word; + a, b : array of longword; + tmp0, tmp1 : longword; + +procedure ins(var l : array of longword; x : longword); + begin + setlength(l, length(l) + 1); + l[length(l) - 1] := x + end; + +begin + setlength(a, 0); + setlength(b, 0); + assign(f, 'CLB.IN'); + reset(f); + readln(f, n); + for i := 1 to n do + begin + readln(f, tmp0, tmp1); + ins(a, tmp0); + ins(b, tmp1) + end; + close(f); + diff --git a/12/TP-HN-2008/R1/CLB.IN b/12/TP-HN-2008/R1/CLB.IN new file mode 100755 index 0000000..662c775 --- /dev/null +++ b/12/TP-HN-2008/R1/CLB.IN @@ -0,0 +1,4 @@ +3 +7 9 +3 8 +10 20 diff --git a/12/TP-HN-2008/R1/CLB.OU b/12/TP-HN-2008/R1/CLB.OU new file mode 100755 index 0000000..e69de29 diff --git a/12/TP-HN-2008/R1/R1.DOC b/12/TP-HN-2008/R1/R1.DOC new file mode 100755 index 0000000..5e29da2 Binary files /dev/null and b/12/TP-HN-2008/R1/R1.DOC differ diff --git a/12/TP-HN-2008/R2/DG b/12/TP-HN-2008/R2/DG new file mode 100755 index 0000000..ad902a1 Binary files /dev/null and b/12/TP-HN-2008/R2/DG differ diff --git a/12/TP-HN-2008/R2/DG.INP b/12/TP-HN-2008/R2/DG.INP new file mode 100755 index 0000000..fb3ca57 --- /dev/null +++ b/12/TP-HN-2008/R2/DG.INP @@ -0,0 +1,6 @@ +4 +0 1 +1 0 +0 -1 +-1 0 +-2 0 0 0 diff --git a/12/TP-HN-2008/R2/DG.OUT b/12/TP-HN-2008/R2/DG.OUT new file mode 100755 index 0000000..c227083 --- /dev/null +++ b/12/TP-HN-2008/R2/DG.OUT @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/12/TP-HN-2008/R2/DG.o b/12/TP-HN-2008/R2/DG.o new file mode 100755 index 0000000..cf2e3e1 Binary files /dev/null and b/12/TP-HN-2008/R2/DG.o differ diff --git a/12/TP-HN-2008/R2/DG.pas b/12/TP-HN-2008/R2/DG.pas new file mode 100755 index 0000000..2313685 --- /dev/null +++ b/12/TP-HN-2008/R2/DG.pas @@ -0,0 +1,83 @@ +type bigboo = [-1..1]; + +var + f : text; + n, i, j : byte; + inp : array[0..100] of PointType; + P, Q : PointType; + P_out, Q_out : boolean; + s : int64 = 0; + +function stri2(A, B, C : PointType) : int64; + begin + stri2 := (C.y - A.y) * (A.x - B.x) - (C.x - A.x) * (A.y - B.y) + end; + +function outpoly(M : PointType) : int64; + begin + outpoly := s; + for i := 0 to n - 1 do + begin + outpoly := outpoly - abs(stri2(M, inp[i], inp[i + 1])) + end + end; + +function sign(x : smallint) : bigboo; + begin + case true of + x > 0 : exit(1); + x = 0 : exit(0); + x < 0 : exit(-1) + end + end; + +function intersect(A, B : PointType) : bigboo; + var b00, b01 : bigboo; + begin + b00 := sign(stri2(P, Q, A)); + b01 := sign(stri2(P, Q, A)); + if b00 = b01 then + if b00 = 0 then exit(0) + else exit(-1); + b00 := sign(stri2(A, B, P)); + b01 := sign(stri2(A, B, Q)); + if b00 = b01 then + if b00 = 0 then exit(0) + else exit(-1); + exit(1) + end; + +function lensqr(A, B : PointType) : int64; + begin + exit() + end; + +procedure out(M, N : PointType); + begin + assign(f, 'DG.OUT'); + rewrite(f); + write(f, trunc(sqrt(sqr(A.x - B.x) + sqr(A.y - B.y)) * 100)); + close(f); + halt + end; + +begin + assign(f, 'DG.INP'); + reset(f); + readln(f, n); + for i := 0 to n - 1 do + readln(f, inp[i].x, inp[i].y); + inp[n] := inp[0]; + readln(f, P.x, P.y, Q.x, Q.y); + close(f); + for i := 1 to n - 2 do + s := s + abs(stri2(inp[0], inp[i], inp[i + 1])); + if outpoly(P) = 0 then + P_out := false; + if outpoly(Q) = 0 then + Q_out := false; + if P_out and Q_out then + for i := 0 to n - 1 do + + out(P, Q) +end. diff --git a/12/TP-HN-2008/R2/HC.pas b/12/TP-HN-2008/R2/HC.pas new file mode 100644 index 0000000..8e6b182 --- /dev/null +++ b/12/TP-HN-2008/R2/HC.pas @@ -0,0 +1,23 @@ +var + f : text; + m, n, i, j : byte; + a : array[1..200, 0..200] of smallint; + +function out + +begin + assign(f, 'HC.INP'); + reset(f); + readln(f, m, n); + for i := 1 to m do + begin + a[i, 0] := 0; + for j := 1 to n do + read(f, a[i, j]) + end; + close(f); + assign(f, 'HC.OUT'); + rewrite(f); + writeln(f, out(a)); + close(f) +end; diff --git a/12/TP-HN-2008/R2/R2.doc b/12/TP-HN-2008/R2/R2.doc new file mode 100755 index 0000000..c804058 Binary files /dev/null and b/12/TP-HN-2008/R2/R2.doc differ diff --git a/12/TP-HN-2008/R2/TBC.PAS b/12/TP-HN-2008/R2/TBC.PAS new file mode 100755 index 0000000..1a26a91 --- /dev/null +++ b/12/TP-HN-2008/R2/TBC.PAS @@ -0,0 +1,69 @@ +var + f : text; + i, l, m, n : integer; + a : array[1..1000] of longint; + +procedure qsort(l, h : integer); + var + i, j : integer; + x, tmp : longint; + begin + i := l; + j := h; + x := a[(i + j) div 2]; + repeat + while a[i] < x do inc(i); + while x < a[j] do dec(j); + if i <= j then + begin + tmp := a[i]; + a[i] := a[j]; + a[j] := tmp; + inc(i); + dec(j) + end + until i > j; + if l < j then qsort(l, j); + if i < h then qsort(i, h) + end; + +function biin(n0 : integer) : boolean; + var l, h, m : integer; + begin + l := 1; + h := n; + repeat + m := (l + h) div 2; + if a[m] = n0 then exit(true); + if a[m] < n0 then l := m + 1 + else h := m - 1 + until l > h; + biin := false + end; + +function libtbc(n0 : integer) : boolean; + var i, j : integer; + begin + for i := 1 to n0 - 1 do + for j := n0 + 1 to n do + if biin(a[n0] * 3 - a[i] - a[j]) then + exit(true); + libtbc := false + end; + +begin + assign(f, 'TBC.INP'); + reset(f); + readln(f, n); + for i := 1 to n do readln(f, a[i]); + close(f); + qsort(1, n); + m := 0; + for l := 2 to n - 1 do + if libtbc(l) then + inc(m); + assign(f, 'TBC.OUT'); + rewrite(f); + writeln(f, m); + close(f) +end. diff --git a/12/TP-HN-2009/R1/BTN.PAS b/12/TP-HN-2009/R1/BTN.PAS new file mode 100755 index 0000000..dbb022d --- /dev/null +++ b/12/TP-HN-2009/R1/BTN.PAS @@ -0,0 +1,87 @@ +type sni = record + s : ansistring; + n : integer +end; + +var + f : text; + s : ansistring; + op, cl : integer; + c : char; + +function cal(s : ansistring) : integer; + var + c : char; + tmp : integer = 0; + begin + cal := 0; + for c in s do + if c = '(' then + begin + inc(tmp); + if tmp > cal then + cal := tmp + end + else + begin + dec(tmp); + if tmp < 0 then exit(0) + end; + if tmp <> 0 then + exit(0) + end; + +function rplc( + s : ansistring; + c : char; + idx : integer +) : ansistring; + begin + exit(copy(s, 1, idx - 1) + c + copy(s, idx + 1, length(s) - idx + 1)) + end; + +function libtn( + s : ansistring; + op, cl, idx : integer +) : sni; + var + i : integer; + v0, v1 : sni; + begin + if (op = 0) and (cl = 0) then + begin + libtn.s := s; + libtn.n := cal(s); + exit + end; + i := idx; + while s[i] <> '?' do + inc(i); + if op = 0 then + exit(libtn(rplc(s, ')', i), 0, cl - 1, i + 1)); + if cl = 0 then + exit(libtn(rplc(s, '(', i), op - 1, 0, i + 1)); + v0 := libtn(rplc(s, '(', i), op - 1, cl, i + 1); + v1 := libtn(rplc(s, ')', i), op, cl - 1, i + 1); + if v0.n > v1.n then + exit(v0) + else exit(v1) + end; + +begin + assign(f, 'BTN.INP'); + reset(f); + read(f, s); + close(f); + op := length(s) div 2; + cl := length(s) div 2; + for c in s do + if c = '(' then + dec(op) + else if c = ')' then + dec(cl); + assign(f, 'BTN.OUT'); + rewrite(f); + writeln(f, libtn(s, op, cl, 1).s); + close(f) +end. diff --git a/12/TP-HN-2009/R1/HEXA.PAS b/12/TP-HN-2009/R1/HEXA.PAS new file mode 100755 index 0000000..a2fd6ca --- /dev/null +++ b/12/TP-HN-2009/R1/HEXA.PAS @@ -0,0 +1,75 @@ +var + f : text; + n, n0, m, i, j, tmp : longint; + s : string; + +function dec2hex(deca : longint) : string; + var + a : array[0..7] of byte; + i, j : byte; + begin + dec2hex := ''; + i := 0; + while deca > 0 do + begin + a[i] := deca mod 16; + deca := deca div 16; + inc(i) + end; + dec(i); + for j := i downto 0 do + case a[j] of + 0 : dec2hex := dec2hex + '0'; + 1 : dec2hex := dec2hex + '1'; + 2 : dec2hex := dec2hex + '2'; + 3 : dec2hex := dec2hex + '3'; + 4 : dec2hex := dec2hex + '4'; + 5 : dec2hex := dec2hex + '5'; + 6 : dec2hex := dec2hex + '6'; + 7 : dec2hex := dec2hex + '7'; + 8 : dec2hex := dec2hex + '8'; + 9 : dec2hex := dec2hex + '9'; + 10 : dec2hex := dec2hex + 'A'; + 11 : dec2hex := dec2hex + 'B'; + 12 : dec2hex := dec2hex + 'C'; + 13 : dec2hex := dec2hex + 'D'; + 14 : dec2hex := dec2hex + 'E'; + 15 : dec2hex := dec2hex + 'F' + end + end; + +begin + assign(f, 'HEXA.INP'); + reset(f); + read(f, n); + close(f); + m := n; + i := 0; + while m > 0 do + begin + inc(i); + tmp := 1; + for j := 1 to i - 1 do tmp := tmp * 16; + m := m + i * (tmp - tmp * 16) + end; + m := i; + for i := 1 to m - 1 do + begin + tmp := 1; + for j := 1 to i - 1 do tmp := tmp * 16; + n := n + i * (tmp - tmp * 16) + end; + n0 := (n + m - 1) div m; + for i := 1 to m - 1 do + begin + tmp := 1; + for j := 1 to i - 1 do tmp := tmp * 16; + n0 := n0 + tmp * 16 - tmp + end; + s := dec2hex(n0); + if n mod m > 0 then m := n mod m; + assign(f, 'HEXA.OUT'); + rewrite(f); + writeln(f, s[m]); + close(f) +end. diff --git a/12/TP-HN-2009/R1/PS.PAS b/12/TP-HN-2009/R1/PS.PAS new file mode 100755 index 0000000..6cf2d09 --- /dev/null +++ b/12/TP-HN-2009/R1/PS.PAS @@ -0,0 +1,80 @@ +var + f : text; + m, n : byte; + k, i, j, l, gcd0 : integer; + a, b : array[1..30] of integer; + c : array[0..1, 1..900] of integer; + +function gcd(d, e : integer) : integer; + var tmp : integer; + begin + while d > 0 do + begin + tmp := d; + d := e mod d; + e := tmp + end; + gcd := e + end; + +procedure qsort(b, e: integer); + var i, j, x, tmp: integer; + begin + i := b; + j := e; + x := (b + e) div 2; + repeat + while c[0, i] * c[1, x] < c[0, x] * c[1, i] do inc(i); + while c[0, x] * c[1, j] < c[0, j] * c[1, x] do dec(j); + if i <= j then + begin + tmp := c[0, i]; + c[0, i] := c[0, j]; + c[0, j] := tmp; + tmp := c[1, i]; + c[1, i] := c[1, j]; + c[1, j] := tmp; + inc(i); + dec(j) + end + until i > j; + if b < j then qsort(b, j); + if i < e then qsort(i, e) + end; + +begin + assign(f, 'PS.INP'); + reset(f); + read(f, m, n, k); + for i := 1 to m do read(f, a[i]); + for i := 1 to n do read(f, b[i]); + close(f); + l := 0; + for i := 1 to m do + for j := 1 to n do + begin + inc(l); + gcd0 := gcd(a[i], b[j]); + c[0, l] := a[i] div gcd0; + c[1, l] := b[j] div gcd0 + end; + qsort(1, l); + i := 1; + while i < l do + begin + inc(i); + if c[0, i] * c[1, i - 1] = c[0, i - 1] * c[1, i] then + begin + dec(l); + for j := i to l do + begin + c[0, j] := c[0, j + 1]; + c[1, j] := c[1, j + 1] + end + end + end; + assign(f, 'PS.OUT'); + rewrite(f); + writeln(f, c[0, k], ' ', c[1, k]); + close(f) +end. diff --git a/12/TP-HN-2009/R1/R1.pdf b/12/TP-HN-2009/R1/R1.pdf new file mode 100755 index 0000000..b0834b3 Binary files /dev/null and b/12/TP-HN-2009/R1/R1.pdf differ diff --git a/12/TP-HN-2009/R2/BAI1.PAS b/12/TP-HN-2009/R2/BAI1.PAS new file mode 100755 index 0000000..b28ae0b --- /dev/null +++ b/12/TP-HN-2009/R2/BAI1.PAS @@ -0,0 +1,90 @@ +uses math; + +var + f : text; + n : longint; + lena, i : integer; + a : array[1..512] of longint; + +procedure insort(x : longint); + var i, j : integer; + begin + inc(lena); + a[lena] := x - 1; + for i := 1 to lena do + if a[i] < x then begin + for j := lena downto i + 1 do + a[j] := a[j - 1]; + a[i] := x; + exit + end + end; + +function notin(x : longint) : boolean; + var l, h, m : integer; + begin + l := 1; + h := lena; + repeat + m := (l + h) div 2; + if a[m] = x then exit(false); + if a[m] < x then h := m - 1 + else l := m + 1 + until l > h; + notin := true + end; + +procedure mklist(n0 : longint); + var + i, j : byte; + n10, m0 : longint; + begin + if n0 <> 0 then begin + insort(n0); + for i := 0 to trunc(log10(n0)) do + begin + n10 := 1; + for j := 1 to i do n10 := n10 * 10; + m0 := n0 div (n10 * 10) + n0 mod n10; + if notin(m0) then mklist(m0) + end + end + end; + +function prime(m : longint) : boolean; + var p, q : integer; + begin + if m < 2 then exit(false); + if m = 2 then exit(true); + if m = 3 then exit(true); + if m mod 2 = 0 then exit(false); + if m mod 3 = 0 then exit(false); + p := 5; + q := 2; + while p * p <= m do + begin + if m mod p = 0 then exit(false); + p := p + q; + q := 6 - q + end; + prime := true + end; + +begin + assign(f, 'BAI1.INP'); + reset(f); + read(f, n); + close(f); + lena := 0; + mklist(n); + assign(f, 'BAI1.OUT'); + rewrite(f); + for i := 1 to lena do + if prime(a[i]) then begin + writeln(f, a[i]); + close(f); + exit + end; + writeln(f, -1); + close(f) +end. diff --git a/12/TP-HN-2009/R2/BAI3.PAS b/12/TP-HN-2009/R2/BAI3.PAS new file mode 100755 index 0000000..30eecdf --- /dev/null +++ b/12/TP-HN-2009/R2/BAI3.PAS @@ -0,0 +1,87 @@ +type + ar = array of ansistring; + +var + f : text; + s0 : ansistring; + a0 : ar; + +function incre(s1, s2 : ansistring) : boolean; + var + i : smallint; + begin + if length(s1) < length(s2) then exit(true); + if length(s1) > length(s2) then exit(false); + for i := 1 to length(s1) do + begin + if ord(s1[i]) < ord(s2[i]) then exit(true); + if ord(s1[i]) > ord(s2[i]) then exit(false) + end; + exit(false) + end; + +function cal(a : ar) : smallint; + var + len, i, tmp : smallint; + begin + cal := 0; + i := 0; + len := length(a); + while (cal + i < len) and (i + 1 < len) do + begin + inc(i); + if incre(a[0], a[i]) then + begin + tmp := cal(copy(a, i, len - i)) + 1; + if tmp > cal then + cal := tmp + end + end + end; + +function putin( + aray : ar; + strng : ansistring; + len : smallint +) : ar; + begin + setlength(aray, length(aray) + 1); + aray[length(aray) - 1] := copy(strng, 1, len); + exit(aray) + end; + +function libai3( + s : ansistring; + a : ar; + n : smallint +) : smallint; + var + len, i, tmp : smallint; + begin + if s = '' then + exit(cal(a)); + libai3 := 0; + len := length(s); + i := 0; + while (i < n) and (i + libai3 < len) do + begin + inc(i); + tmp := libai3(copy(s, i + 1, len - i), putin(a, s, i), n + 1); + if tmp > libai3 then + libai3 := tmp + end + end; + +begin + assign(f, 'BAI3.INP'); + reset(f); + readln(f); + read(f, s0); + close(f); + setlength(a0, 1); + a0[0] := ''; + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(f, libai3(s0, a0, 1)); + close(f) +end. diff --git a/12/TP-HN-2009/R2/R2.pdf b/12/TP-HN-2009/R2/R2.pdf new file mode 100755 index 0000000..7af542a Binary files /dev/null and b/12/TP-HN-2009/R2/R2.pdf differ diff --git a/12/TP-HN-2010/BAI1.PAS b/12/TP-HN-2010/BAI1.PAS new file mode 100755 index 0000000..029201d --- /dev/null +++ b/12/TP-HN-2010/BAI1.PAS @@ -0,0 +1,30 @@ +var + f : text; + i : 1..30; + a : array[0..30] of qword; + +function gcd(a, b : qword) : qword; + var tmp : qword; + begin + while b > 0 do + begin + tmp := b; + b := a mod b; + a := tmp + end; + gcd := a + end; + +begin + assign(f, 'bai1.inp'); + reset(f); + readln(f, a[0]); + for i := 1 to a[0] do read(f, a[i]); + close(f); + for i := a[0] - 1 downto 1 do + a[i] := a[i] * a[i + 1] div gcd(a[i], a[i + 1]); + assign(f, 'bai1.out'); + rewrite(f); + writeln(f, a[1]); + close(f) +end. diff --git a/12/TP-HN-2010/BAI2.PAS b/12/TP-HN-2010/BAI2.PAS new file mode 100755 index 0000000..d6639df --- /dev/null +++ b/12/TP-HN-2010/BAI2.PAS @@ -0,0 +1,40 @@ +var + f : text; + s : string; + len, i, j : byte; + count : integer = 0; + +function libai2(s0 : string) : boolean; + var + bo, boo, b0 : boolean; + c : char; + begin + b0 := false; + bo := false; + boo := false; + for c in s0 do + begin + case c of + '0' .. '9' : b0 := true; + 'a' .. 'z' : bo := true; + 'A' .. 'Z' : boo := true + end; + if b0 and bo and boo then exit(true) + end; + exit(false); + end; + +begin + assign(f, 'BAI2.INP'); + reset(f); + read(f, s); + close(f); + len := length(s); + for i := 1 to len - 5 do + for j := 6 to len - i + 1 do + if libai2(copy(s, i, j)) then inc(count); + assign(f, 'BAI2.OUT'); + rewrite(f); + writeln(f, count); + close(f) +end. diff --git a/12/TP-HN-2010/BAI3 b/12/TP-HN-2010/BAI3 new file mode 100755 index 0000000..7b83e7b Binary files /dev/null and b/12/TP-HN-2010/BAI3 differ diff --git a/12/TP-HN-2010/BAI3.INP b/12/TP-HN-2010/BAI3.INP new file mode 100755 index 0000000..3609812 --- /dev/null +++ b/12/TP-HN-2010/BAI3.INP @@ -0,0 +1 @@ +5 5 0 diff --git a/12/TP-HN-2010/BAI3.OUT b/12/TP-HN-2010/BAI3.OUT new file mode 100755 index 0000000..e69de29 diff --git a/12/TP-HN-2010/BAI3.o b/12/TP-HN-2010/BAI3.o new file mode 100755 index 0000000..7706cd6 Binary files /dev/null and b/12/TP-HN-2010/BAI3.o differ diff --git a/12/TP-HN-2010/BAI3.pas b/12/TP-HN-2010/BAI3.pas new file mode 100755 index 0000000..aedf9a0 --- /dev/null +++ b/12/TP-HN-2010/BAI3.pas @@ -0,0 +1,73 @@ +type + board = array[0..31, 0..31] of boolean; + +var + f : text; + a : board; + i, j, k, l, m, n : byte; + +function king( + e : board; + x, y : byte +) : board; + var z, t : byte; + begin + for z := x - 1 to x + 1 do + for t := y - 1 to y + 1 do + e[z, t] := true; + exit(e) + end; + +function full(c : board) : boolean; + var d : boolean; + begin + for d in c do + if not(d) then + exit(false); + exit(true) + end; + +function libai3( + b : board; + x0, y0 : byte +) : byte; + type tmp = record + n, x, y : byte + end; + var + max : tmp; + t, x, y : byte; + begin + if full(b) then exit(0); + max.n := 0; + for x := x0 to m do + for y := y0 to n do + if not(b[x, y]) then + begin + t := libai3(king(b, x, y), x + 1, y + 1) + 1; + writeln(t); + if t > max.n then + begin + max.x := x; + max.y := y; + max.n := t + end + end; + exit(max.n) + end; + +begin + assign(f, 'BAI3.INP'); + reset(f); + readln(f, m, n, k); + for l := 1 to k do + begin + readln(f, i, j); + a := king(a, i, j) + end; + close(f); + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(libai3(a, 1, 1)); + close(f) +end. diff --git a/12/TP-HN-2010/README.md b/12/TP-HN-2010/README.md new file mode 100644 index 0000000..625312d --- /dev/null +++ b/12/TP-HN-2010/README.md @@ -0,0 +1 @@ +![](TP-2010.png) diff --git a/12/TP-HN-2010/TP-2010.png b/12/TP-HN-2010/TP-2010.png new file mode 100755 index 0000000..7eacc66 Binary files /dev/null and b/12/TP-HN-2010/TP-2010.png differ diff --git a/12/TP-HN-2010/_BAI3.pas b/12/TP-HN-2010/_BAI3.pas new file mode 100644 index 0000000..09ec0ca --- /dev/null +++ b/12/TP-HN-2010/_BAI3.pas @@ -0,0 +1,73 @@ +type + board = array[0..1023] of boolean; + +var + f : text; + a : board; + i, j, k, l, m, n : byte; + +function king( + e : board; + x, y : byte +) : board; + var z, t : byte; + begin + for z := x - 1 to x + 1 do + for t := y - 1 to y + 1 do + e[z, t] := true; + exit(e) + end; + +function full(c : board) : boolean; + var d : boolean; + begin + for d in c do + if not(d) then + exit(false); + exit(true) + end; + +function libai3( + b : board; + x0, y0 : byte +) : byte; + type tmp = record + n, x, y : byte + end; + var + max : tmp; + t, x, y : byte; + begin + if full(b) then exit(0); + max.n := 0; + for x := x0 to m do + for y := y0 to n do + if not(b[x, y]) then + begin + t := libai3(king(b, x, y), x + 1, y + 1) + 1; + writeln(t); + if t > max.n then + begin + max.x := x; + max.y := y; + max.n := t + end + end; + exit(max.n) + end; + +begin + assign(f, 'BAI3.INP'); + reset(f); + readln(f, m, n, k); + for l := 1 to k do + begin + readln(f, i, j); + a := king(a, i, j) + end; + close(f); + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(libai3(a, 1, 1)); + close(f) +end. -- cgit 1.4.1