about summary refs log tree commit diff
path: root/others/volume1/038.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-12 16:18:20 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-12 16:18:20 +0700
commit1a8e1e68759611a66ae116771da5f376c95a3b9f (patch)
treee663fa6adb9264046a876e552ff2a455215c3a8b /others/volume1/038.pas
parentdf9a0d140a7b7edef66f95aa13b5bb4488147f68 (diff)
downloadcp-1a8e1e68759611a66ae116771da5f376c95a3b9f.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1/038.pas')
-rw-r--r--others/volume1/038.pas29
1 files changed, 29 insertions, 0 deletions
diff --git a/others/volume1/038.pas b/others/volume1/038.pas
new file mode 100644
index 0000000..a89142a
--- /dev/null
+++ b/others/volume1/038.pas
@@ -0,0 +1,29 @@
+var
+  n, l, h, l0, h0, len: int16;
+  a: array of int32;
+
+begin
+  readln(n);
+  setlength(a, n);
+  for l := 0 to n - 1 do
+    read(a[l]);
+  len := 0;
+  l0 := 0;
+  h0 := 0;
+  l := 0;
+  while l < n do
+    for h := l to n - 1 do
+      if (h = n - 1) or
+         ((a[h] mod a[h + 1]) * (a[h + 1] mod a[h]) > 0) then
+        begin
+          if len < h - l then
+            begin
+              len := h - l;
+              l0 := l;
+              h0 := h
+            end;
+          l := h + 1;
+          break
+        end;
+  writeln(l0 + 1, ' ', h0 + 1)
+end.