Giải đề thi HSG Tin học lớp 9 với Pascal tỉnh Quảng Bình

Giải đề thi HSG Tin học lớp 9 với Pascal tỉnh Quảng Bình

Trong cuộc thi giải toán qua mạng internet mỗi học sinh đều có số điểm tích lũy riêng của mình. Số điểm tích lũy của mỗi học sinh là một số nguyên dương K (0 < K ≤ 2x10^9). Đội tuyển của trường THCS Tài Năng có N học sinh tham gia dự thi (2 ≤ N ≤ 100). Tại buổi gặp mặt trước kỳ thi cấp tỉnh, thầy hiệu trưởng quyết định thưởng cho các học sinh trong đội tuyển Q triệu đồng, biết rằng điểm tích lũy của mỗi học sinh đều chia hết cho Q.

Yêu cầu: Hãy tìm số nguyên dương Q lớn nhất.

Dữ liệu vào: Cho trong file văn bản PT.INP có cấu trúc như sau:

- Dòng 1: Ghi số nguyên dương N là số lượng học sinh.

- Dòng 2: Ghi N số nguyên dương lần lượt là điểm tích lũy của N học sinh, các số được ghi cách nhau ít nhất một dấu cách.

Dữ liệu ra: Ghi ra file văn bản PT.OUT theo cấu trúc như sau:

- Dòng 1: Ghi số nguyên dương Q tìm được.

Ví dụ: 

PT.INP PT.OUT
5
15   24   45   36   27
3
 

CODE:

Program Phan_thuong;
Const fi='PT.INP';
      fo='PT.OUT';
Type mmc=Array[0..101] of Longint;
Var N:Longint;
    A:mmc;
Function UCLN(x,y:Longint):Longint;
 Var sodu:Word;
 Begin
    sodu:=x mod y;
    While sodu<>0 do
      Begin
        x:=y;
        y:=sodu;
        sodu:=x mod y;
      End;
   UCLN:=y;
End;
Procedure Read_Data;
 Var f:text;
     i:Longint;
 Begin
   Assign(f,fi);
   Reset(f);
   Readln(f,N);
   For i:=1 to N do
      Read(f,A[i]);
   Close(f);
 End;
Function USC:Longint;
Var f:text;
    i,mUSC:longint;
Begin
   mUSC:=UCLN(A[1],A[2]);
   for i:= 3 to N do
      mUSC:=UCLN(mUSC,A[i]);
   USC:=mUSC;
End;
Procedure Write_Data;
Var f:Text;
Begin
   Assign(f,fo);
   Rewrite(f);
   Write(f,USC);
   Close(f);
End;
BEGIN
  Read_Data;
  Write_Data;
End.

 

Bạn thấy bài viết này như thế nào?: 
Average: 8.9 (84 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Using CSS3 transformations and transitions to spice up your web design!

Using CSS3 transformations and transitions to spice up your web design!

Quite often web designers have to come up with a design for a page that needs to be easy to use, without being overly boring. Keeping a minimal and clean design that gives content the prominence it needs

Những checklist cần thiết để Going live Drupal

Những checklist Drupal cần thiết để Going live

So you're launching a new website or replacing an old one and want to make sure everything goes smoothly? This guide will give you a run-down of everything you can check to avoid common pitfalls!

Spaces.module là Drupal Multi-site alternative

Spaces.module là Drupal Multi-site alternative

If you want to share users, content and configuration between Drupal sites you have several options.

Công ty diệt chuột T&C

 

Diet con trung