about summary refs log tree commit diff
path: root/others
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-22 14:51:37 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-22 14:51:37 +0700
commit7ebfa64719d4ac86b30075c65f21eafe9097853e (patch)
treecf9d59c492bd650258cf139d000d45fb6b8357fb /others
parent7d19f480637e9e880b98dabfbcf8e885b0a2d3b9 (diff)
downloadcp-7ebfa64719d4ac86b30075c65f21eafe9097853e.tar.gz
Updare README.md
Diffstat (limited to 'others')
-rw-r--r--others/volume1/112.scm12
-rw-r--r--others/volume1/114.pas36
-rw-r--r--others/volume1/118.pas18
-rw-r--r--others/volume1/122.scm6
-rw-r--r--others/volume1/README.md2
5 files changed, 74 insertions, 0 deletions
diff --git a/others/volume1/112.scm b/others/volume1/112.scm
new file mode 100644
index 0000000..c03bfdc
--- /dev/null
+++ b/others/volume1/112.scm
@@ -0,0 +1,12 @@
+(define (sqr x) (* x x))
+(define (distance n)
+  (let distance-iter ((hi (inexact->exact (truncate (sqrt n)))) (i 2))
+    (cond ((= n 1) 0)
+           ((= i hi) 1)
+           ((= (remainder n i) 0) (begin (set! n (quotient n i))
+                                         (+ (distance-iter hi i) 1)))
+           (else (distance-iter hi (+ i 1))))))
+(let loop ((a (read)) (b (read)))
+  (unless (eof-object? a)
+    (format #t "~a\n" (distance (quotient (* a b) (sqr (gcd a b)))))
+    (loop (read) (read))))
diff --git a/others/volume1/114.pas b/others/volume1/114.pas
new file mode 100644
index 0000000..927a4af
--- /dev/null
+++ b/others/volume1/114.pas
@@ -0,0 +1,36 @@
+var
+  m, n, i, j: int16;
+  h: array[0..1001, 0..1001] of int32;
+  count: int32 = 0;
+
+function stupid(x, y: int16): int8;
+  begin
+    if h[x][y] > h[x - 1][y] then
+      exit(0);
+    if h[x][y] > h[x + 1][y] then
+      exit(0);
+    if h[x][y] > h[x][y - 1] then
+      exit(0);
+    if h[x][y] > h[x][y + 1] then
+      exit(0);
+    stupid := 1
+  end;
+
+begin
+  readln(m, n);
+  for i := 1 to m do
+    for j := 1 to n do
+      read(h[i][j]);
+  for i := 0 to m do
+    h[i][0] := 0;
+  for i := 1 to m + 1 do
+    h[i][n + 1] := 0;
+  for i := 0 to n do
+    h[0][j] := 0;
+  for i := 1 to n + 1 do
+    h[m + 1][i] := 0;
+  for i := 1 to m do
+    for j := 1 to n do
+      inc(count, stupid(i, j));
+  writeln(count)
+end.
diff --git a/others/volume1/118.pas b/others/volume1/118.pas
new file mode 100644
index 0000000..c8008e6
--- /dev/null
+++ b/others/volume1/118.pas
@@ -0,0 +1,18 @@
+var
+  n, i: uint16;
+  a: array of int64;
+
+begin
+  readln(n);
+  setlength(a, n);
+  for i := 0 to n - 1 do
+    read(a[i]);
+  for i := 1 to n - 2 do
+    if (a[i] < a[i - 1]) and
+       (a[i] < a[i + 1]) then
+      begin
+        dec(n);
+        a[i] := a[i - 1]
+      end;
+  writeln(length(a) - n)
+end.
diff --git a/others/volume1/122.scm b/others/volume1/122.scm
new file mode 100644
index 0000000..63b1032
--- /dev/null
+++ b/others/volume1/122.scm
@@ -0,0 +1,6 @@
+(define (sqr x) (* x x))
+(let loop ((r (read)))
+  (unless (eof-object? r)
+    (let ((a (read)) (b (read)))
+      (display (if (< (sqr (* r 2)) (+ (sqr a) (sqr b))) "NO\n" "YES\n")))
+    (loop (read))))
diff --git a/others/volume1/README.md b/others/volume1/README.md
new file mode 100644
index 0000000..6f93607
--- /dev/null
+++ b/others/volume1/README.md
@@ -0,0 +1,2 @@
+Do giới hạn preview của Github khá hạn chế nên các để bài được giữ trong
+[file PDF](README.md).