Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
Bai Tap Pascal Co Ban

Bai Tap Pascal Co Ban

Ratings: (0)|Views: 563 |Likes:
Published by api-26458918

More info:

Published by: api-26458918 on Oct 19, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

B\u00b5i t\u00cbp c\u00ac b\u00b6n\u2013 T\u00cbp I
C\u00b8c b\u00b5i t\u00cbp c\u00ac b\u00b6n
B\u00b5i1. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp s\u00e8 nguy\u00aan d\u00acng N<=1000 v\u00b5 N s\u00e8
nguy\u00aan A[1], . . ., A[N]. H\u00b7y th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh c\u00b8c s\u00e8 sau:
- Gi\u00b8 tr\u00de l\u00edn nh\u00cat c\u00f1a d\u00b7y v\u00b5 c\u00b8c ch\u00d8 s\u00e8 c\u00f1a c\u00b8c s\u00e8 h\u00b9ng \u00ae\u00b9t gi\u00b8 tr\u00de
l\u00edn nh\u00cat.
- Gi\u00b8 tr\u00de nh\u00e1 nh\u00cat c\u00f1a d\u00b7y v\u00b5 c\u00b8c ch\u00d8 s\u00e8 c\u00f1a c\u00b8c s\u00e8 h\u00b9ng \u00ae\u00b9t gi\u00b8 tr\u00de
nh\u00e1 nh\u00cat.
- Gi\u00b8 tr\u00de l\u00edn th\u00f8 nh\u00d7 c\u00f1a d\u00b7y v\u00b5 c\u00b8c ch\u00d8 s\u00e8 c\u00f1a c\u00b8c s\u00e8 h\u00b9ng \u00ae\u00b9t gi\u00b8
tr\u00de l\u00edn nh\u00d7.
- Gi\u00b8 tr\u00de nh\u00e1 th\u00f8 nh\u00d7 c\u00f1a d\u00b7y v\u00b5 c\u00b8c ch\u00d8 s\u00e8 c\u00f1a c\u00b8c s\u00e8 h\u00b9ng \u00ae\u00b9t gi\u00b8
tr\u00de nh\u00e1 nh\u00d7.
- D\u00b7y con g\u00e5m nhi\u00d2u nh\u00cat c\u00b8c s\u00e8 h\u00b9ng li\u00aan ti\u00d5p c\u00f1a d\u00b7y l\u00cbp th\u00b5nh
m\u00e9t c\u00cap s\u00e8 c\u00e9ng
- D\u00b7y con g\u00e5m nhi\u00d2u nh\u00cat c\u00b8c s\u00e8 h\u00b9ng li\u00aan ti\u00d5p c\u00f1a d\u00b7y l\u00cbp th\u00b5nh
m\u00e9t d\u00b7y \u00ae\u00acn \u00aei\u00d6u
- D\u00b7y con g\u00e5m nhi\u00d2u nh\u00cat c\u00b8c s\u00e8 h\u00b9ng li\u00aan ti\u00d5p tr\u00b8i d\u00cau nhau c\u00f1a
d\u00b7y- D\u00b7y con g\u00e5m nhi\u00d2u nh\u00cat c\u00b8c s\u00e8 h\u00b9ng li\u00aan ti\u00d5p c\u00efng d\u00cau c\u00f1a d\u00b7y
B\u00b5i2. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm hai s\u00e8 nguy\u00aan d\u00acng M
v\u00b5 N\u2264 10000 v\u00b5 in ra m\u00b5n h\u00d7nh \u00edc chung l\u00edn nh\u00cat c\u00f1a hai s\u00e8 \u00ae\u00e3.
B\u00b5i3. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm s\u00e8 nguy\u00aan d\u00acng N\u2264
30000 v\u00b5 th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh N c\u00e3 l\u00b5 s\u00e8 nguy\u00aan t\u00e8 hay kh\u00abng.
B\u00b5i4. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm s\u00e8 nguy\u00aan d\u00acng N\u2264
10000 v\u00b5 th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh c\u00b8c s\u00e8 K<=N c\u00e3 b\u00bbng t\u00e6ng c\u00b8c \u00edc
c\u00f1a n\u00e3 v\u00b5 nh\u00e1 h\u00acn n\u00e3? (S\u00e8 K tho\u00b6 m\u00b7n \u00aei\u00d2u ki\u00d6n tr\u00aan \u00ae\u00eec g\u00e4i l\u00b5s\u00e8
ho\u00b5n thi\u00d6n, v\u00dd d\u00f4 6=1+2+3 l\u00b5 s\u00e8 ho\u00b5n thi\u00d6n)
B\u00b5i5. Nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm s\u00e8 nguy\u00aan d\u00acng N<=10000 v\u00b5 N s\u00e8

th\u00f9c A1, . ., AN. H\u00b7y s\u00bep x\u00d5p d\u00b7y \u00ae\u00e3 theo th\u00f8 t\u00f9 kh\u00abng gi\u00b6m. Th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh d\u00b7y \u00ae\u00eec s\u00bep x\u00d5p l\u00b9i \u00ae\u00e3 v\u00b5 ghi r\u00e2 t\u00f5ng s\u00e8 h\u00b9ng l\u00b5 s\u00e8 h\u00b9ng n\u00b5o c\u00f1a d\u00b7y c\u00f2.

B\u00b5i6. C\u00e3 N g\u00e3i k\u00d1o, N<=200, c\u00b8c g\u00e3i k\u00d1o \u00ae\u00eec \u00ae\u00b8nh s\u00e8 t\u00f5 1 \u00ae\u00d5n

N, g\u00e3i k\u00d1o th\u00f8 i c\u00e3 A[i] c\u00b8i k\u00d1o, c\u00b8c s\u00e8 a[1], . ., a[N] \u00ae\u00d2u nguy\u00aan d\u00acng v\u00b5 kh\u00abng qu\u00b8 200. H\u00b7y th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh m\u00e9t c\u00b8ch chia c\u00b8c g\u00e3i k\u00d1o l\u00b5m hai nh\u00e3m sao cho t\u00e6ng s\u00e8 k\u00d1o trong c\u00b8c nh\u00e3m sai kh\u00b8c nhau \u00ddt nh\u00cat.

D\u00f7 li\u00d6u v\u00b5o \u00ae\u00eec cho b\u00ebi file INP.BL trong \u00ae\u00e3 d\u00dfng th\u00f8 nh\u00cat ghi s\u00e8 N v\u00b5 trong c\u00b8c d\u00dfng ti\u00d5p theo, m\u00e7i d\u00dfng ghi 10 s\u00e8 l\u00c7n l\u00eet t\u00f5 A[1] \u00ae\u00d5n A[N].

K\u00d5t qu\u00b6 ghi ra file OUT.BL nh sau: d\u00dfng th\u00f8 nh\u00cat ghi s\u00e8 k\u00d1o ch\u00aanh l\u00d6ch gi\u00f7a hai nh\u00e3m, ti\u00d5p theo l\u00b5 m\u00e9t nh\u00e3m d\u00dfng ghi s\u00e8 hi\u00d6u c\u00b8c g\u00e3i k\u00d1o thu\u00e9c nh\u00e3m th\u00f8 nh\u00cat, m\u00e7i d\u00dfng ghi 20 s\u00e8 hi\u00d6u, cu\u00e8i c\u00efng l\u00b5 m\u00e9t

-1\u2013
L\u00aa Ng\u00e4c Th\u00beng \u2013h o p_ t hu _cu a_b o d ie _3 7@ ya h o o.co m
B\u00b5i t\u00cbp c\u00ac b\u00b6n\u2013 T\u00cbp I
nh\u00e3m d\u00dfng ghi s\u00e8 hi\u00d6u c\u00b8c g\u00e3i k\u00d1o thu\u00e9c nh\u00e3m th\u00f8 hai, m\u00e7i d\u00dfng ghi
20 s\u00e8 hi\u00d6u.
B\u00b5i7. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm b\u00e8n s\u00e8 nguy\u00aan d\u00acng

A, B, C, D, 1<=A<=31, 1<=B<=12, -2000<=C<=2000, 1<=D<=7. \u00fd ngh\u00dca c\u00f1a b\u00e8n s\u00e8 n\u00b5y l\u00b5 ng\u00b5y A th\u00b8ng B n\u00a8m C l\u00b5 ng\u00b5y th\u00f8 D, trong \u00ae\u00e3 1 l\u00b5 ch\u00f1 nh\u00cbt, 2 l\u00b5 th\u00f8 hai, . ., 7 l\u00b5 ng\u00b5y th\u00f8 b\u00b6y. Nh\u00cbp ti\u00d5p ba s\u00e8 nguy\u00aan d\u00acng A1, B1, C1 tho\u00b6 m\u00b7n c\u00b8c \u00aei\u00d2u ki\u00d6n t\u00acng \u00f8ng nh \u00ae\u00e8i v\u00edi A, B, C. H\u00b7y th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh ng\u00b5y A1 th\u00b8ng B1 n\u00a8m C1 l\u00b5 ng\u00b5y th\u00f8 m\u00cay? Bi\u00d5t r\u00bbng n\u00d5u n\u00a8m chia h\u00d5t cho 4, th\u00b8ng 2 c\u00e3 29 ng\u00b5y, c\u00dfn v\u00edi c\u00b8c n\u00a8m kh\u00b8c, th\u00b8ng 2 ch\u00d8 c\u00e3 28 ng\u00b5y.

B\u00b5i8. Cho m\u00e9t h\u00d7nh ch\u00f7 nh\u00cbt c\u00e3 c\u00b8c c\u00b9nh l\u00b5 c\u00b8c s\u00e8 nguy\u00aan d\u00acng

M, N, M v\u00b5 N kh\u00abng qu\u00b8 100. H\u00d7nh ch\u00f7 nh\u00cbt \u00ae\u00eec chia th\u00b5nh c\u00b8c \u00ab vu\u00abng c\u00b9nh \u00ae\u00acn v\u00de b\u00bbng c\u00b8c \u00ae\u00eang song song v\u00edi c\u00b8c c\u00b9nh, c\u00b8c \u00ab n\u00b5y \u00ae\u00eec \u00ae\u00b8nh s\u00e8 nh sau: c\u00b8c d\u00dfng \u00ab \u00ae\u00b8nh s\u00e8 t\u00f5 1 \u00ae\u00d5n M t\u00f5 d\u00edi l\u00aan tr\u00aan, c\u00b8c c\u00e9t \u00ab \u00ae\u00b8nh s\u00e8 t\u00f5 1 \u00ae\u00d5n N t\u00f5 tr\u00b8i sang ph\u00b6i, khi \u00ae\u00e3 m\u00e7i \u00ab \u00ae\u00eec \u00ae\u00c6c trng b\u00ebi ch\u00d8 s\u00e8 d\u00dfng v\u00b5 ch\u00d8 s\u00e8 c\u00e9t c\u00f1a n\u00e3. H\u00b7y ghi ra m\u00b5n h\u00d7nh c\u00b8c \u00ab vu\u00abng c\u00e3 \u00aei\u00d3m chung v\u00edi \u00ae\u00eang ch\u00d0o c\u00f1a h\u00d7nh ch\u00f7 nh\u00cbt \u00aei t\u00f5 g\u00e3c tr\u00b8i tr\u00aan c\u00f1a \u00ab [1,1] \u00ae\u00d5n g\u00e3c ph\u00b6i d\u00edi c\u00f1a \u00ab [M,N].

B\u00b5i9. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp s\u00e8 nguy\u00aan d\u00acng N<=1000 v\u00b5 d\u00b7y N
s\u00e8 nguy\u00aan A[1], . . ., A[N]. H\u00b7y x\u00d0t xem d\u00b7y s\u00e8 \u00ae\u00e3 c\u00e3 bao nhi\u00aau gi\u00b8 tr\u00de
kh\u00b8c nhau v\u00b5 m\u00e7i gi\u00b8 tr\u00de \u00ae\u00e3 l\u00b5 gi\u00b8 tr\u00de c\u00f1a c\u00b8c s\u00e8 h\u00b9ng n\u00b5o c\u00f1a d\u00b7y.
B\u00b5i10. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm hai s\u00e8 nguy\u00aan d\u00acng

M v\u00b5 N, M,N<=10000. H\u00b7y vi\u00d5t ra m\u00b5n h\u00d7nh bi\u00d3u di\u00d4n d\u00edi d\u00b9ng s\u00e8 th\u00cbp ph\u00a9n (n\u00e3i chung l\u00b5 v\u00ab h\u00b9n tu\u00c7n ho\u00b5n) c\u00f1a ph\u00a9n s\u00e8 M/N t\u00f8c l\u00b5 d\u00b9ng

M/N = b1 . .bk,c1. . . cm (d1 . . dr)
V\u00dd d\u00f4 n\u00d5u M=2, N=3, ta ph\u00b6i vi\u00d5t ra m\u00b5n h\u00d7nh 0,(6).
B\u00b5i11. H\u00b7y t\u00d7m m\u00e9t c\u00b8ch bi\u00d3u di\u00d4n c\u00b8c s\u00e8 l\u00edn h\u00b5ng tr\u00a8m ch\u00f7 s\u00e8
v\u00b5 th\u00f9c hi\u00d6n c\u00b8c ph\u00d0p to\u00b8n c\u00e9ng v\u00b5 tr\u00f5.
B\u00b5i12. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm hai s\u00e8 nguy\u00aan d\u00acng
M, N. H\u00b7y t\u00d7m c\u00b8ch thay c\u00b8c d\u00cau ? trong bi\u00d3u th\u00f8c sau b\u00ebi c\u00b8c ph\u00d0p
to\u00b8n +, -, * sao cho gi\u00b8 tr\u00de c\u00f1a bi\u00d3u th\u00f8c nh\u00cbn \u00ae\u00eec b\u00bbng N:
((((M?M)?M)?M)?M)
N\u00d5u kh\u00abng c\u00e3 th\u00d3 \u00ae\u00eec, h\u00b7y th\u00abng b\u00b8o l\u00b5 kh\u00abng th\u00d3 \u00ae\u00eec.
B\u00b5i13. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp m\u00e9t s\u00e8 th\u00f9c d\u00acng R v\u00b5 m\u00e9t s\u00e8
nguy\u00aan d\u00acng MAX. H\u00b7y t\u00d7m trong s\u00e8 c\u00b8c ph\u00a9n s\u00e8 c\u00e3 d\u00b9ng P/Q v\u00edi
Q<=MAX ph\u00a9n s\u00e8 g\u00c7n s\u00e8 R nh\u00cat.
B\u00b5i14. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp s\u00e8 nguy\u00aan d\u00acng N<=30000 v\u00b5
th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh s\u00e8 ch\u00f7 s\u00e8 kh\u00abng t\u00cbn c\u00efng c\u00f1a N!.
-2\u2013
L\u00aa Ng\u00e4c Th\u00beng \u2013h o p_ t hu _cu a_b o d ie _3 7@ ya h o o.co m
B\u00b5i t\u00cbp c\u00ac b\u00b6n\u2013 T\u00cbp I
B\u00b5i15. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm hai x\u00a9u k\u00fd t\u00f9 S1 v\u00b5
S2.1. Th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh \u00ae\u00e9 d\u00b5i c\u00f1a S1 v\u00b5 S2.
2. H\u00b7y x\u00d0t xem S1 c\u00e3 xu\u00cat hi\u00d6n bao nhi\u00aau l\u00c7n trong S2 v\u00b5 xu\u00cat
hi\u00d6n t\u00b9i nh\u00f7ng v\u00de tr\u00dd n\u00b5o?
3. H\u00b7y x\u00d0t xem li\u00d6u S2 c\u00e3 l\u00b5 gh\u00d0p li\u00aan ti\u00d5p c\u00f1a m\u00e9t s\u00e8 l\u00c7n x\u00a9u S1
kh\u00abng?
B\u00b5i16. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp t\u00f5 b\u00b5n ph\u00ddm m\u00e9t k\u00fd t\u00f9 v\u00b5 m\u00e9t
x\u00a9u k\u00fd t\u00f9. H\u00b7y th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh k\u00fd t\u00f9 \u00ae\u00e3 xu\u00cat hi\u00d6n bao nhi\u00aau
l\u00c7n trong x\u00a9u k\u00fd t\u00f9 v\u00b5 t\u00b9i nh\u00f7ng v\u00de tr\u00dd n\u00b5o?
B\u00b5i17. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp 5 s\u00e8 nguy\u00aan A0, A1, A2, A3, A4.
H\u00b7y th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh t\u00d7m m\u00e4i nghi\u00d6m nguy\u00aan c\u00f1a ph\u00acng
tr\u00d7nh
A0 +A1X + A1X2 + A3X3 + A4 X4 = 0
B\u00b5i18. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp m\u00e9t x\u00a9u k\u00fd t\u00f9 S ch\u00d8 g\u00e5m c\u00b8c ch\u00f7
c\u00b8i th\u00eang. H\u00b7y l\u00cbp x\u00a9u S1 nh\u00cbn \u00ae\u00eec t\u00f5 S b\u00bbng c\u00b8ch s\u00bep x\u00d5p l\u00b9i c\u00b8c k\u00fd
t\u00f9 theo v\u00c7n a, b, c, . . .
V\u00dd d\u00f4 n\u00d5u S = 'xbaqp' th\u00d7 S1 = 'abpqx'.
B\u00b5i19. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp 8 s\u00e8 th\u00f9c X1, Y1, X2, Y2, X3, Y3,
X4, Y4, t\u00acng \u00f8ng l\u00b5 to\u00b9 \u00ae\u00e9 c\u00f1a b\u00e8n \u00aei\u00d3m A, B, C, D trong m\u00c6t
ph\u00bcng to\u00b9 \u00ae\u00e9. Th\u00abng b\u00b8o ra m\u00b5n h\u00d7nh c\u00b8c k\u00d5t qu\u00b6 sau:
1. Ba \u00aei\u00d3m A, B, C c\u00e3 l\u00cbp th\u00b5nh m\u00e9t tam gi\u00b8c kh\u00abng?
2. N\u00d5u ABC l\u00b5 m\u00e9t tam gi\u00b8c, h\u00b7y x\u00d0t xem \u00aei\u00d3m D c\u00e3 n\u00bbm b\u00aan
trong tam gi\u00b8c n\u00b5y kh\u00abng?
B\u00b5i20. Vi\u00d5t ch\u00acng tr\u00d7nh nh\u00cbp s\u00e8 nguy\u00aan d\u00acng N<=1000 v\u00b5 d\u00b7y

A g\u00e5m N s\u00e8 nguy\u00aan d\u00acng kh\u00b8c nhau t\u00f5ng \u00ae\u00abi A[1], . ., A[N]. H\u00b7y t\u00d7m m\u00e9t d\u00b7y B g\u00e5m nhi\u00d2u s\u00e8 h\u00b9ng nh\u00cat (kh\u00abng nh\u00cat thi\u00d5t l\u00b5 li\u00aan ti\u00d5p) c\u00f1a A sao cho v\u00edi b\u00cat k\u00fa ba s\u00e8 h\u00b9ng kh\u00b8c nhau X, Y, Z c\u00f1a B, ta lu\u00abn c\u00e3 t\u00e6ng X + Y + Z kh\u00abng l\u00edn h\u00acn t\u00e6ng c\u00b8c s\u00e8 h\u00b9ng c\u00dfn l\u00b9i c\u00f1a B.

B\u00b5i21. Gi\u00b6 s\u00f6 trong m\u00e9t phi\u00aan l\u00b5m vi\u00d6c t\u00f5 th\u00eai \u00aei\u00d3m 0 \u00ae\u00d5n th\u00eai

\u00aei\u00d3m T = 8640000, m\u00e9t trung t\u00a9m t\u00ddnh to\u00b8n ph\u00b6i th\u00f9c hi\u00d6n N ch- \u00acng tr\u00d7nh, ch\u00acng tr\u00d7nh i th\u00f9c hi\u00d6n t\u00f5 th\u00eai \u00aei\u00d3m A[i] \u00ae\u00d5n th\u00eai \u00aei\u00d3m B[i], 0<=A[i]<=B[i]<T.

1. Cho tr\u00edc m\u00e9t kho\u00b6ng th\u00eai gian [P1,Q1]. H\u00b7y x\u00d0t xem li\u00d6u t\u00b9i m\u00e4i
th\u00eai \u00aei\u00d3m c\u00f1a \u00aeo\u00b9n \u00ae\u00e3 lu\u00abn c\u00e3 ch\u00acng tr\u00d7nh ch\u00b9y hay kh\u00abng?
2. Cho tr\u00edc m\u00e9t kho\u00b6ng th\u00eai gian [R1,S1]. H\u00b7y x\u00d0t xem li\u00d6u t\u00b9i m\u00e4i
th\u00eai \u00aei\u00d3m c\u00f1a \u00aeo\u00b9n \u00ae\u00e3 lu\u00abn kh\u00abng c\u00e3 ch\u00acng tr\u00d7nh ch\u00b9y hay kh\u00abng?
3. H\u00b7y t\u00d7m kho\u00b6ng th\u00eai gian [P,Q] d\u00b5i nh\u00cat sao cho t\u00b9i m\u00e4i th\u00eai
\u00aei\u00d3m c\u00f1a n\u00e3 lu\u00abn c\u00e3 ch\u00acng tr\u00d7nh ch\u00b9y.
4. H\u00b7y t\u00d7m kho\u00b6ng th\u00eai gian [R,S] d\u00b5i nh\u00cat sao cho t\u00b9i m\u00e4i th\u00eai
\u00aei\u00d3m c\u00f1a n\u00e3 \u00ae\u00d2u kh\u00abng c\u00e3 ch\u00acng tr\u00d7nh ch\u00b9y.
-3\u2013
L\u00aa Ng\u00e4c Th\u00beng \u2013h o p_ t hu _cu a_b o d ie _3 7@ ya h o o.co m

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Trúc Bùi liked this
tuananh06091 liked this
tuananh06091 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->