S6 Harshad diroc dinh nghia boi D.. Kaprekar, mot nha toan hoc An DQ..[r]
(1)KY THI CHON HOC SINH GIOI cAPHU~N TRUNG HOC CO SO NAM HOC 2018.;.2019 Mon: TINHQC
Thai gian: 150 phut (khong kd thai gian giao tJJ) Ngay thi: 20/02/2019
(D~ thi co 04 trang, g6m 05 hili) TONG QUAN cAc BAI TID
sa GJAO DVC vA J)AoT~O TIENGIANG
BE TID CHiNH TmJC
Ten bai File chllO'ng trinh File dfr lieu vao File ket Qua Bai S6 Harsbad HARS.* HARS.lNP HARS.OUT
Bai2 Bia chi IP IP.* IP.lNP IP.OUT
Bai3 B6n2 b6 d6ix mg CLOCK.* CLOCK.lNP CLOCK.OUT Bai Pbin mnbc')bon ki can NSE.* NSE.lNP NSE.OUT Bai5 S6 eire tri EXTRE.* EXTRE.lNP EXTRE.OUT
Diu * dU"Q"cthay th~ bOiPAS ho,c CPP cua ngon ngft l~p trinh dU'Q"csir dung tuong img lit Pascal ho,c C++
Hiiy [{ip trinh giai cdc bai loan sau: Bili 1:sA Harshad (5 di~m)
S6 Harshad hi met s6 nguyen chia h~t cho t6ng cac chfr s6 cua no S6 Harshad diroc dinh nghia boi D R. Kaprekar, mot nha toan hoc An DQ TiT "Harshad' xudt phat tir tieng Phan (Sanskrit) co nghia la nguoi dua niem vui.
Vi du:24 lamQt s6Harshad vi t6ng cacchfr s6 cuano la2 +4 = 6va24 chia h~t cho 6.
156 cling 1a IDQts6 Harshad vi 1+5 +6= 12 va 156= (12) (13)
157 KHONG phai la s6 Harshad vi no khong chia h~t cho 1+5+7= 13 Yeu cAu: Cho truce s6 nguyen ducmg n, hay tim s6 Harshad nh6 nhdt ~ n Dil Ii~u: Vao tiT file van ban BARS.INP chua s6 nguyen ducmg n:S 109• K~t qua: Ghi file van ban BARS.OUT chua s6 Harshad nh6 nhdt ~ n
I~~BARS.INP I~~BARS.OUT
Bili 2: Dia chi IP (5 di~m)
Dia chi IP (IP la vi~t t~t cua tiT ti~ng Anh: Internet Protocol - giao thuc Internet) 1a mQt dia chi don nhdt rna nhirng thi~t bi di~n tir hi~n dang sir d\lllg de nh~
(2)dien va lien lac voi tren mang may tinh bang each sir dung giao tlnrc Internet
Dia chi IPv4 hop l~ thuong duoc vi~t thee dang g6m b6n nhom s6 th~p phan, ngan each bang d~u cham nhu sau: A.B.C.D, A, B, C va D la cac s6 nguyen tir 0-255 va khong co s6 0ad§.utrirkhi dol! s6 o.
Yeu cAu: DQcvao xau, hay kiem tra cola dia chi IPv4 hop l~khong?
Vi du: xau "25.011.255.255" la khong hop l~ vi "OIl" khong hop l~ (chua s6 a d§.u);xau "250.11.255.256" la khong hop l~ vi "256" khong hop l~(virot qua 255); xau"250.11.255.255" la hop l~
Dft Ii~u: Vao tir file van ban IP.INP chua mQt xau chua cac s6 nguyen '0' '9'
va d~u '.' DQ dai xau khong qua 15
K~t qua: Ghi file van ban IP.OUT chua 'YES" neu la dia chi IPv4 hop l~, ngiroc lai ghi "NO"
IP.INP IP.OUT
250.11.255.255 YES
255.255.011.135 NO
250.11.255.256 NO
Bai 3: Dang dai Xtfog(4 di~m)
D6ng h6 Analog co cach gQi khac la D6ng h6 kim, la mQtlo~i d6ng h6 hiSn thi thai gian bAngcac kim quay tren m~t s6 (kim gia, phut, giay, ) H§.u h~t rnQinguai deu quen thuQcvm cac lo~i d6ng h6 va th\lC hanh dQc chUng rdt nhieu, kS ca cac d6ng h6 khong co s6 Nhfmg chiec d6ng h6 rnm, du atrong cua hi~u hay tren poster quang cao, thu<mg dugc chinh kim c6 diM a luc 10hl0
MQt nhfmg ly cho vi~c dieu chinh thai gian m~c dinh tren hi: la vi tri rna cac kim d6ng h6 d6i xUng Khoa hQc da chUng minh, nguai co xu huang thi~n cam vm cac k~t c~u d6i xUng Vi tri kim d6ng h6 nhu th~,
khi~n cho nhfmg nguai ua hoan hao cam th~y de chiu han va tang suc hftp d~n d6i v6i khach hang
Bay gia, hay tuang tugng nhinth~y ciIng mQt chi~c d6ng h6 thong qua rnQt tb guang Cac d6ng h6 gi6ng nhau, nhung kim gia, kim phut dugc l~t thee dU<mgthbg dUngtir 12den
Yeu cAu: Tim thai gian tren d6ng h6 analog n~u chUng ta nhinvao no guang (khong quan tam d~n kim giay)
11:11 12 :49
(3)Dii' Ii~u: Vao tir file van ban CLOCK.INP g6m m9t dong chua thoi gian co dang h:mm (n~u h tir d~n 9) hoac hh:mm (neu h tir 10 d~n 12), h lei gio, mm lei phut TAt ca thoi gian cho dSu hop l~ thea dinh dang 12 gio (h tir d~n 12, mm tir 00 d~n 59)
K~t qua: Ghi file van ban CLOCK.OUT chua thai gian c~n tim (theo dinh dang h:mm hoac hh:mm)
CLOCK.INP CLOCK OUT
11:11 12:49
1:27 10:33
Bili 4: Phin tfr nho hon k~c,n (3 di~m)
Phan nr nho han kS c~n (Next Smaller Element - NSE) cua phan nr x mot day s6 la phan nr nho hon x xuAt hien d~u tien aben phai cua x day s6 (tinh til vi tri cua x di sang ben phai)
Yeu ciu: V6i mot day s6 cho tnroc, hay xac dinh phk tir nho han kS c~ cua cac phan tu day s6 da cho
LUlly: Cac phk nr rna khong t6n tai phk tUnho han kS c~ dugc xem nhu co ph~n tir nh6 han kS c~n lei-1
Vi d\l:
a) V6i bAtIcy day s6 neio, phk tir qrc phai luon co phk tir nh6 han kS c~ lei-1 b) V 6i bAtIcy day s6 dugc sftP xSp tang d~n, mQi phk tir dSu luon co phk tir nh6 han kS c~ lei-1
c) V 6i day s6 [4, 8, 5, 2, 25], ph~n tir nh6 han kS c~n cua m6i phk tir dugc xac dinh nhu sau:
1=
Day so 25 NSE (i) -1 -1 Dfr li~u: Vao tir file van ban NSE.INP
• Dong dc1uchua sf, nguyen n (1::;n ::;100)
• Dong thu hai chua n sf, nguyen (1::;i::; n) Cae sf, miy duqc each hoi dAucacho
K~t qua: Ghi file van ban NSE.OUT chua n sf, nguyen hi(1::;i::;n), hi hi phlinillnh6 han k€ c~n cua Cae sf, duqc each hOidAueach
NSE.INP 12
NSE.0U'l
5 -1 -1
I~8 5 2 25
(4)Bili 5: sa cvc tr] (3 di~m)
Tim s6 nho nh~tva s6 Ibn nh~t (khong co s6 a dAu) co thS nhan duoc bfutg each s~pxeplai cac chit s6cua IDQt s6dacho
Dil li~u: Vaoillfile van ban EXTRE.INP chua s6nguyen n (1:S n:S 109) K~t qua: Ghi file van ban EXTRE.OUT chua s6 nho nh~t va s6 Ibn nhat theo dinh dang nhu vi du sau:
EXTRE.INP EXTRE.OUT
3891 Inital number = 3891 Smallest number = 1389
Largest number = 9831
Luuy: Giiia cac tir,ddu =va scinguyen dft li~u co dung mot ddu eachva chii cai ddudong la chiiin hoa.
- HET
-• Cdc tdp tin chuang trinh phdi d(lt theo dung quy dinh (ca phdn ten va phdn ma
rong).
• Thi sinh khong duac su dung tai li~u Can bi) coi thi khong giai thich gi them.
HQva ten thi sinh: S6bao danh: