From 87d51fb251a5b734c2b1853e4fbdd6f6d48551bc Mon Sep 17 00:00:00 2001 From: Nyagami Date: Thu, 15 Dec 2022 23:51:04 +0700 Subject: [PATCH] first commit --- CHELLO - Hello World.java | 5 + HELLOFILE - HELLO FILE.java | 18 +++ HELLOJAR - HỌC PHÍ.java | 62 +++++++++ J01001 - HÌNH CHỮ NHẬT.java | 16 +++ J01002 - TÍNH TỔNG.java | 14 +++ J01003 - GIẢI PHƯƠNG TRÌNH BẬC NHẤT.java | 15 +++ J01004 - SỐ NGUYÊN TỐ.java | 25 ++++ J01005 - CHIA TAM GIÁC.java | 19 +++ J01006 - TÍNH SỐ FIBONACCI.java | 16 +++ J01007 - KIỂM TRA SỐ FIBONACCI.java | 26 ++++ J01008 - PHÂN TÍCH THỪA SỐ NGUYÊN TỐ.java | 29 +++++ J01009 - TỔNG GIAI THỪA.java | 30 +++++ J01010 - CẮT ĐÔI.java | 37 ++++++ J01011 - BỘI SỐ CHUNG - ƯỚC SỐ CHUNG.java | 23 ++++ J01012 - ƯỚC SỐ CHIA HẾT CHO 2.java | 28 +++++ J01013 - TỔNG ƯỚC SỐ - 1.java | 30 +++++ J01014 - ƯỚC SỐ NGUYÊN TỐ LỚN NHẤT.java | 26 ++++ J01016 - CHỮ SỐ 4 VÀ CHỮ SỐ 7.java | 17 +++ J01017 - SỐ LIỀN KỀ.java | 22 ++++ J01018 - SỐ KHÔNG LIỀN KỀ.java | 25 ++++ J01020 - ĐẦY ĐỦ CÁC CHỮ SỐ.java | 30 +++++ J01021 - TÍNH LŨY THỪA.java | 23 ++++ J01022 - XÂU NHỊ PHÂN.java | 31 +++++ J01023 - TOÁN LỚP BA.java | 63 ++++++++++ J01024 - SỐ TAM PHÂN.java | 21 ++++ J01025 - HÌNH VUÔNG.java | 22 ++++ J01026 - SỐ CHÍNH PHƯƠNG.java | 19 +++ J02004 - MẢNG ĐỐI XỨNG.java | 23 ++++ J02005 - GIAO CỦA HAI DÃY SỐ.java | 35 ++++++ J02006 - HỢP CỦA HAI DÃY SỐ.java | 33 +++++ J02007 - ĐẾM SỐ LẦN XUẤT HIỆN.java | 31 +++++ ... NHỎ NHẤT CỦA N SỐ NGUYÊN DƯƠNG ĐẦU TIÊN.java | 24 ++++ J02009 - XẾP HÀNG.java | 28 +++++ J02010 - SẮP XẾP ĐỔI CHỖ TRỰC TIẾP.java | 34 +++++ J02011 - SẮP XẾP CHỌN.java | 36 ++++++ J02012 - SẮP XẾP CHÈN.java | 27 ++++ J02013 - SẮP XẾP NỔI BỌT.java | 44 +++++++ J02014 - ĐIỂM CÂN BẰNG.java | 29 +++++ J02016 - BỘ BA SỐ PYTAGO.java | 33 +++++ J02017 - THU GỌN DÃY SỐ.java | 23 ++++ J02019 - TỔNG ƯỚC SỐ - 2.java | 40 ++++++ J02020 - LIỆT KÊ TỔ HỢP - 1.java | 30 +++++ J02021 - LIỆT KÊ TỔ HỢP - 2.java | 30 +++++ J02022 - SỐ XA CÁCH.java | 36 ++++++ J02023 - LỰA CHỌN THAM LAM.java | 29 +++++ J02024 - DÃY CON CÓ TỔNG LẺ.java | 41 ++++++ J02025 - DÃY CON CÓ TỔNG NGUYÊN TỐ.java | 47 +++++++ J02026 - DÃY CON CÓ K PHẦN TỬ TĂNG DẦN.java | 26 ++++ J02027 - KHOẢNG CÁCH NHỎ HƠN K.java | 28 +++++ J02028 - DÃY CON LIÊN TIẾP TỔNG BẰNG K.java | 35 ++++++ J02033 - ĐẢO DẤU.java | 28 +++++ J02034 - BỔ SUNG DÃY SỐ.java | 27 ++++ J02035 - QUAY PHẢI.java | 23 ++++ J020356 - LỰA CHỌN THAM LAM.java | 29 +++++ J02036 - ƯỚC SỐ CHUNG LỚN NHẤT.java | 33 +++++ J02037 - DÃY ƯU THẾ.java | 22 ++++ J02101 - IN MA TRẬN.java | 29 +++++ J02102 - MA TRẬN XOẮN ỐC TĂNG DẦN.java | 50 ++++++++ ...3 - TÍCH MA TRẬN VỚI CHUYỂN VỊ CỦA NÓ.java | 45 +++++++ J02104 - DANH SÁCH CẠNH.java | 21 ++++ J02105 - DANH SÁCH KỀ.java | 21 ++++ J02106 - MA TRẬN NHỊ PHÂN.java | 19 +++ J03004 - CHUẨN HÓA XÂU HỌ TÊN - 1.java | 33 +++++ J03005 - CHUẨN HÓA XÂU HỌ TÊN - 2.java | 35 ++++++ J03006 - SỐ ĐẸP 1.java | 22 ++++ J03007 - SỐ ĐẸP 2.java | 23 ++++ J03008 - SỐ ĐẸP 3.java | 22 ++++ J03009 - TẬP TỪ RIÊNG CỦA HAI XÂU.java | 37 ++++++ J03010 - ĐỊA CHỈ EMAIL.java | 31 +++++ ...ỚC SỐ CHUNG LỚN NHẤT CỦA SỐ NGUYÊN LỚN.java | 18 +++ J03012 - TỔNG SỐ NGUYÊN LỚN - 1.java | 13 ++ J03013 - HIỆU SỐ NGUYÊN LỚN - 1.java | 17 +++ J03014 - TỔNG SỐ NGUYÊN LỚN - 2.java | 13 ++ J03015 - HIỆU SỐ NGUYÊN LỚN - 2.java | 14 +++ J03016 - CHIA HẾT CHO 11.java | 14 +++ J03017 - LOẠI BỎ “100”.java | 33 +++++ J03018 - TÌM SỐ DƯ.java | 22 ++++ J03019 - XÂU CON LỚN NHẤT.java | 31 +++++ J03020 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java | 61 +++++++++ J03021 - ĐIỆN THOẠI CỤC GẠCH.java | 35 ++++++ J03022 - XỬ LÝ VĂN BẢN.java | 19 +++ J03023 - SỐ LA MÃ.java | 30 +++++ J03024 - SỐ ƯU THẾ.java | 29 +++++ J03025 - XÂU ĐỐI XỨNG.java | 18 +++ J03026 - XÂU KHÁC NHAU DÀI NHẤT.java | 22 ++++ J03027 - RÚT GỌN XÂU KÝ TỰ.java | 20 +++ J03028 - MÃ HÓA DRM.java | 37 ++++++ J03029 - CHUẨN HÓA CÂU.java | 36 ++++++ J03030 - BIẾN ĐỔI A – B.java | 25 ++++ J03031 - XÂU ĐẦY ĐỦ.java | 18 +++ J03032 - ĐẢO TỪ.java | 22 ++++ J03033 - BỘI SỐ CHUNG NHỎ NHẤT.java | 19 +++ J03035 - ĐIỀN CHỮ SỐ.java | 46 +++++++ J03036 - XOAY VÒNG KÝ TỰ.java | 39 ++++++ J03037 - VÒNG TRÒN.java | 35 ++++++ J03038 - ĐÁNH DẤU CHỮ CÁI.java | 34 +++++ J03039 - CHIA HẾT.java | 16 +++ J03040 - BIỂN SỐ ĐẸP.java | 32 +++++ J04001 - KHAI BÁO LỚP POINT.java | 25 ++++ J04002 - KHAI BÁO LỚP HÌNH CHỮ NHẬT.java | 17 +++ J04003 - PHÂN SỐ.java | 16 +++ J04004 - TỔNG PHÂN SỐ.java | 21 ++++ J04005 - KHAI BÁO LỚP THÍ SINH.java | 24 ++++ J04006 - KHAI BÁO LỚP SINH VIÊN.java | 14 +++ J04007 - KHAI BÁO LỚP NHÂN VIÊN.java | 8 ++ J04008 - CHU VI TAM GIÁC.java | 32 +++++ J04009 - DIỆN TÍCH TAM GIÁC.java | 54 ++++++++ ...ỆN TÍCH HÌNH TRÒN NGOẠI TIẾP TAM GIÁC.java | 56 +++++++++ J04011 - BỐN ĐIỂM TRÊN MẶT PHẲNG.java | 94 ++++++++++++++ J04012 - BÀI TOÁN TÍNH CÔNG.java | 31 +++++ J04013 - BÀI TOÁN TUYỂN SINH.java | 52 ++++++++ J04014 - TÍNH TOÁN PHÂN SỐ.java | 63 ++++++++++ J04015 - TÍNH THU NHẬP GIÁO VIÊN.java | 15 +++ J04016 - TÍCH HAI ĐỐI TƯỢNG MA TRẬN.java | 71 +++++++++++ ...17 - TÍCH MA TRẬN VÀ CHUYỂN VỊ CỦA NÓ.java | 86 +++++++++++++ J04018 - SỐ PHỨC.java | 44 +++++++ J04019 - LỚP TRIANGLE - 1.java | 67 ++++++++++ J04020 - LỚP PAIR.java | 63 ++++++++++ J04021 - LỚP INTSET.java | 49 ++++++++ J04022 - WORDSET.java | 59 +++++++++ ...3 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 1.java | 28 +++++ ...4 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 2.java | 38 ++++++ ...5 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 3.java | 60 +++++++++ J05006 - DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java | 52 ++++++++ ...SẮP XẾP DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java | 62 +++++++++ J05008 - DIỆN TÍCH ĐA GIÁC.java | 23 ++++ J05009 - TÌM THỦ KHOA CỦA KỲ THI.java | 57 +++++++++ J05010 - SẮP XẾP DANH SÁCH MẶT HÀNG.java | 54 ++++++++ J05011 - TÍNH GIỜ.java | 41 ++++++ J05012 - TÍNH TIỀN.java | 37 ++++++ J05013 - TUYỂN DỤNG.java | 45 +++++++ J05014 - TUYỂN GIÁO VIÊN.java | 56 +++++++++ J05015 - ĐUA XE ĐẠP.java | 44 +++++++ J05016 - HÓA ĐƠN KHÁCH SẠN.java | 74 +++++++++++ J05017 - HÓA ĐƠN TIỀN NƯỚC.java | 45 +++++++ J05018 - BẢNG ĐIỂM HỌC SINH.java | 54 ++++++++ J05019 - LƯỢNG MƯA TRUNG BÌNH.java | 57 +++++++++ J05020 - SẮP XẾP SINH VIÊN THEO LỚP.java | 56 +++++++++ J05021 - SẮP XẾP THEO MÃ SINH VIÊN.java | 51 ++++++++ J05022 - LIỆT KÊ SINH VIÊN THEO LỚP.java | 59 +++++++++ J05023 - LIỆT KÊ SINH VIÊN THEO KHÓA.java | 59 +++++++++ J05024 - LIỆT KÊ SINH VIÊN THEO NGÀNH.java | 71 +++++++++++ J05025 - SẮP XẾP DANH SÁCH GIẢNG VIÊN.java | 38 ++++++ ...26 - DANH SÁCH GIẢNG VIÊN THEO BỘ MÔN.java | 48 +++++++ J05027 - TÌM KIẾM GIẢNG VIÊN.java | 50 ++++++++ ...ANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 1.java | 33 +++++ ...ANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 2.java | 40 ++++++ J05030 - BẢNG ĐIỂM THÀNH PHẦN - 1.java | 37 ++++++ J05031 - BẢNG ĐIỂM THÀNH PHẦN - 2.java | 37 ++++++ J05032 - TRẺ NHẤT – GIÀ NHẤT.java | 41 ++++++ J05033 - SẮP XẾP THỜI GIAN.java | 29 +++++ J05034 - DANH SÁCH THỰC TẬP - 1.java | 45 +++++++ J05035 - DANH SÁCH THỰC TẬP - 2.java | 45 +++++++ J05036 - TÍNH GIÁ BÁN - 1.java | 34 +++++ J05037 - TÍNH GIÁ BÁN - 2.java | 38 ++++++ J05038 - BẢNG KÊ TIỀN LƯƠNG.java | 47 +++++++ J05040 - LẬP BẢNG TÍNH CÔNG.java | 42 +++++++ J05041 - SẮP XẾP BẢNG TÍNH CÔNG.java | 43 +++++++ J05042 - BẢNG XẾP HẠNG.java | 34 +++++ J05043 - TÍNH THU NHẬP CHO NHÂN VIÊN.java | 46 +++++++ J05044 - LIỆT KÊ NHÂN VIÊN THEO CHỨC VỤ.java | 51 ++++++++ J05045 - SẮP XẾP NHÂN VIÊN THEO THU NHẬP.java | 52 ++++++++ J05046 - BẢNG KÊ NHẬP KHO.java | 46 +++++++ ...NG KÊ NHẬP KHO SẮP XẾP THEO CHIẾT KHẤU.java | 47 +++++++ J05048 - BẢNG THEO DÕI NHẬP XUẤT HÀNG.java | 46 +++++++ ...49 - LIỆT KÊ NHẬP XUẤT HÀNG THEO NHÓM.java | 50 ++++++++ J05050 - TÍNH TIỀN ĐIỆN.java | 43 +++++++ J05051 - SẮP XẾP BẢNG TÍNH TIỀN ĐIỆN.java | 44 +++++++ J05052 - TRA CỨU ĐƠN HÀNG.java | 37 ++++++ J05053 - SẮP XẾP ĐƠN HÀNG.java | 38 ++++++ J05054 - XẾP HẠNG HỌC SINH.java | 51 ++++++++ J05055 - XẾP HẠNG VẬN ĐỘNG VIÊN - 1.java | 68 ++++++++++ J05056 - XẾP HẠNG VẬN ĐỘNG VIÊN - 2.java | 69 ++++++++++ J05057 - BẢNG ĐIỂM TUYỂN SINH.java | 42 +++++++ J05058 - SẮP XẾP KẾT QUẢ TUYỂN SINH.java | 46 +++++++ J05059 - XÁC ĐỊNH DANH SÁCH TRÚNG TUYỂN.java | 67 ++++++++++ J05060 - KẾT QUẢ XÉT TUYỂN.java | 46 +++++++ J05061 - SẮP XẾP KẾT QUẢ XÉT TUYỂN.java | 50 ++++++++ J05062 - HỌC BỔNG SINH VIÊN.java | 68 ++++++++++ J05063 - TỔNG ĐA THỨC.java | 85 +++++++++++++ J05064 - BẢNG THU NHẬP GIÁO VIÊN.java | 55 ++++++++ J05065 - LIỆT KÊ NHÂN VIÊN THEO NHÓM.java | 65 ++++++++++ J05066 - TÌM KIẾM NHÂN VIÊN THEO TÊN.java | 65 ++++++++++ J05067 - QUẢN LÝ KHO XĂNG DẦU.java | 55 ++++++++ J05068 - SẮP XẾP BẢNG GIÁ XĂNG DẦU.java | 56 +++++++++ J05069 - CÂU LẠC BỘ BÓNG ĐÁ - 1.java | 57 +++++++++ J05070 - CÂU LẠC BỘ BÓNG ĐÁ - 2.java | 61 +++++++++ ...71 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 1.java | 83 ++++++++++++ ...72 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 2.java | 86 +++++++++++++ J05073 - TÍNH TOÁN GIÁ BÁN.java | 52 ++++++++ J05074 - ĐIỂM DANH - 1.java | 55 ++++++++ J05075 - ĐIỂM DANH - 2.java | 58 +++++++++ J05076 - NHẬP XUẤT HÀNG.java | 67 ++++++++++ J05077 - TÍNH LƯƠNG.java | 81 ++++++++++++ J05078 - BẢNG LƯƠNG THEO PHÒNG BAN.java | 92 ++++++++++++++ J05079 - LỚP HỌC PHẦN – 1.java | 61 +++++++++ J05080 - LỚP HỌC PHẦN – 2.java | 65 ++++++++++ J05081 - DANH SÁCH MẶT HÀNG.java | 50 ++++++++ J05082 - DANH SÁCH KHÁCH HÀNG.java | 61 +++++++++ J06001 - TÍNH TOÁN HÓA ĐƠN BÁN QUẦN ÁO.java | 87 +++++++++++++ J06002 - SẮP XẾP HÓA ĐƠN BÁN QUẦN ÁO.java | 90 +++++++++++++ J06003 - QUẢN LÝ BÀI TẬP NHÓM – 1.java | 52 ++++++++ J06004 - QUẢN LÝ BÀI TẬP NHÓM – 2.java | 44 +++++++ J06005 - QUẢN LÝ BÁN HÀNG – 1.java | 106 ++++++++++++++++ J06006 - QUẢN LÝ BÁN HÀNG – 2.java | 110 ++++++++++++++++ J06007 - BẢNG TÍNH GIỜ CHUẨN.java | 62 +++++++++ ... - TÍNH GIỜ CHUẨN CHO TỪNG GIẢNG VIÊN.java | 119 ++++++++++++++++++ J07001 - ĐỌC FILE VĂN BẢN.java | 17 +++ J07002 - TÍNH TỔNG.java | 25 ++++ J07003 - TÁCH ĐÔI VÀ TÍNH TỔNG.java | 24 ++++ J07004 - SỐ KHÁC NHAU TRONG FILE - 1.java | 24 ++++ J07005 - SỐ KHÁC NHAU TRONG FILE - 2.java | 17 +++ J07006 - SỐ KHÁC NHAU TRONG FILE - 3.java | 17 +++ J07007 - LIỆT KÊ TỪ KHÁC NHAU.java | 42 +++++++ J07008 - DÃY CON TĂNG DẦN.java | 30 +++++ J07009 - LỚP INTSET - 2.java | 55 ++++++++ ... - DANH SÁCH SINH VIÊN TRONG FILE - 2.java | 26 ++++ ...NG KÊ TỪ KHÁC NHAU TRONG FILE VĂN BẢN.java | 60 +++++++++ ...NG KÊ TỪ KHÁC NHAU TRONG FILE NHỊ PHÂN.java | 48 +++++++ ...NH SÁCH SINH VIÊN TRONG FILE NHỊ PHÂN.java | 40 ++++++ ...14 - HỢP VÀ GIAO CỦA HAI FILE VĂN BẢN.java | 60 +++++++++ ...15 - SỐ NGUYÊN TỐ TRONG FILE NHỊ PHÂN.java | 26 ++++ ... SỐ NGUYÊN TỐ TRONG HAI FILE NHỊ PHÂN.java | 42 +++++++ J07017 - LỚP PAIR (generic).java | 65 ++++++++++ J07018 - CHUẨN HÓA DANH SÁCH SINH VIÊN.java | 50 ++++++++ J07019 - HÓA ĐƠN - 1.java | 88 +++++++++++++ J07020 - HÓA ĐƠN - 2.java | 109 ++++++++++++++++ J07021 - CHUẨN HÓA XÂU HỌ TÊN TRONG FILE.java | 28 +++++ J07022 - LOẠI BỎ SỐ NGUYÊN.java | 26 ++++ J07023 - NGUYÊN TỐ VÀ THUẬN NGHỊCH.java | 63 ++++++++++ J07024 - HIỆU CỦA HAI TẬP TỪ.java | 52 ++++++++ J07025 - DANH SÁCH KHÁCH HÀNG TRONG FILE.java | 58 +++++++++ J07027 - QUẢN LÝ BÀI TẬP NHÓM.java | 59 +++++++++ J07028 - TÍNH GIỜ CHUẨN.java | 65 ++++++++++ ...29 - SỐ NGUYÊN TỐ LỚN NHẤT TRONG FILE.java | 28 +++++ J07030 - CẶP SỐ NGUYÊN TỐ TRONG FILE - 1.java | 25 ++++ J07031 - CẶP SỐ NGUYÊN TỐ TRONG FILE 2.java | 26 ++++ J07032 - SỐ THUẬN NGHỊCH TRONG FILE.java | 48 +++++++ ... - DANH SÁCH SINH VIÊN TRONG FILE - 1.java | 58 +++++++++ J07034 - DANH SÁCH MÔN HỌC.java | 43 +++++++ J07035 - BẢNG ĐIỂM THEO MÔN HỌC.java | 91 ++++++++++++++ J07036 - BẢNG ĐIỂM THEO LỚP.java | 91 ++++++++++++++ J07037 - DANH SÁCH DOANH NGHIỆP.java | 43 +++++++ J07038 - DANH SÁCH THỰC TẬP - 3.java | 86 +++++++++++++ J07040 - LIỆT KÊ THEO THỨ TỰ XUẤT HIỆN.java | 28 +++++ J07041 - LIỆT KÊ CẶP SỐ - 1.java | 43 +++++++ J07042 - LIỆT KÊ CẶP SỐ - 2.java | 53 ++++++++ J07045 - LOẠI PHÒNG.java | 56 +++++++++ J07046 - DANH SÁCH LƯU TRÚ.java | 46 +++++++ J07047 - QUẢN LÝ KHÁCH SẠN.java | 70 +++++++++++ J07048 - DANH SÁCH SẢN PHẨM – 2.java | 38 ++++++ J07049 - TÍNH NGÀY HẾT HẠN BẢO HÀNH.java | 78 ++++++++++++ J07050 - SẮP XẾP MẶT HÀNG.java | 43 +++++++ J07051 - TÍNH TIỀN PHÒNG.java | 66 ++++++++++ J07052 - DANH SÁCH TRÚNG TUYỂN.java | 76 +++++++++++ J07053 - XÉT TUYỂN.java | 63 ++++++++++ J07054 - TÍNH ĐIỂM TRUNG BÌNH.java | 54 ++++++++ J07055 - XẾP LOẠI.java | 52 ++++++++ J07056 - TÍNH TIỀN ĐIỆN.java | 61 +++++++++ J07057 - ĐIỂM TUYỂN SINH.java | 97 ++++++++++++++ J07058 - DANH SÁCH MÔN THI.java | 42 +++++++ J07059 - DANH SÁCH CA THI.java | 63 ++++++++++ J07060 - SẮP XẾP LỊCH THI.java | 83 ++++++++++++ J07071 - TÊN VIẾT TẮT.java | 73 +++++++++++ J07072 - CHUẨN HÓA VÀ SẮP XẾP.java | 47 +++++++ J07073 - ĐĂNG KÝ HÌNH THỨC GIẢNG DẠY.java | 46 +++++++ J07074 - LỊCH GIẢNG DẠY THEO MÔN HỌC.java | 82 ++++++++++++ J07075 - LỊCH GIẢNG DẠY THEO GIẢNG VIÊN.java | 71 +++++++++++ J07076 - SẮP XẾP MA TRẬN.java | 38 ++++++ J07077 - TÍNH GIÁ TRỊ BIỂU THỨC.java | 77 ++++++++++++ J07078 - TÌM VỊ TRÍ XÂU CON.java | 26 ++++ J07081 - SẮP XẾP DANH SÁCH SINH VIÊN.java | 41 ++++++ J07084 - THỜI GIAN ONLINE LIÊN TỤC.java | 39 ++++++ J07085 - TỔNG CHỮ SỐ.java | 26 ++++ J08010 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java | 61 +++++++++ J08011 - LIỆT KÊ VÀ ĐẾM.java | 50 ++++++++ J08012 - HÌNH SAO.java | 22 ++++ J08015 - CẶP SỐ CÓ TỔNG BẰNG K.java | 35 ++++++ J08020 - KIỂM TRA DÃY NGOẶC ĐÚNG.java | 25 ++++ J08021 - DÃY NGOẶC ĐÚNG DÀI NHẤT.java | 30 +++++ ...2 - PHẦN TỬ BÊN PHẢI ĐẦU TIÊN LỚN HƠN.java | 30 +++++ J08023 - HÌNH CHỮ NHẬT LỚN NHẤT.java | 32 +++++ J08024 - SỐ 0 VÀ SỐ 9.java | 28 +++++ J08025 - QUAY HÌNH VUÔNG.java | 51 ++++++++ J08026 - BIẾN ĐỔI S – T.java | 21 ++++ J08027 - GÕ BÀN PHÍM.java | 27 ++++ J08028 - HÌNH CHỮ NHẬT ĐƠN SẮC.java | 39 ++++++ J08029 - QUÂN MÃ.java | 59 +++++++++ JKT013 - SỐ LỘC PHÁT.java | 38 ++++++ JKT014 - ĐẦU TƯ CHỨNG KHOÁN.java | 32 +++++ JKT015 - GÕ BÀN PHÍM.java | 25 ++++ TN02012 - TÍNH LƯƠNG.java | 81 ++++++++++++ 292 files changed, 12623 insertions(+) create mode 100644 CHELLO - Hello World.java create mode 100644 HELLOFILE - HELLO FILE.java create mode 100644 HELLOJAR - HỌC PHÍ.java create mode 100644 J01001 - HÌNH CHỮ NHẬT.java create mode 100644 J01002 - TÍNH TỔNG.java create mode 100644 J01003 - GIẢI PHƯƠNG TRÌNH BẬC NHẤT.java create mode 100644 J01004 - SỐ NGUYÊN TỐ.java create mode 100644 J01005 - CHIA TAM GIÁC.java create mode 100644 J01006 - TÍNH SỐ FIBONACCI.java create mode 100644 J01007 - KIỂM TRA SỐ FIBONACCI.java create mode 100644 J01008 - PHÂN TÍCH THỪA SỐ NGUYÊN TỐ.java create mode 100644 J01009 - TỔNG GIAI THỪA.java create mode 100644 J01010 - CẮT ĐÔI.java create mode 100644 J01011 - BỘI SỐ CHUNG - ƯỚC SỐ CHUNG.java create mode 100644 J01012 - ƯỚC SỐ CHIA HẾT CHO 2.java create mode 100644 J01013 - TỔNG ƯỚC SỐ - 1.java create mode 100644 J01014 - ƯỚC SỐ NGUYÊN TỐ LỚN NHẤT.java create mode 100644 J01016 - CHỮ SỐ 4 VÀ CHỮ SỐ 7.java create mode 100644 J01017 - SỐ LIỀN KỀ.java create mode 100644 J01018 - SỐ KHÔNG LIỀN KỀ.java create mode 100644 J01020 - ĐẦY ĐỦ CÁC CHỮ SỐ.java create mode 100644 J01021 - TÍNH LŨY THỪA.java create mode 100644 J01022 - XÂU NHỊ PHÂN.java create mode 100644 J01023 - TOÁN LỚP BA.java create mode 100644 J01024 - SỐ TAM PHÂN.java create mode 100644 J01025 - HÌNH VUÔNG.java create mode 100644 J01026 - SỐ CHÍNH PHƯƠNG.java create mode 100644 J02004 - MẢNG ĐỐI XỨNG.java create mode 100644 J02005 - GIAO CỦA HAI DÃY SỐ.java create mode 100644 J02006 - HỢP CỦA HAI DÃY SỐ.java create mode 100644 J02007 - ĐẾM SỐ LẦN XUẤT HIỆN.java create mode 100644 J02008 - BỘI SỐ NHỎ NHẤT CỦA N SỐ NGUYÊN DƯƠNG ĐẦU TIÊN.java create mode 100644 J02009 - XẾP HÀNG.java create mode 100644 J02010 - SẮP XẾP ĐỔI CHỖ TRỰC TIẾP.java create mode 100644 J02011 - SẮP XẾP CHỌN.java create mode 100644 J02012 - SẮP XẾP CHÈN.java create mode 100644 J02013 - SẮP XẾP NỔI BỌT.java create mode 100644 J02014 - ĐIỂM CÂN BẰNG.java create mode 100644 J02016 - BỘ BA SỐ PYTAGO.java create mode 100644 J02017 - THU GỌN DÃY SỐ.java create mode 100644 J02019 - TỔNG ƯỚC SỐ - 2.java create mode 100644 J02020 - LIỆT KÊ TỔ HỢP - 1.java create mode 100644 J02021 - LIỆT KÊ TỔ HỢP - 2.java create mode 100644 J02022 - SỐ XA CÁCH.java create mode 100644 J02023 - LỰA CHỌN THAM LAM.java create mode 100644 J02024 - DÃY CON CÓ TỔNG LẺ.java create mode 100644 J02025 - DÃY CON CÓ TỔNG NGUYÊN TỐ.java create mode 100644 J02026 - DÃY CON CÓ K PHẦN TỬ TĂNG DẦN.java create mode 100644 J02027 - KHOẢNG CÁCH NHỎ HƠN K.java create mode 100644 J02028 - DÃY CON LIÊN TIẾP TỔNG BẰNG K.java create mode 100644 J02033 - ĐẢO DẤU.java create mode 100644 J02034 - BỔ SUNG DÃY SỐ.java create mode 100644 J02035 - QUAY PHẢI.java create mode 100644 J020356 - LỰA CHỌN THAM LAM.java create mode 100644 J02036 - ƯỚC SỐ CHUNG LỚN NHẤT.java create mode 100644 J02037 - DÃY ƯU THẾ.java create mode 100644 J02101 - IN MA TRẬN.java create mode 100644 J02102 - MA TRẬN XOẮN ỐC TĂNG DẦN.java create mode 100644 J02103 - TÍCH MA TRẬN VỚI CHUYỂN VỊ CỦA NÓ.java create mode 100644 J02104 - DANH SÁCH CẠNH.java create mode 100644 J02105 - DANH SÁCH KỀ.java create mode 100644 J02106 - MA TRẬN NHỊ PHÂN.java create mode 100644 J03004 - CHUẨN HÓA XÂU HỌ TÊN - 1.java create mode 100644 J03005 - CHUẨN HÓA XÂU HỌ TÊN - 2.java create mode 100644 J03006 - SỐ ĐẸP 1.java create mode 100644 J03007 - SỐ ĐẸP 2.java create mode 100644 J03008 - SỐ ĐẸP 3.java create mode 100644 J03009 - TẬP TỪ RIÊNG CỦA HAI XÂU.java create mode 100644 J03010 - ĐỊA CHỈ EMAIL.java create mode 100644 J03011 - ƯỚC SỐ CHUNG LỚN NHẤT CỦA SỐ NGUYÊN LỚN.java create mode 100644 J03012 - TỔNG SỐ NGUYÊN LỚN - 1.java create mode 100644 J03013 - HIỆU SỐ NGUYÊN LỚN - 1.java create mode 100644 J03014 - TỔNG SỐ NGUYÊN LỚN - 2.java create mode 100644 J03015 - HIỆU SỐ NGUYÊN LỚN - 2.java create mode 100644 J03016 - CHIA HẾT CHO 11.java create mode 100644 J03017 - LOẠI BỎ “100”.java create mode 100644 J03018 - TÌM SỐ DƯ.java create mode 100644 J03019 - XÂU CON LỚN NHẤT.java create mode 100644 J03020 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java create mode 100644 J03021 - ĐIỆN THOẠI CỤC GẠCH.java create mode 100644 J03022 - XỬ LÝ VĂN BẢN.java create mode 100644 J03023 - SỐ LA MÃ.java create mode 100644 J03024 - SỐ ƯU THẾ.java create mode 100644 J03025 - XÂU ĐỐI XỨNG.java create mode 100644 J03026 - XÂU KHÁC NHAU DÀI NHẤT.java create mode 100644 J03027 - RÚT GỌN XÂU KÝ TỰ.java create mode 100644 J03028 - MÃ HÓA DRM.java create mode 100644 J03029 - CHUẨN HÓA CÂU.java create mode 100644 J03030 - BIẾN ĐỔI A – B.java create mode 100644 J03031 - XÂU ĐẦY ĐỦ.java create mode 100644 J03032 - ĐẢO TỪ.java create mode 100644 J03033 - BỘI SỐ CHUNG NHỎ NHẤT.java create mode 100644 J03035 - ĐIỀN CHỮ SỐ.java create mode 100644 J03036 - XOAY VÒNG KÝ TỰ.java create mode 100644 J03037 - VÒNG TRÒN.java create mode 100644 J03038 - ĐÁNH DẤU CHỮ CÁI.java create mode 100644 J03039 - CHIA HẾT.java create mode 100644 J03040 - BIỂN SỐ ĐẸP.java create mode 100644 J04001 - KHAI BÁO LỚP POINT.java create mode 100644 J04002 - KHAI BÁO LỚP HÌNH CHỮ NHẬT.java create mode 100644 J04003 - PHÂN SỐ.java create mode 100644 J04004 - TỔNG PHÂN SỐ.java create mode 100644 J04005 - KHAI BÁO LỚP THÍ SINH.java create mode 100644 J04006 - KHAI BÁO LỚP SINH VIÊN.java create mode 100644 J04007 - KHAI BÁO LỚP NHÂN VIÊN.java create mode 100644 J04008 - CHU VI TAM GIÁC.java create mode 100644 J04009 - DIỆN TÍCH TAM GIÁC.java create mode 100644 J04010 - DIỆN TÍCH HÌNH TRÒN NGOẠI TIẾP TAM GIÁC.java create mode 100644 J04011 - BỐN ĐIỂM TRÊN MẶT PHẲNG.java create mode 100644 J04012 - BÀI TOÁN TÍNH CÔNG.java create mode 100644 J04013 - BÀI TOÁN TUYỂN SINH.java create mode 100644 J04014 - TÍNH TOÁN PHÂN SỐ.java create mode 100644 J04015 - TÍNH THU NHẬP GIÁO VIÊN.java create mode 100644 J04016 - TÍCH HAI ĐỐI TƯỢNG MA TRẬN.java create mode 100644 J04017 - TÍCH MA TRẬN VÀ CHUYỂN VỊ CỦA NÓ.java create mode 100644 J04018 - SỐ PHỨC.java create mode 100644 J04019 - LỚP TRIANGLE - 1.java create mode 100644 J04020 - LỚP PAIR.java create mode 100644 J04021 - LỚP INTSET.java create mode 100644 J04022 - WORDSET.java create mode 100644 J05003 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 1.java create mode 100644 J05004 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 2.java create mode 100644 J05005 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 3.java create mode 100644 J05006 - DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java create mode 100644 J05007 - SẮP XẾP DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java create mode 100644 J05008 - DIỆN TÍCH ĐA GIÁC.java create mode 100644 J05009 - TÌM THỦ KHOA CỦA KỲ THI.java create mode 100644 J05010 - SẮP XẾP DANH SÁCH MẶT HÀNG.java create mode 100644 J05011 - TÍNH GIỜ.java create mode 100644 J05012 - TÍNH TIỀN.java create mode 100644 J05013 - TUYỂN DỤNG.java create mode 100644 J05014 - TUYỂN GIÁO VIÊN.java create mode 100644 J05015 - ĐUA XE ĐẠP.java create mode 100644 J05016 - HÓA ĐƠN KHÁCH SẠN.java create mode 100644 J05017 - HÓA ĐƠN TIỀN NƯỚC.java create mode 100644 J05018 - BẢNG ĐIỂM HỌC SINH.java create mode 100644 J05019 - LƯỢNG MƯA TRUNG BÌNH.java create mode 100644 J05020 - SẮP XẾP SINH VIÊN THEO LỚP.java create mode 100644 J05021 - SẮP XẾP THEO MÃ SINH VIÊN.java create mode 100644 J05022 - LIỆT KÊ SINH VIÊN THEO LỚP.java create mode 100644 J05023 - LIỆT KÊ SINH VIÊN THEO KHÓA.java create mode 100644 J05024 - LIỆT KÊ SINH VIÊN THEO NGÀNH.java create mode 100644 J05025 - SẮP XẾP DANH SÁCH GIẢNG VIÊN.java create mode 100644 J05026 - DANH SÁCH GIẢNG VIÊN THEO BỘ MÔN.java create mode 100644 J05027 - TÌM KIẾM GIẢNG VIÊN.java create mode 100644 J05028 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 1.java create mode 100644 J05029 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 2.java create mode 100644 J05030 - BẢNG ĐIỂM THÀNH PHẦN - 1.java create mode 100644 J05031 - BẢNG ĐIỂM THÀNH PHẦN - 2.java create mode 100644 J05032 - TRẺ NHẤT – GIÀ NHẤT.java create mode 100644 J05033 - SẮP XẾP THỜI GIAN.java create mode 100644 J05034 - DANH SÁCH THỰC TẬP - 1.java create mode 100644 J05035 - DANH SÁCH THỰC TẬP - 2.java create mode 100644 J05036 - TÍNH GIÁ BÁN - 1.java create mode 100644 J05037 - TÍNH GIÁ BÁN - 2.java create mode 100644 J05038 - BẢNG KÊ TIỀN LƯƠNG.java create mode 100644 J05040 - LẬP BẢNG TÍNH CÔNG.java create mode 100644 J05041 - SẮP XẾP BẢNG TÍNH CÔNG.java create mode 100644 J05042 - BẢNG XẾP HẠNG.java create mode 100644 J05043 - TÍNH THU NHẬP CHO NHÂN VIÊN.java create mode 100644 J05044 - LIỆT KÊ NHÂN VIÊN THEO CHỨC VỤ.java create mode 100644 J05045 - SẮP XẾP NHÂN VIÊN THEO THU NHẬP.java create mode 100644 J05046 - BẢNG KÊ NHẬP KHO.java create mode 100644 J05047 - BẢNG KÊ NHẬP KHO SẮP XẾP THEO CHIẾT KHẤU.java create mode 100644 J05048 - BẢNG THEO DÕI NHẬP XUẤT HÀNG.java create mode 100644 J05049 - LIỆT KÊ NHẬP XUẤT HÀNG THEO NHÓM.java create mode 100644 J05050 - TÍNH TIỀN ĐIỆN.java create mode 100644 J05051 - SẮP XẾP BẢNG TÍNH TIỀN ĐIỆN.java create mode 100644 J05052 - TRA CỨU ĐƠN HÀNG.java create mode 100644 J05053 - SẮP XẾP ĐƠN HÀNG.java create mode 100644 J05054 - XẾP HẠNG HỌC SINH.java create mode 100644 J05055 - XẾP HẠNG VẬN ĐỘNG VIÊN - 1.java create mode 100644 J05056 - XẾP HẠNG VẬN ĐỘNG VIÊN - 2.java create mode 100644 J05057 - BẢNG ĐIỂM TUYỂN SINH.java create mode 100644 J05058 - SẮP XẾP KẾT QUẢ TUYỂN SINH.java create mode 100644 J05059 - XÁC ĐỊNH DANH SÁCH TRÚNG TUYỂN.java create mode 100644 J05060 - KẾT QUẢ XÉT TUYỂN.java create mode 100644 J05061 - SẮP XẾP KẾT QUẢ XÉT TUYỂN.java create mode 100644 J05062 - HỌC BỔNG SINH VIÊN.java create mode 100644 J05063 - TỔNG ĐA THỨC.java create mode 100644 J05064 - BẢNG THU NHẬP GIÁO VIÊN.java create mode 100644 J05065 - LIỆT KÊ NHÂN VIÊN THEO NHÓM.java create mode 100644 J05066 - TÌM KIẾM NHÂN VIÊN THEO TÊN.java create mode 100644 J05067 - QUẢN LÝ KHO XĂNG DẦU.java create mode 100644 J05068 - SẮP XẾP BẢNG GIÁ XĂNG DẦU.java create mode 100644 J05069 - CÂU LẠC BỘ BÓNG ĐÁ - 1.java create mode 100644 J05070 - CÂU LẠC BỘ BÓNG ĐÁ - 2.java create mode 100644 J05071 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 1.java create mode 100644 J05072 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 2.java create mode 100644 J05073 - TÍNH TOÁN GIÁ BÁN.java create mode 100644 J05074 - ĐIỂM DANH - 1.java create mode 100644 J05075 - ĐIỂM DANH - 2.java create mode 100644 J05076 - NHẬP XUẤT HÀNG.java create mode 100644 J05077 - TÍNH LƯƠNG.java create mode 100644 J05078 - BẢNG LƯƠNG THEO PHÒNG BAN.java create mode 100644 J05079 - LỚP HỌC PHẦN – 1.java create mode 100644 J05080 - LỚP HỌC PHẦN – 2.java create mode 100644 J05081 - DANH SÁCH MẶT HÀNG.java create mode 100644 J05082 - DANH SÁCH KHÁCH HÀNG.java create mode 100644 J06001 - TÍNH TOÁN HÓA ĐƠN BÁN QUẦN ÁO.java create mode 100644 J06002 - SẮP XẾP HÓA ĐƠN BÁN QUẦN ÁO.java create mode 100644 J06003 - QUẢN LÝ BÀI TẬP NHÓM – 1.java create mode 100644 J06004 - QUẢN LÝ BÀI TẬP NHÓM – 2.java create mode 100644 J06005 - QUẢN LÝ BÁN HÀNG – 1.java create mode 100644 J06006 - QUẢN LÝ BÁN HÀNG – 2.java create mode 100644 J06007 - BẢNG TÍNH GIỜ CHUẨN.java create mode 100644 J06008 - TÍNH GIỜ CHUẨN CHO TỪNG GIẢNG VIÊN.java create mode 100644 J07001 - ĐỌC FILE VĂN BẢN.java create mode 100644 J07002 - TÍNH TỔNG.java create mode 100644 J07003 - TÁCH ĐÔI VÀ TÍNH TỔNG.java create mode 100644 J07004 - SỐ KHÁC NHAU TRONG FILE - 1.java create mode 100644 J07005 - SỐ KHÁC NHAU TRONG FILE - 2.java create mode 100644 J07006 - SỐ KHÁC NHAU TRONG FILE - 3.java create mode 100644 J07007 - LIỆT KÊ TỪ KHÁC NHAU.java create mode 100644 J07008 - DÃY CON TĂNG DẦN.java create mode 100644 J07009 - LỚP INTSET - 2.java create mode 100644 J07010 - DANH SÁCH SINH VIÊN TRONG FILE - 2.java create mode 100644 J07011 - THỐNG KÊ TỪ KHÁC NHAU TRONG FILE VĂN BẢN.java create mode 100644 J07012 - THỐNG KÊ TỪ KHÁC NHAU TRONG FILE NHỊ PHÂN.java create mode 100644 J07013 - DANH SÁCH SINH VIÊN TRONG FILE NHỊ PHÂN.java create mode 100644 J07014 - HỢP VÀ GIAO CỦA HAI FILE VĂN BẢN.java create mode 100644 J07015 - SỐ NGUYÊN TỐ TRONG FILE NHỊ PHÂN.java create mode 100644 J07016 - SỐ NGUYÊN TỐ TRONG HAI FILE NHỊ PHÂN.java create mode 100644 J07017 - LỚP PAIR (generic).java create mode 100644 J07018 - CHUẨN HÓA DANH SÁCH SINH VIÊN.java create mode 100644 J07019 - HÓA ĐƠN - 1.java create mode 100644 J07020 - HÓA ĐƠN - 2.java create mode 100644 J07021 - CHUẨN HÓA XÂU HỌ TÊN TRONG FILE.java create mode 100644 J07022 - LOẠI BỎ SỐ NGUYÊN.java create mode 100644 J07023 - NGUYÊN TỐ VÀ THUẬN NGHỊCH.java create mode 100644 J07024 - HIỆU CỦA HAI TẬP TỪ.java create mode 100644 J07025 - DANH SÁCH KHÁCH HÀNG TRONG FILE.java create mode 100644 J07027 - QUẢN LÝ BÀI TẬP NHÓM.java create mode 100644 J07028 - TÍNH GIỜ CHUẨN.java create mode 100644 J07029 - SỐ NGUYÊN TỐ LỚN NHẤT TRONG FILE.java create mode 100644 J07030 - CẶP SỐ NGUYÊN TỐ TRONG FILE - 1.java create mode 100644 J07031 - CẶP SỐ NGUYÊN TỐ TRONG FILE 2.java create mode 100644 J07032 - SỐ THUẬN NGHỊCH TRONG FILE.java create mode 100644 J07033 - DANH SÁCH SINH VIÊN TRONG FILE - 1.java create mode 100644 J07034 - DANH SÁCH MÔN HỌC.java create mode 100644 J07035 - BẢNG ĐIỂM THEO MÔN HỌC.java create mode 100644 J07036 - BẢNG ĐIỂM THEO LỚP.java create mode 100644 J07037 - DANH SÁCH DOANH NGHIỆP.java create mode 100644 J07038 - DANH SÁCH THỰC TẬP - 3.java create mode 100644 J07040 - LIỆT KÊ THEO THỨ TỰ XUẤT HIỆN.java create mode 100644 J07041 - LIỆT KÊ CẶP SỐ - 1.java create mode 100644 J07042 - LIỆT KÊ CẶP SỐ - 2.java create mode 100644 J07045 - LOẠI PHÒNG.java create mode 100644 J07046 - DANH SÁCH LƯU TRÚ.java create mode 100644 J07047 - QUẢN LÝ KHÁCH SẠN.java create mode 100644 J07048 - DANH SÁCH SẢN PHẨM – 2.java create mode 100644 J07049 - TÍNH NGÀY HẾT HẠN BẢO HÀNH.java create mode 100644 J07050 - SẮP XẾP MẶT HÀNG.java create mode 100644 J07051 - TÍNH TIỀN PHÒNG.java create mode 100644 J07052 - DANH SÁCH TRÚNG TUYỂN.java create mode 100644 J07053 - XÉT TUYỂN.java create mode 100644 J07054 - TÍNH ĐIỂM TRUNG BÌNH.java create mode 100644 J07055 - XẾP LOẠI.java create mode 100644 J07056 - TÍNH TIỀN ĐIỆN.java create mode 100644 J07057 - ĐIỂM TUYỂN SINH.java create mode 100644 J07058 - DANH SÁCH MÔN THI.java create mode 100644 J07059 - DANH SÁCH CA THI.java create mode 100644 J07060 - SẮP XẾP LỊCH THI.java create mode 100644 J07071 - TÊN VIẾT TẮT.java create mode 100644 J07072 - CHUẨN HÓA VÀ SẮP XẾP.java create mode 100644 J07073 - ĐĂNG KÝ HÌNH THỨC GIẢNG DẠY.java create mode 100644 J07074 - LỊCH GIẢNG DẠY THEO MÔN HỌC.java create mode 100644 J07075 - LỊCH GIẢNG DẠY THEO GIẢNG VIÊN.java create mode 100644 J07076 - SẮP XẾP MA TRẬN.java create mode 100644 J07077 - TÍNH GIÁ TRỊ BIỂU THỨC.java create mode 100644 J07078 - TÌM VỊ TRÍ XÂU CON.java create mode 100644 J07081 - SẮP XẾP DANH SÁCH SINH VIÊN.java create mode 100644 J07084 - THỜI GIAN ONLINE LIÊN TỤC.java create mode 100644 J07085 - TỔNG CHỮ SỐ.java create mode 100644 J08010 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java create mode 100644 J08011 - LIỆT KÊ VÀ ĐẾM.java create mode 100644 J08012 - HÌNH SAO.java create mode 100644 J08015 - CẶP SỐ CÓ TỔNG BẰNG K.java create mode 100644 J08020 - KIỂM TRA DÃY NGOẶC ĐÚNG.java create mode 100644 J08021 - DÃY NGOẶC ĐÚNG DÀI NHẤT.java create mode 100644 J08022 - PHẦN TỬ BÊN PHẢI ĐẦU TIÊN LỚN HƠN.java create mode 100644 J08023 - HÌNH CHỮ NHẬT LỚN NHẤT.java create mode 100644 J08024 - SỐ 0 VÀ SỐ 9.java create mode 100644 J08025 - QUAY HÌNH VUÔNG.java create mode 100644 J08026 - BIẾN ĐỔI S – T.java create mode 100644 J08027 - GÕ BÀN PHÍM.java create mode 100644 J08028 - HÌNH CHỮ NHẬT ĐƠN SẮC.java create mode 100644 J08029 - QUÂN MÃ.java create mode 100644 JKT013 - SỐ LỘC PHÁT.java create mode 100644 JKT014 - ĐẦU TƯ CHỨNG KHOÁN.java create mode 100644 JKT015 - GÕ BÀN PHÍM.java create mode 100644 TN02012 - TÍNH LƯƠNG.java diff --git a/CHELLO - Hello World.java b/CHELLO - Hello World.java new file mode 100644 index 0000000..f47beb0 --- /dev/null +++ b/CHELLO - Hello World.java @@ -0,0 +1,5 @@ +public class Main{ + public static void main(String[] args){ + System.out.println("Hello PTIT."); + } +} diff --git a/HELLOFILE - HELLO FILE.java b/HELLOFILE - HELLO FILE.java new file mode 100644 index 0000000..8a51c25 --- /dev/null +++ b/HELLOFILE - HELLO FILE.java @@ -0,0 +1,18 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +public class Main{ + public static void main(String[] args){ + File file = new File("Hello.txt"); + try{ + Scanner scaner = new Scanner(file); + while(scaner.hasNextLine()){ + System.out.println(scaner.nextLine()); + } + scaner.close(); + }catch(FileNotFoundException e){ + + } + } +} diff --git a/HELLOJAR - HỌC PHÍ.java b/HELLOJAR - HỌC PHÍ.java new file mode 100644 index 0000000..aa5a11e --- /dev/null +++ b/HELLOJAR - HỌC PHÍ.java @@ -0,0 +1,62 @@ + +package nyagami; +import java.io.*; +import java.util.*; +import view.InvoiceView; +import vn.edu.ptit.*; +/** + * + * @author hoang + */ + + +public class Nyagami { + + static class PaymentController{ + private Invoice invoice; + + public PaymentController(){ + Scanner sc = new Scanner(System.in); + + Student st = new Student(sc.nextLine(), sc.nextLine()); + + int n_subject = Integer.parseInt(sc.nextLine()); + ArrayList AlSubject = new ArrayList<>(); + + for(int i=0; i0){ + t--; + Long n = reader.nextLong(); + System.out.println(n*(n+1)/2); + } + reader.close(); + } +} diff --git a/J01003 - GIẢI PHƯƠNG TRÌNH BẬC NHẤT.java b/J01003 - GIẢI PHƯƠNG TRÌNH BẬC NHẤT.java new file mode 100644 index 0000000..e32cf56 --- /dev/null +++ b/J01003 - GIẢI PHƯƠNG TRÌNH BẬC NHẤT.java @@ -0,0 +1,15 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args){ + Scanner reader = new Scanner(System.in); + float a = reader.nextFloat(), b = reader.nextFloat(); + if(a==0){ + if(b!=0) System.out.println("VN"); + else System.out.println("VSN"); + }else{ + System.out.printf("%.2f", -b/a); + } + reader.close(); + } +} diff --git a/J01004 - SỐ NGUYÊN TỐ.java b/J01004 - SỐ NGUYÊN TỐ.java new file mode 100644 index 0000000..c9ce1c4 --- /dev/null +++ b/J01004 - SỐ NGUYÊN TỐ.java @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class Main { + + static boolean nt(int n){ + if(n<2) return false; + if(n==2) return true; + if(n%2==0) return false; + for(int i=3;i<=Math.sqrt(n);i+=2){ + if(n%i==0) return false; + } + return true; + } + public static void main(String[] args){ + Scanner reader = new Scanner(System.in); + int t = reader.nextInt(); + while(t>0){ + t--; + int n = reader.nextInt(); + if(nt(n)) System.out.println("YES"); + else System.out.println("NO"); + } + reader.close(); + } +} diff --git a/J01005 - CHIA TAM GIÁC.java b/J01005 - CHIA TAM GIÁC.java new file mode 100644 index 0000000..a8496a0 --- /dev/null +++ b/J01005 - CHIA TAM GIÁC.java @@ -0,0 +1,19 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args){ + Scanner reader = new Scanner(System.in); + int t = reader.nextInt(); + while(t>0){ + t--; + double n = reader.nextDouble(), h = reader.nextDouble(); + for(double i = 1; i < n; i++){ + double p = i/n; + double curh = h*(Math.sqrt(p)); + System.out.printf("%.6f ",curh); + } + System.out.println(""); + } + reader.close(); + } +} diff --git a/J01006 - TÍNH SỐ FIBONACCI.java b/J01006 - TÍNH SỐ FIBONACCI.java new file mode 100644 index 0000000..41695bd --- /dev/null +++ b/J01006 - TÍNH SỐ FIBONACCI.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args){ + long[] f = new long[94]; + f[0]=0; f[1]=1; + for(int i=2;i<=92;i++) f[i]=f[i-1]+f[i-2]; + Scanner reader = new Scanner(System.in); + int t = reader.nextInt(); + while(t>0){ + t--; + System.out.println(f[reader.nextInt()]); + } + reader.close(); + } +} diff --git a/J01007 - KIỂM TRA SỐ FIBONACCI.java b/J01007 - KIỂM TRA SỐ FIBONACCI.java new file mode 100644 index 0000000..a2708de --- /dev/null +++ b/J01007 - KIỂM TRA SỐ FIBONACCI.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class Main { + + public static void main(String[] args){ + long[] f = new long[94]; + f[0]=0; f[1]=1; + for(int i=2;i<=92;i++) f[i]=f[i-1]+f[i-2]; + + Scanner reader = new Scanner(System.in); + int t = reader.nextInt(); + while(t>0){ + t--; + long n = reader.nextLong(); + if(isfi(n,f)) System.out.println("YES"); + else System.out.println("NO"); + } + reader.close(); + } + static boolean isfi(long n,long[] f){ + for(int i=0;i<=92;i++){ + if(n==f[i]) return true; + } + return false; + } +} diff --git a/J01008 - PHÂN TÍCH THỪA SỐ NGUYÊN TỐ.java b/J01008 - PHÂN TÍCH THỪA SỐ NGUYÊN TỐ.java new file mode 100644 index 0000000..081c6f6 --- /dev/null +++ b/J01008 - PHÂN TÍCH THỪA SỐ NGUYÊN TỐ.java @@ -0,0 +1,29 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + for(int i=1; i<=t; i++){ + int n = sc.nextInt(); + System.out.printf("Test %d: ",i); + int can = (int) Math.sqrt((double)n); + for(int j=2; j<=can; j++){ + int cnt=0; + while(n%j==0){ + n/=j; + cnt++; + } + if(cnt>0){ + System.out.printf("%d(%d) ", j, cnt); + } + } + if(n>1) System.out.printf("%d(1)", n); + System.out.println(""); + } + sc.close(); + } +} diff --git a/J01009 - TỔNG GIAI THỪA.java b/J01009 - TỔNG GIAI THỪA.java new file mode 100644 index 0000000..f1aac83 --- /dev/null +++ b/J01009 - TỔNG GIAI THỪA.java @@ -0,0 +1,30 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package test; +import java.util.Scanner; +/** + * + * @author hoang + */ +public class Test { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Scanner reader = new Scanner(System.in); + long n = reader.nextLong(); + long ans = 0; + long[] f = new long[22]; + f[0]=1; + for(int i=1; i<=n ; i++){ + f[i]=f[i-1]*i; + ans+=f[i]; + } + System.out.print(ans); + reader.close(); + } + +} diff --git a/J01010 - CẮT ĐÔI.java b/J01010 - CẮT ĐÔI.java new file mode 100644 index 0000000..e644b30 --- /dev/null +++ b/J01010 - CẮT ĐÔI.java @@ -0,0 +1,37 @@ + +import java.util.Scanner; +public class Main { + static char convert(char x) { + if (x == '0') + return '0'; + if (x == '1') + return '1'; + if (x == '8') + return '0'; + if (x == '9') + return '0'; + return '2'; + } + + static String ans(char[] a) { + for (int i = 0; i < a.length; i++) { + a[i] = convert(a[i]); + if (a[i] == '2') + return "INVALID"; + } + String s = new String(a); + s=s.replaceFirst("^0+", ""); + if ("".equals(s)) return "INVALID"; + return s; + } + + public static void main(String[] args) { + Scanner reader = new Scanner(System.in); + int t = Integer.parseInt(reader.nextLine()); + for (int i = 0; i < t; i++) { + String s = reader.nextLine(); + System.out.println(ans(s.toCharArray())); + } + reader.close(); + } +} diff --git a/J01011 - BỘI SỐ CHUNG - ƯỚC SỐ CHUNG.java b/J01011 - BỘI SỐ CHUNG - ƯỚC SỐ CHUNG.java new file mode 100644 index 0000000..87c8e31 --- /dev/null +++ b/J01011 - BỘI SỐ CHUNG - ƯỚC SỐ CHUNG.java @@ -0,0 +1,23 @@ + +import java.util.Scanner; +public class Main { + + static long gcd(long a, long b){ + if(b==0) return a; + return gcd(b,a%b); + } + + static long lcm(long a,long b){ + return a*b/gcd(a,b); + } + + public static void main(String[] args) { + Scanner reader = new Scanner(System.in); + int t = reader.nextInt(); + for (int i = 0; i < t; i++) { + int a=reader.nextInt(), b=reader.nextInt(); + System.out.printf("%d %d\n",lcm(a,b),gcd(a,b)); + } + reader.close(); + } +} diff --git a/J01012 - ƯỚC SỐ CHIA HẾT CHO 2.java b/J01012 - ƯỚC SỐ CHIA HẾT CHO 2.java new file mode 100644 index 0000000..aaf1e10 --- /dev/null +++ b/J01012 - ƯỚC SỐ CHIA HẾT CHO 2.java @@ -0,0 +1,28 @@ + +import java.util.Scanner; +public class Main { + + static int count(int n){ + if(n%2==1) return 0; + int can=(int) Math.sqrt((double) n); + int c=0; + for(int i=1;i<=can;i++){ + if(n%i==0){ + if(i%2==0) c++; + if((n/i)%2==0) c++; + } + } + if(can*can==n && can%2==0) c--; + return c; + } + + public static void main(String[] args) { + Scanner reader = new Scanner(System.in); + int t = reader.nextInt(); + for (int i = 0; i < t; i++) { + int a=reader.nextInt(); + System.out.println(count(a)); + } + reader.close(); + } +} diff --git a/J01013 - TỔNG ƯỚC SỐ - 1.java b/J01013 - TỔNG ƯỚC SỐ - 1.java new file mode 100644 index 0000000..e77b45c --- /dev/null +++ b/J01013 - TỔNG ƯỚC SỐ - 1.java @@ -0,0 +1,30 @@ + +import java.util.Scanner; +public class Main { + + static long[] f = new long[2000001]; + + public static void main(String[] args) { + for(int i=0;i<2000001;i++){ + f[i]=0; + Boolean oke=true; + for(int j=2;j<=(int)Math.sqrt(i);j++){ + if(i%j==0){ + f[i]=f[j]+f[i/j]; + oke=false; + break; + } + } + if(oke) f[i]=i; + } + Scanner reader = new Scanner(System.in); + long t = reader.nextLong(); + long s=0; + for (long i = 0; i < t; i++) { + int a=reader.nextInt(); + s+=f[a]; + } + System.out.print(s); + reader.close(); + } +} diff --git a/J01014 - ƯỚC SỐ NGUYÊN TỐ LỚN NHẤT.java b/J01014 - ƯỚC SỐ NGUYÊN TỐ LỚN NHẤT.java new file mode 100644 index 0000000..83f8f48 --- /dev/null +++ b/J01014 - ƯỚC SỐ NGUYÊN TỐ LỚN NHẤT.java @@ -0,0 +1,26 @@ + +import java.util.Scanner; +public class Main { + + static long[] f = new long[2000001]; + + public static void main(String[] args) { + Scanner reader = new Scanner(System.in); + long t = reader.nextLong(); + for (long i = 0; i < t; i++) { + long ans=1; + long a=reader.nextLong(); + for(long j=2;j<=(long)Math.sqrt(a);j++){ + if(a%j==0){ + ans=j; + while(a%j==0){ + a/=j; + } + } + } + if(a>1) ans=a; + System.out.println(ans); + } + reader.close(); + } +} diff --git a/J01016 - CHỮ SỐ 4 VÀ CHỮ SỐ 7.java b/J01016 - CHỮ SỐ 4 VÀ CHỮ SỐ 7.java new file mode 100644 index 0000000..dea0cc4 --- /dev/null +++ b/J01016 - CHỮ SỐ 4 VÀ CHỮ SỐ 7.java @@ -0,0 +1,17 @@ + +import java.util.Scanner; +public class Main { + + static long[] f = new long[2000001]; + + public static void main(String[] args) { + Scanner reader = new Scanner(System.in); + String s = reader.next(); + int c=0; + for(int i=0;i0){ + r|=(1<<(x%10)); + x/=10; + } + if(r==ans){ + System.out.println(i*n); + return; + } + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + while(T-->0) solve(sc.nextLong()); + } +} diff --git a/J01021 - TÍNH LŨY THỪA.java b/J01021 - TÍNH LŨY THỪA.java new file mode 100644 index 0000000..7b4464e --- /dev/null +++ b/J01021 - TÍNH LŨY THỪA.java @@ -0,0 +1,23 @@ + +import java.util.Scanner; +public class Main { + + static long mod=1000000007; + + static long mod(long a,long b){ + if(b==0) return 1; + if(b%2==1) return mod(a,b-1)*a%mod; + long p=mod(a,b/2); + return p*p%mod; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + while(true){ + long a=sc.nextLong(), b=sc.nextLong(); + if(a==0 && b==0) break; + System.out.println(mod(a,b)); + } + sc.close(); + } +} diff --git a/J01022 - XÂU NHỊ PHÂN.java b/J01022 - XÂU NHỊ PHÂN.java new file mode 100644 index 0000000..2ac2346 --- /dev/null +++ b/J01022 - XÂU NHỊ PHÂN.java @@ -0,0 +1,31 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + + static long[] f = new long[94]; + + static int Try(int n, long k){ + if(n==1) return 0; + if(n==2) return 1; + if(k<=f[n-2]) return Try(n-2,k); + return Try(n-1,k-f[n-2]); + } + + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + f[0]=0; + f[1]=1; + for(int i=2;i<94;i++){ + f[i]=f[i-1]+f[i-2]; + } + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + long k = sc.nextLong(); + System.out.println(Try(n, k)); + } + sc.close(); + } +} diff --git a/J01023 - TOÁN LỚP BA.java b/J01023 - TOÁN LỚP BA.java new file mode 100644 index 0000000..57af4db --- /dev/null +++ b/J01023 - TOÁN LỚP BA.java @@ -0,0 +1,63 @@ +import java.util.*; + +public class non { + + static ArrayList genn(String s){ + ArrayList a = new ArrayList<>(); + if(s.charAt(0) == '?'){ + for(char c = '1'; c <= '9'; c++) a.add(c + "" + s.charAt(1)); + }else a.add(s); + if(s.charAt(1) == '?'){ + ArrayList ans = new ArrayList<>(); + for(String i : a){ + for(char c = '0'; c <= '9'; c++) ans.add(i.charAt(0) + "" + c); + } + return ans; + } + return a; + } + + static String geno(String s){ + if(s.charAt(0) == '?') return "+-"; + return s; + } + + static int cal(int a, int b, char op){ + if(op == '+') return a+b; + return a-b; + } + + static boolean check(String a, char op, String b, String c){ + if("*/".indexOf(op) > -1) return false; + int x = Integer.parseInt(a); + int y = Integer.parseInt(b); + int z = Integer.parseInt(c); + return x>9 && y>9 && z>9 && cal(x, y, op) == z; + } + + static void solve(String a, String op, String b, String equal, String c){ + ArrayList arr1 = genn(a); + ArrayList arr2 = genn(b); + ArrayList arr3 = genn(c); + op = geno(op); + for(String i:arr1){ + for(String j:arr2){ + for(String k:arr3){ + for(int u=0;u0) solve(sc.next(), sc.next(), sc.next(), sc.next(), sc.next()); + } +} diff --git a/J01024 - SỐ TAM PHÂN.java b/J01024 - SỐ TAM PHÂN.java new file mode 100644 index 0000000..c897cb6 --- /dev/null +++ b/J01024 - SỐ TAM PHÂN.java @@ -0,0 +1,21 @@ + +import java.util.Scanner; +public class Main { + + static String check(String s){ + for(int i=0;i h = new TreeSet<>(); + int n = sc.nextInt(), m = sc.nextInt(); + int[] a = new int[n]; + int[] b = new int[m]; + for(int i=0;i{ + System.out.printf("%d ", k); + }); + sc.close(); + } +} diff --git a/J02006 - HỢP CỦA HAI DÃY SỐ.java b/J02006 - HỢP CỦA HAI DÃY SỐ.java new file mode 100644 index 0000000..442b0e9 --- /dev/null +++ b/J02006 - HỢP CỦA HAI DÃY SỐ.java @@ -0,0 +1,33 @@ +package nyagami; + +import java.util.Scanner; +import java.util.TreeSet; +import java.util.HashSet; + +public class test{ + + static boolean has(int[] a, int n, int x){ + for(int i=0;i h = new TreeSet<>(); + HashSet a = new HashSet<>(); + HashSet b = new HashSet<>(); + int n = sc.nextInt(), m = sc.nextInt(); + for(int i=0;i h.add(k)); + b.forEach(k -> h.add(k)); + h.forEach((k)->{ + System.out.printf("%d ", k); + }); + sc.close(); + } +} diff --git a/J02007 - ĐẾM SỐ LẦN XUẤT HIỆN.java b/J02007 - ĐẾM SỐ LẦN XUẤT HIỆN.java new file mode 100644 index 0000000..9a5d1ca --- /dev/null +++ b/J02007 - ĐẾM SỐ LẦN XUẤT HIỆN.java @@ -0,0 +1,31 @@ +import java.util.Scanner; +import java.util.Map; +import java.util.HashMap; + +public class Main { + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + for(int j=1;j<=t;j++){ + System.out.printf("Test %d:\n",j); + int n=sc.nextInt(); + int[] a = new int[n]; + for(int i=0;i m = new HashMap(); + for(int i=0;i0){ + System.out.printf("%d xuat hien %d lan\n",a[i],m.get(a[i])); + m.put(a[i], 0); + } + } + } + sc.close(); + } +} diff --git a/J02008 - BỘI SỐ NHỎ NHẤT CỦA N SỐ NGUYÊN DƯƠNG ĐẦU TIÊN.java b/J02008 - BỘI SỐ NHỎ NHẤT CỦA N SỐ NGUYÊN DƯƠNG ĐẦU TIÊN.java new file mode 100644 index 0000000..12fa409 --- /dev/null +++ b/J02008 - BỘI SỐ NHỎ NHẤT CỦA N SỐ NGUYÊN DƯƠNG ĐẦU TIÊN.java @@ -0,0 +1,24 @@ +import java.util.Scanner; + +public class Main { + static long gcd(long a,long b){ + if(b==0) return a; + return gcd(b,a%b); + } + static long lcm(long a,long b){ + return a*b/gcd(a,b); + } + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t=sc.nextInt(); + while(t-->0){ + long n=sc.nextLong(); + long s=1; + for(int i=1;i<=n;i++){ + s=lcm(s,i); + } + System.out.println(s); + } + sc.close(); + } +} diff --git a/J02009 - XẾP HÀNG.java b/J02009 - XẾP HÀNG.java new file mode 100644 index 0000000..ab0c4e0 --- /dev/null +++ b/J02009 - XẾP HÀNG.java @@ -0,0 +1,28 @@ +import java.util.*; +import java.io.*; + +public class Main { + static class pair{ + public int first, second; + public pair(int a, int b){ + first = a; + second = b; + } + } + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + return x.first - b.first; + }); + int now = 0; + for(int i=0;i=now) now=a.get(i).first+a.get(i).second; + else now+=a.get(i).second; + } + System.out.println(now); + } +} diff --git a/J02010 - SẮP XẾP ĐỔI CHỖ TRỰC TIẾP.java b/J02010 - SẮP XẾP ĐỔI CHỖ TRỰC TIẾP.java new file mode 100644 index 0000000..f9f6a61 --- /dev/null +++ b/J02010 - SẮP XẾP ĐỔI CHỖ TRỰC TIẾP.java @@ -0,0 +1,34 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + + static void out(int[] a, int n, int step){ + System.out.printf("Buoc %d: ",step); + for(int i=0;ia[j]) { + int tmp = a[i]; + a[i] = a[j]; + a[j] = tmp; + } + } + out(a,n,i+1); + } + sc.close(); + } +} diff --git a/J02011 - SẮP XẾP CHỌN.java b/J02011 - SẮP XẾP CHỌN.java new file mode 100644 index 0000000..edbd085 --- /dev/null +++ b/J02011 - SẮP XẾP CHỌN.java @@ -0,0 +1,36 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + + static void out(int[] a, int n, int step){ + System.out.printf("Buoc %d: ",step); + for(int i=0;ia[j]) { + candindex=j; + } + } + int tmp = a[i]; + a[i] = a[candindex]; + a[candindex] = tmp; + out(a,n,i+1); + } + sc.close(); + } +} diff --git a/J02012 - SẮP XẾP CHÈN.java b/J02012 - SẮP XẾP CHÈN.java new file mode 100644 index 0000000..59c81f0 --- /dev/null +++ b/J02012 - SẮP XẾP CHÈN.java @@ -0,0 +1,27 @@ +package nyagami; + +import java.util.Scanner; +import java.util.ArrayList; +import java.util.Collections; + +public class test{ + + static void out(ArrayList a, int step){ + System.out.printf("Buoc %d: ", step); + a.forEach(k -> System.out.printf("%d ", k)); + System.out.println(""); + } + + + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;ia[i+1]) return false; + } + return true; + } + + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for(int i=0;ia[j+1]){ + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + out(a,n,i+1); + if(isSorted(a,n)) break; + } + sc.close(); + } +} diff --git a/J02014 - ĐIỂM CÂN BẰNG.java b/J02014 - ĐIỂM CÂN BẰNG.java new file mode 100644 index 0000000..645942e --- /dev/null +++ b/J02014 - ĐIỂM CÂN BẰNG.java @@ -0,0 +1,29 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + int[] a = new int[n+1]; + for(int i=1;i=2;i--){ + int j=0, k=i-1; + while(ja[i]) k--; + else j++; + } + } + return false; + } + static long sq(Long x){ + return x*x; + } + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + long[] a = new long[n]; + for (int i = 0; i < n; i++) + a[i] = sq(sc.nextLong()); + if(check(a)) System.out.println("YES"); + else System.out.println("NO"); + } + } +} diff --git a/J02017 - THU GỌN DÃY SỐ.java b/J02017 - THU GỌN DÃY SỐ.java new file mode 100644 index 0000000..3631c49 --- /dev/null +++ b/J02017 - THU GỌN DÃY SỐ.java @@ -0,0 +1,23 @@ +package nyagami; + +import java.util.Scanner; +import java.util.Stack; + +public class test{ + + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + Stack a = new Stack<>(); + for(int i=0; i>1); + return p*p; + } + static void set(){ + for(int i=2;i<=(int)Math.sqrt(N);++i){ + if(U[i]==0){ + U[i]=i; + for(int j=0;j<=N/i;++j) U[i*j] = i; + } + } + for(int i=2;i<=N;++i){ + if(U[i]==0) U[i]=i+1; + else{ + int n = i, x = 0; + while(n%U[i]==0){ + n/=U[i]; + x++; + } + if(n==1) U[i] = (pow(U[i], x+1) - 1)/(U[i]-1); + else U[i] = U[pow(U[i], x)] * U[n]; + } + } + } + public static void main(String[] args) { + set(); + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(), b = sc.nextInt(), cnt = 0; + for(int i=a;i<=b;++i) if(U[i] - i > i) ++cnt; + System.out.println(cnt); + } +} diff --git a/J02020 - LIỆT KÊ TỔ HỢP - 1.java b/J02020 - LIỆT KÊ TỔ HỢP - 1.java new file mode 100644 index 0000000..01a08f2 --- /dev/null +++ b/J02020 - LIỆT KÊ TỔ HỢP - 1.java @@ -0,0 +1,30 @@ +package nyagami; + +import java.util.Scanner; +import java.util.Stack; + +public class test{ + static int n, k, cnt=0; + static void Try(int i, int start, int[] res){ + if(i==k){ + cnt++; + for(int j=0; j0 && Math.abs(j-a[i-1])!=1))){ + vs[j]=true; + a[i]=j; + Try(i+1,a,vs); + vs[j]=false; + } + } + } + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + n = sc.nextInt(); + boolean[] visited = new boolean[n+1]; + int[] a = new int[n]; + Try(0,a,visited); + System.out.println(""); + } + sc.close(); + } +} diff --git a/J02023 - LỰA CHỌN THAM LAM.java b/J02023 - LỰA CHỌN THAM LAM.java new file mode 100644 index 0000000..e73d09a --- /dev/null +++ b/J02023 - LỰA CHỌN THAM LAM.java @@ -0,0 +1,29 @@ +import java.util.*; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), s = sc.nextInt(), n9 = 0; + String Max = "", Min = ""; + if(n*9 < s || s == 0){ + System.out.println("-1 -1"); + return; + } + while(s>=9){ + Max += "9"; + n9++; + s-=9; + } + if(s!=0) Max += Integer.toString(s); + while(Max.length()0?2:0);i++) System.out.print("0"); + if(s>0) System.out.print(n9+1!=n?s-1:s); + while(n9-->0) System.out.print("9"); + System.out.printf(" %s",Max); + } +} diff --git a/J02024 - DÃY CON CÓ TỔNG LẺ.java b/J02024 - DÃY CON CÓ TỔNG LẺ.java new file mode 100644 index 0000000..9c2a2a0 --- /dev/null +++ b/J02024 - DÃY CON CÓ TỔNG LẺ.java @@ -0,0 +1,41 @@ +import java.util.*; +import java.io.*; + +public class Main { + static ArrayList ans; + + static void Try(int end, int[] a, int sum, String s) { + if (sum % 2 == 1) { + System.out.println(s); + ans.add(s); + } + for (int i = a.length - 1; i > end; i--) { + Try(i, a, sum + a[i], s + a[i] + ' '); + } + } + + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(); + int[] a = new int[n]; + ans = new ArrayList<>(); + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + for (int i = 0; i < n - 1; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] < a[j]) { + int tmp = a[i]; + a[i] = a[j]; + a[j] = tmp; + } + } + } + Try(-1, a, 0, ""); + Collections.sort(ans); + // ans.forEach(e -> System.out.println(e)); + } + } +} diff --git a/J02025 - DÃY CON CÓ TỔNG NGUYÊN TỐ.java b/J02025 - DÃY CON CÓ TỔNG NGUYÊN TỐ.java new file mode 100644 index 0000000..80800a3 --- /dev/null +++ b/J02025 - DÃY CON CÓ TỔNG NGUYÊN TỐ.java @@ -0,0 +1,47 @@ +import java.util.*; +import java.io.*; + +public class Main { + static boolean primr(int x) { + if (x < 2) + return false; + if (x == 2) + return true; + if (x % 2 == 0) + return false; + for (int i = 3; i <= (int) Math.sqrt(x); i += 2) { + if (x % i == 0) + return false; + + } + return true; + } + static void Try(int end, int[] a, int sum, String s) { + if (primr(sum)) System.out.println(s); + for (int i = a.length - 1; i > end; i--) { + Try(i, a, sum + a[i], s + a[i] + ' '); + } + } + + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + for (int i = 0; i < n - 1; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] < a[j]) { + int tmp = a[i]; + a[i] = a[j]; + a[j] = tmp; + } + } + } + Try(-1, a, 0, ""); + } + } +} diff --git a/J02026 - DÃY CON CÓ K PHẦN TỬ TĂNG DẦN.java b/J02026 - DÃY CON CÓ K PHẦN TỬ TĂNG DẦN.java new file mode 100644 index 0000000..f94da4c --- /dev/null +++ b/J02026 - DÃY CON CÓ K PHẦN TỬ TĂNG DẦN.java @@ -0,0 +1,26 @@ +import java.util.*; +import java.io.*; + +public class Main { + static void Try(int start, int cnt, int k, int[] a, String s){ + if(cnt==k){ + System.out.println(s); + return; + } + for(int i=start; i0){ + int n = sc.nextInt(), k = sc.nextInt(); + int[] a = new int[n]; + for(int i=0;ir) return l; + int mid = (l+r)/2; + if(a[mid] > x) return uppper_bound(l, mid - 1 , a, x); + return uppper_bound(mid + 1, r, a, x); + } + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(), k = sc.nextInt(); + int[] a = new int[n]; + for(int i=0;i0){ + int n = sc.nextInt(); + long k = sc.nextLong(); + long[] a = new long[n]; + for(int i=0;i k){ + sum-=a[l]; + l++; + } + } + if(check) System.out.println("YES"); + else System.out.println("NO"); + } + } +} diff --git a/J02033 - ĐẢO DẤU.java b/J02033 - ĐẢO DẤU.java new file mode 100644 index 0000000..e3dcbf0 --- /dev/null +++ b/J02033 - ĐẢO DẤU.java @@ -0,0 +1,28 @@ +import java.io.*; +import java.util.*; + +public class non { + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + long k = sc.nextLong(); + long[] a = new long[n]; + for(int i=0;i0){ + int n = sc.nextInt(); + int[] a = new int[n]; + int[] b = new int[n]; + for(int i=0;i=9){ + Max += "9"; + n9++; + s-=9; + } + if(s!=0) Max += Integer.toString(s); + while(Max.length()0?2:0);i++) System.out.print("0"); + if(s>0) System.out.print(n9+1!=n?s-1:s); + while(n9-->0) System.out.print("9"); + System.out.printf(" %s",Max); + } +} diff --git a/J02036 - ƯỚC SỐ CHUNG LỚN NHẤT.java b/J02036 - ƯỚC SỐ CHUNG LỚN NHẤT.java new file mode 100644 index 0000000..7629a94 --- /dev/null +++ b/J02036 - ƯỚC SỐ CHUNG LỚN NHẤT.java @@ -0,0 +1,33 @@ +import java.util.*; + +public class Main { + static int gcd(int a, int b) { + if (b == 0) + return a; + return gcd(b, a % b); + } + + static int lcm(int a, int b) { + return a * b / gcd(a, b); + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(); + int[] a = new int[n]; + int[] b = new int[n + 1]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + b[0] = a[0]; + for (int i = 1; i < n; i++) { + b[i] = lcm(a[i], a[i - 1]); + } + b[n] = a[n - 1]; + for (int i = 0; i < n + 1; i++) { + System.out.printf("%d ", b[i]); + } + System.out.println(); + } + } +} diff --git a/J02037 - DÃY ƯU THẾ.java b/J02037 - DÃY ƯU THẾ.java new file mode 100644 index 0000000..7ad2c4e --- /dev/null +++ b/J02037 - DÃY ƯU THẾ.java @@ -0,0 +1,22 @@ +import java.util.*; +import java.io.*; + +public class Main { + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + sc.nextLine(); + while (t-- > 0) { + String[] s = sc.nextLine().trim().split("\\s+"); + int cnt = 0; + for (int i = 0; i < s.length; i++) { + if (Integer.parseInt(s[i]) % 2 == 0) + cnt++; + } + if (s.length % 2 == 0 && cnt > s.length - cnt || s.length % 2 == 1 && s.length - cnt > cnt) + System.out.println("YES"); + else System.out.println("NO"); + } + } +} diff --git a/J02101 - IN MA TRẬN.java b/J02101 - IN MA TRẬN.java new file mode 100644 index 0000000..c43043c --- /dev/null +++ b/J02101 - IN MA TRẬN.java @@ -0,0 +1,29 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + int[][] a = new int[n][n]; + for(int i=0; i=0; j--) System.out.printf("%d ", a[i][j]); + j=0; + } + } + System.out.println(""); + } + sc.close(); + } +} diff --git a/J02102 - MA TRẬN XOẮN ỐC TĂNG DẦN.java b/J02102 - MA TRẬN XOẮN ỐC TĂNG DẦN.java new file mode 100644 index 0000000..215dc45 --- /dev/null +++ b/J02102 - MA TRẬN XOẮN ỐC TĂNG DẦN.java @@ -0,0 +1,50 @@ +import java.util.*; + +public class Main { + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[][] a = new int[n][n]; + int[] b = new int[n * n]; + for (int i = 0; i < n * n; i++) + b[i] = sc.nextInt(); + Arrays.sort(b); + int x = 0, y = 0, i = 0; + while (i < n * n) { + while (y < n && a[x][y] == 0) { + a[x][y] = b[i]; + y++; + i++; + } + x++; + y--; + while (x < n && a[x][y] == 0) { + a[x][y] = b[i]; + x++; + i++; + } + y--; + x--; + while (y >= 0 && a[x][y] == 0) { + a[x][y] = b[i]; + y--; + i++; + } + x--; + y++; + while (x >= 0 && a[x][y] == 0) { + a[x][y] = b[i]; + x--; + i++; + } + y++; + x++; + } + for (i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + System.out.printf("%d ", a[i][j]); + } + System.out.println(""); + } + } +} diff --git a/J02103 - TÍCH MA TRẬN VỚI CHUYỂN VỊ CỦA NÓ.java b/J02103 - TÍCH MA TRẬN VỚI CHUYỂN VỊ CỦA NÓ.java new file mode 100644 index 0000000..3a03ad6 --- /dev/null +++ b/J02103 - TÍCH MA TRẬN VỚI CHUYỂN VỊ CỦA NÓ.java @@ -0,0 +1,45 @@ +package nyagami; + +import java.util.Scanner; + +public class test{ + static int[][] trans(int[][] a, int n, int m){ + int[][] b = new int[m][n]; + for(int i=0; i 3-cnt) res++; + } + System.out.print(res); + sc.close(); + } +} diff --git a/J03004 - CHUẨN HÓA XÂU HỌ TÊN - 1.java b/J03004 - CHUẨN HÓA XÂU HỌ TÊN - 1.java new file mode 100644 index 0000000..f8b06a2 --- /dev/null +++ b/J03004 - CHUẨN HÓA XÂU HỌ TÊN - 1.java @@ -0,0 +1,33 @@ +package pkg1.chuan_hoa_xau_ho_ten1; + +import java.util.Scanner; + + +public class Chuan_hoa_xau_ho_ten1 { + + static String edit(String s){ + String s1 = s.substring(0, 1); + String s2 = s.substring(1, s.length()); + s1 = s1.toUpperCase(); + return s1+s2; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + sc.nextLine(); + while(t>0){ + t-=1; + String s = sc.nextLine(); + s = s.toLowerCase(); + s = s.replaceAll("\\s+", " "); + s = s.trim(); + String word[] = s.split("\\s"); + for( String i : word){ + System.out.print(edit(i)+" "); + } + System.out.println(""); + } + } + +} diff --git a/J03005 - CHUẨN HÓA XÂU HỌ TÊN - 2.java b/J03005 - CHUẨN HÓA XÂU HỌ TÊN - 2.java new file mode 100644 index 0000000..66c1428 --- /dev/null +++ b/J03005 - CHUẨN HÓA XÂU HỌ TÊN - 2.java @@ -0,0 +1,35 @@ +import java.util.Scanner; +import java.util.ArrayDeque; +import java.util.Queue; + +public class Main{ + static char up(char x){ + if('a'<=x && x<='z') return (char)((int)x-32); + return x; + } + static Queue re(String name){ + String[] a = name.split("[' ']+"); + Queue r = new ArrayDeque<>(); + + for(int i=0; i q = re(name.toLowerCase()); + String[] a = new String[q.size()]; + q.toArray(a); + a[a.length-1] += ","; + for(int i=1; i0){ + String s=sc.next(); + System.out.println(check(s)); + } + sc.close(); + } +} diff --git a/J03007 - SỐ ĐẸP 2.java b/J03007 - SỐ ĐẸP 2.java new file mode 100644 index 0000000..719f06b --- /dev/null +++ b/J03007 - SỐ ĐẸP 2.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class Main { + static String check(String s){ + int n=s.length(); + if(s.charAt(n-1)!='8') return "NO"; + int sum=0; + for(int i=0;i0){ + String s=sc.next(); + System.out.println(check(s)); + } + sc.close(); + } +} diff --git a/J03008 - SỐ ĐẸP 3.java b/J03008 - SỐ ĐẸP 3.java new file mode 100644 index 0000000..ce2db8d --- /dev/null +++ b/J03008 - SỐ ĐẸP 3.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +public class Main { + static String nt="2357"; + static String check(String s){ + int n=s.length(); + for(int i=0;i0){ + String s=sc.next(); + System.out.println(check(s)); + } + sc.close(); + } +} diff --git a/J03009 - TẬP TỪ RIÊNG CỦA HAI XÂU.java b/J03009 - TẬP TỪ RIÊNG CỦA HAI XÂU.java new file mode 100644 index 0000000..0120c81 --- /dev/null +++ b/J03009 - TẬP TỪ RIÊNG CỦA HAI XÂU.java @@ -0,0 +1,37 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package pkg6.tap_tu_rieng_cua_2_xau; + +import java.util.HashSet; +import java.util.Scanner; +import java.util.Set; + +/** + * + * @author GIGABYTE + */ +public class Tap_tu_rieng_cua_2_xau { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + sc.nextLine(); + while(t>0){ + t-=1; + Set st = new HashSet<>(); + String s1[] = sc.nextLine().split("\\s"); + String s2 = sc.nextLine(); + for(String word: s1){ + if(!s2.contains(word)){ + st.add(word); + } + } + for(String i: st){ + System.out.print(i + " "); + } + System.out.println(""); + } + } + +} diff --git a/J03010 - ĐỊA CHỈ EMAIL.java b/J03010 - ĐỊA CHỈ EMAIL.java new file mode 100644 index 0000000..78ebe0b --- /dev/null +++ b/J03010 - ĐỊA CHỈ EMAIL.java @@ -0,0 +1,31 @@ +import java.util.Scanner; +import java.util.HashMap; + +public class Main{ + static String mail(String s){ + String[] a = s.split("[' ']+"); + String r = a[a.length-1]; + for(int i=0; i a = new HashMap<>(); + while(sc.hasNextLine()){ + String name = sc.nextLine(); + if(name.length() == 0) continue; + String user = mail(name.toLowerCase()); + if(a.get(user) == null){ + a.put(user, 2); + }else{ + int th = a.get(user); + a.put(user, th+1); + user += Integer.toString(th); + } + System.out.println(user + "@ptit.edu.vn"); + } + } +} diff --git a/J03011 - ƯỚC SỐ CHUNG LỚN NHẤT CỦA SỐ NGUYÊN LỚN.java b/J03011 - ƯỚC SỐ CHUNG LỚN NHẤT CỦA SỐ NGUYÊN LỚN.java new file mode 100644 index 0000000..181693b --- /dev/null +++ b/J03011 - ƯỚC SỐ CHUNG LỚN NHẤT CỦA SỐ NGUYÊN LỚN.java @@ -0,0 +1,18 @@ +import java.math.BigInteger; +import java.util.Scanner; + +public class Main { + static BigInteger gcd(BigInteger a, BigInteger b){ + if(b.equals(BigInteger.ZERO)) return a; + return gcd(b,a.mod(b)); + } + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t=sc.nextInt(); + while(t-->0){ + BigInteger a=sc.nextBigInteger(), b=sc.nextBigInteger(); + System.out.println(gcd(a,b)); + } + sc.close(); + } +} diff --git a/J03012 - TỔNG SỐ NGUYÊN LỚN - 1.java b/J03012 - TỔNG SỐ NGUYÊN LỚN - 1.java new file mode 100644 index 0000000..dbaf1ba --- /dev/null +++ b/J03012 - TỔNG SỐ NGUYÊN LỚN - 1.java @@ -0,0 +1,13 @@ +import java.util.*; +import java.math.*; +public class Main { + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + BigInteger a = new BigInteger(sc.next()); + BigInteger b = new BigInteger(sc.next()); + System.out.println(a.add(b)); + } + } +} diff --git a/J03013 - HIỆU SỐ NGUYÊN LỚN - 1.java b/J03013 - HIỆU SỐ NGUYÊN LỚN - 1.java new file mode 100644 index 0000000..7274634 --- /dev/null +++ b/J03013 - HIỆU SỐ NGUYÊN LỚN - 1.java @@ -0,0 +1,17 @@ +import java.util.Scanner; +import java.math.BigInteger; + +public class Main{ + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + BigInteger a = new BigInteger(sc.next()); + BigInteger b = new BigInteger(sc.next()); + int max = Math.max(a.toString().length(), b.toString().length()); + String ans = a.subtract(b).abs().toString(); + while(ans.length()0){ + BigInteger a = new BigInteger(sc.next()); + BigInteger b = new BigInteger(sc.next()); + System.out.println(a.add(b)); + } + } +} diff --git a/J03015 - HIỆU SỐ NGUYÊN LỚN - 2.java b/J03015 - HIỆU SỐ NGUYÊN LỚN - 2.java new file mode 100644 index 0000000..a517c46 --- /dev/null +++ b/J03015 - HIỆU SỐ NGUYÊN LỚN - 2.java @@ -0,0 +1,14 @@ +import java.math.BigInteger; +import java.util.Scanner; + +public class Main { + static BigInteger gcd(BigInteger a, BigInteger b){ + if(b.equals(BigInteger.ZERO)) return a; + return gcd(b,a.mod(b)); + } + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + BigInteger a=sc.nextBigInteger(),b=sc.nextBigInteger(); + System.out.println(a.subtract(b)); + } +} diff --git a/J03016 - CHIA HẾT CHO 11.java b/J03016 - CHIA HẾT CHO 11.java new file mode 100644 index 0000000..fe0d476 --- /dev/null +++ b/J03016 - CHIA HẾT CHO 11.java @@ -0,0 +1,14 @@ +import java.util.*; +import java.math.*; +public class Main { + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + BigInteger a = new BigInteger(sc.next()); + if (a.mod(new BigInteger("11")).equals(BigInteger.ZERO)) + System.out.println("1"); + else System.out.println("0"); + } + } +} diff --git a/J03017 - LOẠI BỎ “100”.java b/J03017 - LOẠI BỎ “100”.java new file mode 100644 index 0000000..821e68f --- /dev/null +++ b/J03017 - LOẠI BỎ “100”.java @@ -0,0 +1,33 @@ +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = Integer.parseInt(sc.nextLine()); + while(t-->0){ + String s = sc.next(); + Stack st = new Stack<>(); + for(int i=0;i 0) { + BigInteger n = new BigInteger(sc.next()); + int a = Integer.parseInt(n.mod(BigInteger.valueOf(4)).toString()); + int b = Integer.parseInt(n.mod(BigInteger.valueOf(2)).toString()); + int s = 1 + pow(2, a) + pow(3, a) + pow(4, b); + System.out.println(s%5); + } + } +} diff --git a/J03019 - XÂU CON LỚN NHẤT.java b/J03019 - XÂU CON LỚN NHẤT.java new file mode 100644 index 0000000..537b203 --- /dev/null +++ b/J03019 - XÂU CON LỚN NHẤT.java @@ -0,0 +1,31 @@ +import java.util.*; +import java.math.*; + +public class Main { + static class pi { + char c; + int index; + + public pi(char x, int y) { + c = x; + index = y; + } + } + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + String s = sc.next(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < s.length(); i++) + a.add(new pi(s.charAt(i), i)); + a.sort((pi x, pi y) -> { + return (int) (y.c - x.c); + }); + int pre = 0; + for (int i = 0; i < a.size(); i++) { + if (a.get(i).index < pre) + continue; + System.out.print(a.get(i).c); + pre = a.get(i).index; + } + } +} diff --git a/J03020 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java b/J03020 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java new file mode 100644 index 0000000..f5ee1e0 --- /dev/null +++ b/J03020 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java @@ -0,0 +1,61 @@ +import java.util.*; + +public class Main { + + static class word { + String w; + int cnt, stt; + + public word(String w, int i) { + this.w = w; + this.cnt = 1; + this.stt = i; + } + + @Override + public String toString() { + return w + " " + cnt; + } + } + + static boolean tn(String s) { + for (int i = 0; i < s.length() / 2; i++) { + if (s.charAt(i) != s.charAt(s.length() - 1 - i)) + return false; + } + return true; + } + + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int index = 0; + while (sc.hasNext()) { + String s = sc.next(); + if (!tn(s)) + continue; + boolean oke = true; + for (int i = 0; i < a.size(); i++) { + if (a.get(i).w.compareTo(s) == 0) { + oke = false; + a.get(i).cnt += 1; + } + } + if (oke) { + a.add(new word(s, index)); + index++; + } + } + a.sort((word x, word y) -> { + if (x.w.length() == y.w.length()) { + return x.stt - y.stt; + } + return y.w.length() - x.w.length(); + }); + a.forEach(e -> { + if (e.w.length() == a.get(0).w.length()) + System.out.println(e); + }); + } +} diff --git a/J03021 - ĐIỆN THOẠI CỤC GẠCH.java b/J03021 - ĐIỆN THOẠI CỤC GẠCH.java new file mode 100644 index 0000000..edecead --- /dev/null +++ b/J03021 - ĐIỆN THOẠI CỤC GẠCH.java @@ -0,0 +1,35 @@ +import java.util.Scanner; +import java.math.BigInteger; + +public class Main{ + static char convert(char x){ + if("ABC".indexOf(x) > -1) return '2'; + if("DEF".indexOf(x) > -1) return '3'; + if("GHI".indexOf(x) > -1) return '4'; + if("JKL".indexOf(x) > -1) return '5'; + if("MNO".indexOf(x) > -1) return '6'; + if("PQRS".indexOf(x) > -1) return '7'; + if("TUV".indexOf(x) > -1) return '8'; + return '9'; + } + static boolean dx(char[] a, int n){ + for(int i=0;i<=n/2;i++){ + if(a[i]!=a[n-i-1]) return false; + } + return true; + } + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + String s = sc.next(); + s = s.toUpperCase(); + char[] c = new char[s.length()]; + for(int i=0; i a = new HashMap<>(); + static String LM = "MDCLXVI"; + + static int cal(String s) { + for (int i = 0; i < LM.length(); i++) { + if (s.indexOf(LM.charAt(i)) > -1) { + int x = s.indexOf(LM.charAt(i)); + return a.get(LM.charAt(i)) - cal(s.substring(0, x)) + cal(s.substring(x + 1)); + } + } + return 0; + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + a.put('I', 1); + a.put('V', 5); + a.put('X', 10); + a.put('L', 50); + a.put('C', 100); + a.put('D', 500); + a.put('M', 1000); + int t = sc.nextInt(); + while (t-- > 0) { + System.out.println(cal(sc.next())); + } + } +} diff --git a/J03024 - SỐ ƯU THẾ.java b/J03024 - SỐ ƯU THẾ.java new file mode 100644 index 0000000..e9c671d --- /dev/null +++ b/J03024 - SỐ ƯU THẾ.java @@ -0,0 +1,29 @@ +import java.math.BigInteger; +import java.util.Scanner; + +public class Main { + static boolean is(char x){ + if(x>='0' && x<='9') return true; + return false; + } + static String check(String s){ + if(s.charAt(0)=='0') return "INVALID"; + int n=s.length(); + int c=0; + for(int i=0;in-c) return "YES"; + if(n%2==1 && c0){ + String S = sc.next(); + int cnt = 0; + for(int i=0; i0){ + String a = sc.next(); + String b = sc.next(); + if(!eq(a,b)) System.out.println(Math.max(a.length(), b.length())); + else System.out.println("-1"); + } + sc.close(); + } +} diff --git a/J03027 - RÚT GỌN XÂU KÝ TỰ.java b/J03027 - RÚT GỌN XÂU KÝ TỰ.java new file mode 100644 index 0000000..e56bb28 --- /dev/null +++ b/J03027 - RÚT GỌN XÂU KÝ TỰ.java @@ -0,0 +1,20 @@ +import java.util.Scanner; +import java.util.Stack; + +public class Main{ + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + String s = sc.next(); + Stack a = new Stack<>(); + for(int i=0; i System.out.print(c)); + sc.close(); + } +} diff --git a/J03028 - MÃ HÓA DRM.java b/J03028 - MÃ HÓA DRM.java new file mode 100644 index 0000000..337058b --- /dev/null +++ b/J03028 - MÃ HÓA DRM.java @@ -0,0 +1,37 @@ +import java.util.*; +public class non { + + static int value(String s){ + int cnt = 0; + for(int i=0; i0){ + String s = sc.next(); + String a = s.substring(0, s.length()/2); + String b = s.substring(s.length()/2); + a = turn(a); + b = turn(b); + String r = ""; + for(int i=0;i1){ + n-=1; + a[a.length - 2] += a[a.length - 1]; + } + } + int i=0; + while(i 0) { + String s = sc.next(); + int k = sc.nextInt(); + HashSet hs = new HashSet<>(); + for (int i = 0; i < s.length(); i++) { + hs.add(s.charAt(i)); + } + if (s.length() >= 26 && hs.size() + k >= 26) { + System.out.println("YES"); + }else System.out.println("NO"); + } + } +} diff --git a/J03032 - ĐẢO TỪ.java b/J03032 - ĐẢO TỪ.java new file mode 100644 index 0000000..0825a8a --- /dev/null +++ b/J03032 - ĐẢO TỪ.java @@ -0,0 +1,22 @@ +import java.util.Scanner; +import java.util.Stack; + +public class Main{ + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + sc.nextLine(); + while(t-->0){ + String line = sc.nextLine(); + String[] w = line.split("[' ']+"); + for(int i=0; i0){ + BigInteger a = new BigInteger(sc.next()); + BigInteger b = new BigInteger(sc.next()); + System.out.println(a.multiply(b).divide(gcd(a,b))); + } + sc.close(); + } +} diff --git a/J03035 - ĐIỀN CHỮ SỐ.java b/J03035 - ĐIỀN CHỮ SỐ.java new file mode 100644 index 0000000..06265c7 --- /dev/null +++ b/J03035 - ĐIỀN CHỮ SỐ.java @@ -0,0 +1,46 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static long pow(long a, long b){ + if(b==0) return 1; + return pow(a, b-1) * a; + } + + static long q_cnt(String a){ + long r=0; + for(int i=0;i b.charAt(i)) return pow(10, rm); + return cnt(i+1, a, b, rm); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = Integer.parseInt(sc.nextLine()); + while(t-->0){ + String a = sc.next(), b = sc.next(); + long n = q_cnt(a); + if(a.length() b.length()){ + if(a.charAt(0) == '?') System.out.println(9*pow(10, n-1)); + else System.out.println(pow(10, n)); + }else{ + System.out.println(cnt(0,a,b,n)); + } + } + } +} diff --git a/J03036 - XOAY VÒNG KÝ TỰ.java b/J03036 - XOAY VÒNG KÝ TỰ.java new file mode 100644 index 0000000..c50fa05 --- /dev/null +++ b/J03036 - XOAY VÒNG KÝ TỰ.java @@ -0,0 +1,39 @@ +import java.util.*; + +public class non { + + static int turn(String a, String b){ + if(a.length() != b.length()) return -1; + String s = a; + for(int i=0;i<=a.length();i++){ + if(s.compareTo(b) == 0) return i; + s = s.substring(1) + s.charAt(0); + } + return -1; + } + + static void solve(String[] a){ + int ans = 1000000; + for(String i: a){ + int cnt = 0; + for(String j:a){ + int x = turn(j, i); + if(x==-1){ + System.out.println(-1); + return; + } + cnt+=x; + } + ans=Math.min(ans, cnt); + } + System.out.println(ans); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + String[] a = new String[n]; + for(int i=0;i a = new ArrayList<>(); + for (char c = 'A'; c <= 'Z'; c++) { + int i = 0; + pair x = new pair(); + for (int j = 0; j < s.length(); j++) { + if (s.charAt(j) == c) { + if (i == 0) { + x.x = j; + i++; + } else + x.y = j; + } + } + a.add(x); + } + int cnt = 0; + for (int i = 0; i < a.size() - 1; i++) { + for (int j = i + 1; j < a.size(); j++) { + if (a.get(i).y < a.get(j).x || a.get(j).y < a.get(i).x || (a.get(i).x-a.get(j).x) * (a.get(j).y -a.get(i).y) > 0) + continue; + cnt++; + } + } + System.out.println(cnt); + } +} diff --git a/J03038 - ĐÁNH DẤU CHỮ CÁI.java b/J03038 - ĐÁNH DẤU CHỮ CÁI.java new file mode 100644 index 0000000..b25bbb1 --- /dev/null +++ b/J03038 - ĐÁNH DẤU CHỮ CÁI.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package pkg17.danh_dau_chu_cai; + +import java.util.HashSet; +import java.util.Scanner; +import java.util.Set; + +/** + * + * @author GIGABYTE + */ +public class Danh_dau_chu_cai { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + + String s = sc.nextLine(); + Set st = new HashSet<>(); + for(int i=0;i0){ + BigInteger a = new BigInteger(sc.next()); + BigInteger b = new BigInteger(sc.next()); + if(a.mod(b).equals(BigInteger.ZERO) || b.mod(a).equals(BigInteger.ZERO)) System.out.println("YES"); + else System.out.println("NO"); + } + sc.close(); + } +} diff --git a/J03040 - BIỂN SỐ ĐẸP.java b/J03040 - BIỂN SỐ ĐẸP.java new file mode 100644 index 0000000..5b336c2 --- /dev/null +++ b/J03040 - BIỂN SỐ ĐẸP.java @@ -0,0 +1,32 @@ +import java.util.Scanner; +import java.math.BigInteger; + +public class Main{ + static boolean inc(String s){ + for(int i=0; i= s.charAt(i+1)) return false; + } + return true; + } + static boolean equal(String s){ + if(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2) && s.charAt(3) == s.charAt(4)) return true; + return false; + } + static boolean se(String s){ + for(int i=0; i0){ + String card = sc.next().substring(5); + String[] a = card.split("['.']"); + card = a[0] + a[1]; + if(inc(card) || equal(card) || se(card)) System.out.println("YES"); + else System.out.println("NO"); + } + } +} diff --git a/J04001 - KHAI BÁO LỚP POINT.java b/J04001 - KHAI BÁO LỚP POINT.java new file mode 100644 index 0000000..26181ca --- /dev/null +++ b/J04001 - KHAI BÁO LỚP POINT.java @@ -0,0 +1,25 @@ +import java.util.Scanner; +public class Main{ + static class point{ + double x,y; + public void get(Scanner sc){ + x = sc.nextDouble(); + y = sc.nextDouble(); + } + } + static double dis(point a, point b){ + return Math.sqrt(Math.pow(a.x-b.x,2) + Math.pow(a.y - b.y, 2)); + } + public static void main(String args[]){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- > 0){ + point a = new point(); + point b = new point(); + a.get(sc); + b.get(sc); + System.out.printf("%.4f\n",dis(a,b)); + } + sc.close(); + } +} diff --git a/J04002 - KHAI BÁO LỚP HÌNH CHỮ NHẬT.java b/J04002 - KHAI BÁO LỚP HÌNH CHỮ NHẬT.java new file mode 100644 index 0000000..3ab4938 --- /dev/null +++ b/J04002 - KHAI BÁO LỚP HÌNH CHỮ NHẬT.java @@ -0,0 +1,17 @@ +import java.util.Scanner; +import java.math.BigInteger; + +public class Main{ + static String st(String s){ + if(s.length()==1) return "" + Character.toUpperCase(s.charAt(0)); + s = s.toLowerCase(); + return "" + Character.toUpperCase(s.charAt(0)) + s.substring(1); + } + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(), b = sc.nextInt(); + String c = sc.next(); + if(a>0 && b>0) System.out.printf("%d %d %s",(a+b)*2, a*b, st(c)); + else System.out.println("INVALID"); + } +} diff --git a/J04003 - PHÂN SỐ.java b/J04003 - PHÂN SỐ.java new file mode 100644 index 0000000..0a02342 --- /dev/null +++ b/J04003 - PHÂN SỐ.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class Main{ + static long gcd(long a, long b){ + if(b==0) return a; + return gcd(b,a%b); + } + public static void main(String args[]){ + Scanner sc = new Scanner(System.in); + long a = sc.nextLong(), b = sc.nextLong(); + long g = gcd(a,b); + a/=g; b/=g; + System.out.printf("%d/%d",a,b); + sc.close(); + } +} diff --git a/J04004 - TỔNG PHÂN SỐ.java b/J04004 - TỔNG PHÂN SỐ.java new file mode 100644 index 0000000..3a81f5d --- /dev/null +++ b/J04004 - TỔNG PHÂN SỐ.java @@ -0,0 +1,21 @@ +import java.util.Scanner; +import java.math.BigInteger; + +public class Main{ + static long gcd(long a, long b){ + if(b==0) return a; + return gcd(b, a%b); + } + public static void main(String[] arg){ + Scanner sc = new Scanner(System.in); + long a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(); + long u1 = gcd(a,b), u2 = gcd(c,d); + a/=u1; b/=u1; c/=u2; d/=u2; + long m = b*d/gcd(b,d); + long t = a*(m/b) + c*(m/d); + long u = gcd(t,m); + t/=u; m/=u; + System.out.printf("%d/%d",t,m); + sc.close(); + } +} diff --git a/J04005 - KHAI BÁO LỚP THÍ SINH.java b/J04005 - KHAI BÁO LỚP THÍ SINH.java new file mode 100644 index 0000000..52a7161 --- /dev/null +++ b/J04005 - KHAI BÁO LỚP THÍ SINH.java @@ -0,0 +1,24 @@ +import java.util.Scanner; +public class Main{ + static class person{ + String name, date; + float a, b, c; + public void out(){ + System.out.printf("%s %s %.1f", name, date, a + b + c); + } + public void in(Scanner sc){ + name = sc.nextLine(); + date = sc.next(); + a = sc.nextFloat(); + b = sc.nextFloat(); + c = sc.nextFloat(); + } + } + public static void main(String args[]){ + Scanner sc = new Scanner(System.in); + person a = new person(); + a.in(sc); + a.out(); + sc.close(); + } +} diff --git a/J04006 - KHAI BÁO LỚP SINH VIÊN.java b/J04006 - KHAI BÁO LỚP SINH VIÊN.java new file mode 100644 index 0000000..0192729 --- /dev/null +++ b/J04006 - KHAI BÁO LỚP SINH VIÊN.java @@ -0,0 +1,14 @@ +import java.util.*; +public class Main{ + static String conver(String d){ + String[] arr = d.split("/"); + for(int i=0; i= c[0]+c[1]+c[2]) return false; + return true; + } + public static void main(String[] a) { + Scanner sc=new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + pair[] p = new pair[3]; + for(int i=0; i<3; i++) p[i] = new pair(sc.nextDouble(), sc.nextDouble()); + double[] c = new double[3]; + for(int i=0; i<3; i++){ + c[i] = dis(p[i], p[(i+1)%3]); + } + if(validate(c)) System.out.printf("%.3f\n",c[0]+c[1]+c[2]); + else System.out.println("INVALID"); + } + } +} diff --git a/J04009 - DIỆN TÍCH TAM GIÁC.java b/J04009 - DIỆN TÍCH TAM GIÁC.java new file mode 100644 index 0000000..4934d86 --- /dev/null +++ b/J04009 - DIỆN TÍCH TAM GIÁC.java @@ -0,0 +1,54 @@ +import java.io.InputStream; +import java.util.*; + +public class Main { + + + static class Point{ + double x, y; + + public Point(double a, double b){ + x = a; + y = b; + } + + static Point nextPoint(Scanner sc){ + Point a = new Point(sc.nextDouble(), sc.nextDouble()); + return a; + } + } + + static double dis(Point a, Point b){ + return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); + } + + static class Triangle{ + double A, B, C; + public Triangle(Point a, Point b, Point c){ + A = dis(a, b); + B = dis(b, c); + C = dis(c, a); + } + public boolean valid(){ + double m = Math.max(A, Math.max(B, C)); + return 2*m < A + B + C; + } + public String getPerimeter(){ + double s = Math.sqrt((A+B+C)*(A+B-C)*(A-B+C)*(-A+B+C))/4; + return String.format("%.2f", s); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >0){ + Triangle a = new Triangle(Point.nextPoint(sc), Point.nextPoint(sc), Point.nextPoint(sc)); + if(!a.valid()){ + System.out.println("INVALID"); + } else{ + System.out.println(a.getPerimeter()); + } + } + } +} diff --git a/J04010 - DIỆN TÍCH HÌNH TRÒN NGOẠI TIẾP TAM GIÁC.java b/J04010 - DIỆN TÍCH HÌNH TRÒN NGOẠI TIẾP TAM GIÁC.java new file mode 100644 index 0000000..54d62bd --- /dev/null +++ b/J04010 - DIỆN TÍCH HÌNH TRÒN NGOẠI TIẾP TAM GIÁC.java @@ -0,0 +1,56 @@ +import java.io.InputStream; +import java.util.*; + +public class Main { + + + static class Point{ + double x, y; + + public Point(double a, double b){ + x = a; + y = b; + } + + static Point nextPoint(Scanner sc){ + Point a = new Point(sc.nextDouble(), sc.nextDouble()); + return a; + } + } + + static double dis(Point a, Point b){ + return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); + } + + static class Triangle{ + double A, B, C; + public Triangle(Point a, Point b, Point c){ + A = dis(a, b); + B = dis(b, c); + C = dis(c, a); + } + public boolean valid(){ + double m = Math.max(A, Math.max(B, C)); + return 2*m < A + B + C; + } + public String getPerimeter(){ + double s = Math.sqrt((A+B+C)*(A+B-C)*(A-B+C)*(-A+B+C))/4; + double R = A*B*C/(4*s); + s = Math.PI*R*R; + return String.format("%.3f", s); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >0){ + Triangle a = new Triangle(Point.nextPoint(sc), Point.nextPoint(sc), Point.nextPoint(sc)); + if(!a.valid()){ + System.out.println("INVALID"); + } else{ + System.out.println(a.getPerimeter()); + } + } + } +} diff --git a/J04011 - BỐN ĐIỂM TRÊN MẶT PHẲNG.java b/J04011 - BỐN ĐIỂM TRÊN MẶT PHẲNG.java new file mode 100644 index 0000000..a8c9cd1 --- /dev/null +++ b/J04011 - BỐN ĐIỂM TRÊN MẶT PHẲNG.java @@ -0,0 +1,94 @@ +import java.util.*; + +public class Main { + + static long def(long a, long b, long c, long d) { + return a * d - b * c; + } + + static class Vector { + long x, y, z; + + public Vector(long a, long b, long c) { + x = a; + y = b; + z = c; + } + + public Vector() { + x = 0; + y = 0; + z = 0; + } + + public long tvh(Vector b) { + return this.x * b.x + this.y * b.y + this.z * b.z; + } + + public Vector tch(Vector b) { + Vector r = new Vector(); + r.x = def(this.y, this.z, b.y, b.z); + r.y = def(this.z, this.x, b.z, b.x); + r.z = def(this.x, this.y, b.x, b.y); + return r; + } + + } + + static class Point3D { + long x, y, z; + + public Point3D(int l, int m, int n) { + x = (long) l; + y = (long) m; + z = (long) n; + } + + public Point3D(long l, long m, long n) { + x = (long) l; + y = (long) m; + z = (long) n; + } + + static boolean check(Point3D p1, Point3D p2, Point3D p3, Point3D p4) { + Vector v1 = new Vector(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z); + Vector v2 = new Vector(p1.x - p3.x, p1.y - p3.y, p1.z - p3.z); + Vector v3 = new Vector(p1.x - p4.x, p1.y - p4.y, p1.z - p4.z); + Vector h = v1.tch(v2); + return h.tvh(v3) == 0; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + Point3D p1 = new Point3D(sc.nextInt(),sc.nextInt(),sc.nextInt()); + Point3D p2 = new Point3D(sc.nextInt(),sc.nextInt(),sc.nextInt()); + Point3D p3 = new Point3D(sc.nextInt(),sc.nextInt(),sc.nextInt()); + Point3D p4 = new Point3D(sc.nextInt(),sc.nextInt(),sc.nextInt()); + + if(Point3D.check(p1,p2,p3,p4)){ + System.out.println("YES"); + } else{ + System.out.println("NO"); + } + } + } + public static void main5078725(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + Point3D p1 = new Point3D(sc.nextInt(), sc.nextInt(), sc.nextInt()); + Point3D p2 = new Point3D(sc.nextInt(), sc.nextInt(), sc.nextInt()); + Point3D p3 = new Point3D(sc.nextInt(), sc.nextInt(), sc.nextInt()); + Point3D p4 = new Point3D(sc.nextInt(), sc.nextInt(), sc.nextInt()); + + if (Point3D.check(p1, p2, p3, p4)) { + System.out.println("YES"); + } else { + System.out.println("NO"); + } + } + } +} diff --git a/J04012 - BÀI TOÁN TÍNH CÔNG.java b/J04012 - BÀI TOÁN TÍNH CÔNG.java new file mode 100644 index 0000000..4c14b90 --- /dev/null +++ b/J04012 - BÀI TOÁN TÍNH CÔNG.java @@ -0,0 +1,31 @@ +import java.util.*; + +public class Main { + static int sup(String s) { + if (s.compareTo("GD") == 0) + return 250000; + if (s.compareTo("PGD") == 0) + return 200000; + if (s.compareTo("TP") == 0) + return 180000; + return 150000; + } + + static int ex(int l, int days) { + if (days >= 25) + return l / 5; + if (days >= 22) + return l / 10; + return 0; + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.printf("NV01 %s ", sc.nextLine()); + int x = sc.nextInt(); + int days = sc.nextInt(); + String cv = sc.next(); + int plus = ex(x*days, days); + int pc = sup(cv); + System.out.printf("%d %d %d %d", x * days, plus, pc, x * days + plus + pc); + } +} diff --git a/J04013 - BÀI TOÁN TUYỂN SINH.java b/J04013 - BÀI TOÁN TUYỂN SINH.java new file mode 100644 index 0000000..8da4452 --- /dev/null +++ b/J04013 - BÀI TOÁN TUYỂN SINH.java @@ -0,0 +1,52 @@ +import java.io.FileNotFoundException; +import java.util.Scanner; + +public class Main { + + private static class ThiSinh { + private String id, name; + private double scoreT, scoreL, scoreH, priorityScore, totalScore, sum; + private String tt; + + ThiSinh(String id, String name, double scoreT, double scoreL, double scoreH) { + this.id = id; + this.name = name; + this.scoreT = scoreT; + this.scoreL = scoreL; + this.scoreH = scoreH; + this.priorityScore = 0; + if (id.startsWith("KV1")) + this.priorityScore = 0.5; + if (id.startsWith("KV2")) + this.priorityScore = 1.0; + if (id.startsWith("KV3")) + this.priorityScore = 2.5; + this.sum = scoreT * 2 + scoreL + scoreH; + this.totalScore = scoreT * 2 + scoreL + scoreH + this.priorityScore; + + } + + void inThongTin() { + System.out.print(this.id + ' ' + this.name + ' '); + if ((int) this.priorityScore == this.priorityScore) + System.out.printf("%.0f ", this.priorityScore); + else + System.out.printf("%.1f ", this.priorityScore); + if ((int) this.sum == this.sum ) + System.out.printf("%.0f ", this.sum ); + else + System.out.printf("%.1f ", this.sum ); + if (this.totalScore >= 24) + this.tt = "TRUNG TUYEN"; + else + this.tt = "TRUOT"; + System.out.println(this.tt); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ThiSinh x = new ThiSinh(sc.nextLine(), sc.nextLine(), sc.nextDouble(), sc.nextDouble(), sc.nextDouble()); + x.inThongTin(); + } +} diff --git a/J04014 - TÍNH TOÁN PHÂN SỐ.java b/J04014 - TÍNH TOÁN PHÂN SỐ.java new file mode 100644 index 0000000..c02745f --- /dev/null +++ b/J04014 - TÍNH TOÁN PHÂN SỐ.java @@ -0,0 +1,63 @@ +import java.util.*;; + +public class Main { + static long gcd(long a, long b) { + if (b == 0) + return a; + return gcd(b, a % b); + } + + static class ps { + long t, m; + + public ps(long x, long y) { + t = x; + m = y; + this.rg(); + } + + public void rg() { + long x = gcd(t, m); + t /= x; + m /= x; + // if (m < 0) { + // t *= -1; + // m *= -1; + // } + } + + public ps add(ps b) { + ps r = new ps(0, 1); + r.m = m * b.m; + r.t = t * b.m + m * b.t; + r.rg(); + return r; + } + + public ps mul(ps b) { + ps r = new ps(0, 1); + r.t = t * b.t; + r.m = m * b.m; + r.rg(); + return r; + } + + @Override + public String toString() { + return String.format("%d/%d", t, m); + } + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + ps a = new ps(sc.nextLong(), sc.nextLong()); + ps b = new ps(sc.nextLong(), sc.nextLong()); + ps sum = a.add(b); + ps c = sum.mul(sum); + ps d = a.mul(b.mul(c)); + System.out.printf("%s %s\n", c, d); + + } + } +} diff --git a/J04015 - TÍNH THU NHẬP GIÁO VIÊN.java b/J04015 - TÍNH THU NHẬP GIÁO VIÊN.java new file mode 100644 index 0000000..085f9dc --- /dev/null +++ b/J04015 - TÍNH THU NHẬP GIÁO VIÊN.java @@ -0,0 +1,15 @@ +import java.util.*; +public class Main{ + static int sup(String s){ + if("HT".compareTo(s) == 0) return 2000000; + if("HP".compareTo(s) == 0) return 900000; + return 500000; + } + public static void main(String[] a) { + Scanner sc=new Scanner(System.in); + String code = sc.nextLine(); + + System.out.printf("%s %s %d %d %d", code, sc.nextLine(), Integer.parseInt(code.substring(2)), sup(code.substring(0,2)), + sup(code.substring(0,2)) + sc.nextInt() * Integer.parseInt(code.substring(2))); + } +} diff --git a/J04016 - TÍCH HAI ĐỐI TƯỢNG MA TRẬN.java b/J04016 - TÍCH HAI ĐỐI TƯỢNG MA TRẬN.java new file mode 100644 index 0000000..0653a36 --- /dev/null +++ b/J04016 - TÍCH HAI ĐỐI TƯỢNG MA TRẬN.java @@ -0,0 +1,71 @@ +import java.io.File; +import java.io.IOException; +import java.util.*; + +public class Main { + + static class Matrix { + long[][] a; + int n, m; + + public Matrix(int n, int m) { + a = new long[n][m]; + this.n = n; + this.m = m; + } + + public void nextMatrix(Scanner sc) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + a[i][j] = sc.nextLong(); + } + } + } + + public Matrix mul(Matrix b) { + Matrix r = new Matrix(n, b.m); + for (int i = 0; i < n; i++) { + for (int j = 0; j < b.m; j++) { + long s = 0; + for (int k = 0; k < m; k++) { + s += a[i][k] * b.a[k][j]; + } + r.a[i][j] = s; + } + } + return r; + } + + @Override + public String toString() { + String[] s = new String[n]; + for (int i = 0; i < n; i++) { + s[i] = ""; + for (int j = 0; j < m; j++) { + s[i] += a[i][j] + " "; + } + } + return String.join("\n", s); + } + + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), m = sc.nextInt(), p = sc.nextInt(); + Matrix a = new Matrix(n,m); + a.nextMatrix(sc); + Matrix b = new Matrix(m,p); + b.nextMatrix(sc); + System.out.println(a.mul(b)); + } + public static void main9850897(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), m = sc.nextInt(), p = sc.nextInt(); + Matrix a = new Matrix(n, m); + a.nextMatrix(sc); + Matrix b = new Matrix(m, p); + b.nextMatrix(sc); + System.out.println(a.mul(b)); + } +} + diff --git a/J04017 - TÍCH MA TRẬN VÀ CHUYỂN VỊ CỦA NÓ.java b/J04017 - TÍCH MA TRẬN VÀ CHUYỂN VỊ CỦA NÓ.java new file mode 100644 index 0000000..27429c9 --- /dev/null +++ b/J04017 - TÍCH MA TRẬN VÀ CHUYỂN VỊ CỦA NÓ.java @@ -0,0 +1,86 @@ +import java.io.File; +import java.io.IOException; +import java.util.*; + +public class Main { + + static class Matrix { + long[][] a; + int n, m; + + public Matrix(int n, int m) { + a = new long[n][m]; + this.n = n; + this.m = m; + } + + public void nextMatrix(Scanner sc) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + a[i][j] = sc.nextLong(); + } + } + } + + public Matrix trans(){ + Matrix r = new Matrix(m, n); + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + r.a[i][j] = a[j][i]; + } + } + return r; + } + + public Matrix mul(Matrix b) { + Matrix r = new Matrix(n, b.m); + for (int i = 0; i < n; i++) { + for (int j = 0; j < b.m; j++) { + long s = 0; + for (int k = 0; k < m; k++) { + s += a[i][k] * b.a[k][j]; + } + r.a[i][j] = s; + } + } + return r; + } + + @Override + public String toString() { + String[] s = new String[n]; + for (int i = 0; i < n; i++) { + s[i] = ""; + for (int j = 0; j < m; j++) { + s[i] += a[i][j] + " "; + } + } + return String.join("\n", s); + } + + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(), m = sc.nextInt(); + Matrix a = new Matrix(n,m); + a.nextMatrix(sc); + Matrix b = a.trans(); + System.out.println(a.mul(b)); + } + } + public static void main5238774(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(), m = sc.nextInt(); + Matrix a = new Matrix(n, m); + a.nextMatrix(sc); + Matrix b = a.trans(); + System.out.println(a.mul(b)); + } + } +} + diff --git a/J04018 - SỐ PHỨC.java b/J04018 - SỐ PHỨC.java new file mode 100644 index 0000000..8525549 --- /dev/null +++ b/J04018 - SỐ PHỨC.java @@ -0,0 +1,44 @@ +import java.util.*; + +public class Main { + + static class complex{ + int real, img; + + public complex(int a, int b){ + real = a; + img = b; + } + + public complex add(complex b){ + complex x = new complex(0, 0); + x.real = real + b.real; + x.img = img + b.img; + return x; + } + + public complex mul(complex b){ + complex x = new complex(0, 0); + x.real = real*b.real + -img*b.img; + x.img = real*b.img + img*b.real; + return x; + } + + @Override + public String toString(){ + return real + " + " + img + 'i'; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >0){ + complex a = new complex(sc.nextInt(), sc.nextInt()); + complex b = new complex(sc.nextInt(), sc.nextInt()); + complex c = a.add(b).mul(a); + complex d = a.add(b).mul(a.add(b)); + System.out.printf("%s, %s\n", c, d); + } + } +} diff --git a/J04019 - LỚP TRIANGLE - 1.java b/J04019 - LỚP TRIANGLE - 1.java new file mode 100644 index 0000000..f8b8429 --- /dev/null +++ b/J04019 - LỚP TRIANGLE - 1.java @@ -0,0 +1,67 @@ +import java.io.InputStream; +import java.util.*; + +public class Main { + + + static class Point{ + double x, y; + + public Point(double a, double b){ + x = a; + y = b; + } + + static Point nextPoint(Scanner sc){ + Point a = new Point(sc.nextDouble(), sc.nextDouble()); + return a; + } + } + + static double dis(Point a, Point b){ + return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2)); + } + + static class Triangle{ + double A, B, C; + public Triangle(Point a, Point b, Point c){ + A = dis(a, b); + B = dis(b, c); + C = dis(c, a); + } + public boolean valid(){ + double m = Math.max(A, Math.max(B, C)); + return 2*m < A + B + C; + } + public String getPerimeter(){ + double c = A+B+C; + return String.format("%.3f", c); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >0){ + Triangle a = new Triangle(Point.nextPoint(sc), Point.nextPoint(sc), Point.nextPoint(sc)); + if(!a.valid()){ + System.out.println("INVALID"); + } else{ + System.out.println(a.getPerimeter()); + } + } + } + public static void main6937539(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- >0){ + Triangle a = new Triangle(Point.nextPoint(sc), Point.nextPoint(sc), Point.nextPoint(sc)); + if(!a.valid()){ + System.out.println("INVALID"); + } else{ + System.out.println(a.getPerimeter()); + } + } + } +} + diff --git a/J04020 - LỚP PAIR.java b/J04020 - LỚP PAIR.java new file mode 100644 index 0000000..40143ac --- /dev/null +++ b/J04020 - LỚP PAIR.java @@ -0,0 +1,63 @@ +import java.util.*; +import java.io.*; + +public class Main{ + static boolean prime(Integer x){ + if(x<2) return false; + if(x==2) return true; + if(x%2==0) return false; + for(int i=3;i<=(int)Math.sqrt(x);i+=2){ + if(x%i==0) return false; + } + return true; + } + static class Pair { + public Integer x; + public Integer y; + public Pair(Integer a, Integer b){ + x = a; + y = b; + } + public boolean isPrime(){ + return prime(x) && prime(y); + } + @Override + public String toString(){ + return String.format("%d %d",x,y); + } + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + boolean check = false; + for(int i = 2; i <= 2*Math.sqrt(n); i++){ + Pair p = new Pair<>(i, n-i); + if(p.isPrime()){ + System.out.println(p); + check = true; + break; + } + } + if(!check) System.out.println(-1); + } + } + public static void main8500646(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + boolean check = false; + for(int i = 2; i <= 2*Math.sqrt(n); i++){ + Pair p = new Pair<>(i, n-i); + if(p.isPrime()){ + System.out.println(p); + check = true; + break; + } + } + if(!check) System.out.println(-1); + } + } +} diff --git a/J04021 - LỚP INTSET.java b/J04021 - LỚP INTSET.java new file mode 100644 index 0000000..0887ddd --- /dev/null +++ b/J04021 - LỚP INTSET.java @@ -0,0 +1,49 @@ +import java.util.*; + +public class Main { + static class IntSet { + TreeSet a; + + public IntSet(int[] arr) { + a = new TreeSet<>(); + for (int i : arr) + a.add(i); + } + + public IntSet union(IntSet b) { + b.a.forEach(e -> this.a.add(e)); + return this; + } + @Override + public String toString() { + String s = ""; + Object[] r = a.toArray(); + for (int i = 0; i < r.length; i++) + s += r[i] + " "; + return s; + } + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), m = sc.nextInt(), a[] = new int[n], b[] = new int[m]; + for(int i = 0; i a; + + public WordSet(String s) { + a = new TreeSet<>(); + String[] r = s.toLowerCase().trim().split("\\s+"); + for (int i = 0; i < r.length; i++) + a.add(r[i]); + } + + public WordSet() { + a = new TreeSet<>(); + } + + public WordSet union(WordSet b) { + WordSet c = new WordSet(); + c.a.addAll(this.a); + c.a.addAll(b.a); + return c; + } + + public WordSet intersection(WordSet b) { + WordSet c = new WordSet(); + for (String i : this.a) { + for (String j : b.a) { + if (i.compareTo(j) == 0) + c.a.add(i); + } + } + return c; + } + @Override + public String toString() { + String r = ""; + for (String i : a) + r += i + ' '; + return r; + } + } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + WordSet s1 = new WordSet(in.nextLine()); + WordSet s2 = new WordSet(in.nextLine()); + System.out.println(s1.union(s2)); + System.out.println(s1.intersection(s2)); + } + public static void main5905074(String[] args) { + Scanner in = new Scanner(System.in); + WordSet s1 = new WordSet(in.nextLine()); + WordSet s2 = new WordSet(in.nextLine()); + System.out.println(s1.union(s2)); + System.out.println(s1.intersection(s2)); + } +} + diff --git a/J05003 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 1.java b/J05003 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 1.java new file mode 100644 index 0000000..c48f142 --- /dev/null +++ b/J05003 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 1.java @@ -0,0 +1,28 @@ +import java.util.*; + +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String msv(int i) { + String s = Integer.toString(i); + while (s.length() < 3) + s = "0" + s; + return "B20DCCN" + s; + } + + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + for (int i = 1; i <= t; i++) { + sc.nextLine(); + System.out.printf("%s %s %s %s %.2f\n", msv(i), sc.nextLine(), sc.nextLine(), toD(sc.next()), sc.nextFloat()); + } + } +} diff --git a/J05004 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 2.java b/J05004 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 2.java new file mode 100644 index 0000000..67950b6 --- /dev/null +++ b/J05004 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 2.java @@ -0,0 +1,38 @@ +import java.util.*; + +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static String msv(int i) { + String s = Integer.toString(i); + while (s.length() < 3) + s = "0" + s; + return "B20DCCN" + s; + } + + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + for (int i = 1; i <= t; i++) { + sc.nextLine(); + System.out.printf("%s %s%s %s %.2f\n", msv(i), stdName( + sc.nextLine()), sc.nextLine(), toD(sc.next()), sc.nextFloat()); + } + } +} diff --git a/J05005 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 3.java b/J05005 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 3.java new file mode 100644 index 0000000..c427d0a --- /dev/null +++ b/J05005 - DANH SÁCH ĐỐI TƯỢNG SINH VIÊN - 3.java @@ -0,0 +1,60 @@ +import java.util.*; + +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String code, name, cl, date; + float gpa; + + public sv(int i, String n, String c, String d, Float s) { + code = "B20DCCN" + String.format("%03d", i); + name = stdName(n); + cl = c; + date = toD(d); + gpa = s; + } + + @Override + public String toString() { + return code + ' ' + name + cl + ' ' + date + ' ' + String.format("%.2f", gpa); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int t = sc.nextInt(); + for (int i = 1; i <= t; i++) { + sc.nextLine(); + a.add(new sv(i, sc.nextLine(), sc.next(), sc.next(), sc.nextFloat())); + } + Collections.sort(a, new Comparator() { + @Override + public int compare(sv x, sv y){ + if (y.gpa > x.gpa) + return 1; + if (y.gpa < x.gpa) + return -1; + return 0; + } + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05006 - DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java b/J05006 - DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java new file mode 100644 index 0000000..5f30d7f --- /dev/null +++ b/J05006 - DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java @@ -0,0 +1,52 @@ +import java.util.*; + +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String code, name, gender, address, date, tax, day; + float gpa; + + public sv(int i, String n, String c, String d, String add, String t, String day) { + code = String.format("%05d", i); + name = stdName(n); + gender = c; + date = d; + address = add; + tax = t; + this.day = day; + } + + @Override + public String toString() { + return code + ' ' + name + gender + ' ' + date + ' ' + address + ' ' + tax + ' ' + day; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int t = sc.nextInt(); + sc.nextLine(); + for (int i = 1; i <= t; i++) { + a.add(new sv(i, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05007 - SẮP XẾP DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java b/J05007 - SẮP XẾP DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java new file mode 100644 index 0000000..875b09e --- /dev/null +++ b/J05007 - SẮP XẾP DANH SÁCH ĐỐI TƯỢNG NHÂN VIÊN.java @@ -0,0 +1,62 @@ +import java.util.*; +import java.text.*; +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String code, name, gender, address, date, tax, day; + float gpa; + + public sv(int i, String n, String c, String d, String add, String t, String day) { + code = String.format("%05d", i); + name = stdName(n); + gender = c; + date = d; + address = add; + tax = t; + this.day = day; + } + + @Override + public String toString() { + return code + ' ' + name + gender + ' ' + date + ' ' + address + ' ' + tax + ' ' + day; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int t = sc.nextInt(); + sc.nextLine(); + for (int i = 1; i <= t; i++) { + a.add(new sv(i, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + SimpleDateFormat f = new SimpleDateFormat("dd/mm/yyyy"); + a.sort((sv x, sv y) -> { + int c = 0; + try{ + c = f.parse(x.date).compareTo(f.parse(y.date)); + }catch (ParseException e){ + + } + return c; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05008 - DIỆN TÍCH ĐA GIÁC.java b/J05008 - DIỆN TÍCH ĐA GIÁC.java new file mode 100644 index 0000000..50b7814 --- /dev/null +++ b/J05008 - DIỆN TÍCH ĐA GIÁC.java @@ -0,0 +1,23 @@ +import java.util.*; + +public class non { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(); + long[] x = new long[n]; + long[] y = new long[n]; + for (int i = 0; i < n; i++) { + x[i] = sc.nextLong(); + y[i] = sc.nextLong(); + } + long s = 0; + for (int i = 0; i < n; i++) { + s += x[i] * y[(i + 1) % n]; + s -= x[(i + 1) % n] * y[i]; + } + System.out.printf("%.3f\n", Math.abs(s)*0.5); + } + } +} diff --git a/J05009 - TÌM THỦ KHOA CỦA KỲ THI.java b/J05009 - TÌM THỦ KHOA CỦA KỲ THI.java new file mode 100644 index 0000000..13197f0 --- /dev/null +++ b/J05009 - TÌM THỦ KHOA CỦA KỲ THI.java @@ -0,0 +1,57 @@ +import java.util.*; +import java.text.*; +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String name, date; + int code; + float sum; + + public sv(int i, String n, String d, float a, float b, float c) { + code = i; + name = n; + date = d; + sum = a+b+c; + } + + @Override + public String toString() { + return code + " " + name + ' ' + date + ' ' + String.format("%.1f", sum); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int t = sc.nextInt(); + for (int i = 1; i <= t; i++) { + sc.nextLine(); + a.add(new sv(i, sc.nextLine(), sc.next(), sc.nextFloat(), sc.nextFloat(), sc.nextFloat())); + } + SimpleDateFormat f = new SimpleDateFormat("dd/mm/yyyy"); + a.sort((sv x, sv y) -> { + if(x.sum == y.sum) return x.code - y.code; + return (int)(y.sum-x.sum); + }); + a.forEach(e -> { + if(e.sum == a.get(0).sum) System.out.println(e); + }); + } +} diff --git a/J05010 - SẮP XẾP DANH SÁCH MẶT HÀNG.java b/J05010 - SẮP XẾP DANH SÁCH MẶT HÀNG.java new file mode 100644 index 0000000..027552b --- /dev/null +++ b/J05010 - SẮP XẾP DANH SÁCH MẶT HÀNG.java @@ -0,0 +1,54 @@ +import java.util.*; +public class Main { + static String toD(String s) { + String[] d = s.split("/"); + for (int i = 0; i <= 1; i++) { + while (d[i].length() < 2) + d[i] = "0" + d[i]; + } + return d[0] + "/" + d[1] + "/" + d[2]; + } + + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String name, date; + int code; + double ex; + + public sv(int i, String n, String d, double a, double b) { + code = i; + name = n; + date = d; + ex = b-a; + } + + @Override + public String toString() { + return code + " " + name + ' ' + date + ' ' + String.format("%.2f", ex); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int t = sc.nextInt(); + for (int i = 1; i <= t; i++) { + sc.nextLine(); + a.add(new sv(i, sc.nextLine(), sc.nextLine(), sc.nextDouble(), sc.nextDouble())); + } + a.sort((sv x, sv y) -> { + return (int)(y.ex - x.ex); + }); + a.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J05011 - TÍNH GIỜ.java b/J05011 - TÍNH GIỜ.java new file mode 100644 index 0000000..57f386b --- /dev/null +++ b/J05011 - TÍNH GIỜ.java @@ -0,0 +1,41 @@ +import java.util.*; +import java.text.*; +public class Main { + + static class o { + String code, name, tin, tout; + Long time; + + public o(String code, String name, String tin, String tout) { + this.code = code; + this.name = name; + this.tin = tin; + this.tout = tout; + SimpleDateFormat f = new SimpleDateFormat("HH:mm"); + try { + time = (f.parse(tout).getTime() - f.parse(tin).getTime()) / 1000; + } catch (ParseException e) { + + } + } + + @Override + public String toString() { + return code + ' ' + name + ' ' + time / 3600 + " gio " + time / 60 % 60 + " phut"; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + sc.nextLine(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + a.add(new o(sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + a.sort((o x, o y) -> { + return y.time.compareTo(x.time); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05012 - TÍNH TIỀN.java b/J05012 - TÍNH TIỀN.java new file mode 100644 index 0000000..79b1a06 --- /dev/null +++ b/J05012 - TÍNH TIỀN.java @@ -0,0 +1,37 @@ +import java.io.File; +import java.io.IOException; +import java.util.*; + +public class Main { + + static class ob { + String code, name; + Long sl, price, ck, sum; + + public ob(String code, String name, long sl, long price, long ck) { + this.code = code; + this.name = name; + this.sl = sl; + this.price = price; + this.ck = ck; + this.sum = price * sl - ck; + } + + @Override + public String toString() { + return code + " " + name + " " + sl + " " + price + " " + ck + " " + sum; + } + + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new ob(sc.nextLine(), sc.nextLine(), sc.nextLong(), sc.nextLong(), sc.nextLong())); + } + a.sort((ob x, ob y) -> y.sum.compareTo(x.sum)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05013 - TUYỂN DỤNG.java b/J05013 - TUYỂN DỤNG.java new file mode 100644 index 0000000..7266303 --- /dev/null +++ b/J05013 - TUYỂN DỤNG.java @@ -0,0 +1,45 @@ +import java.util.*; + +public class Main { + + static class ob { + String code, name, type; + Double sum; + + public ob(int i, String name, double x, double y) { + this.code = String.format("TS%02d", i); + this.name = name; + if (x > 10) + x /= 10; + if (y > 10) + y /= 10; + this.sum = (x + y) / 2; + if (this.sum < 5) + this.type = "TRUOT"; + else if (this.sum < 8) + this.type = "CAN NHAC"; + else if (this.sum <= 9.5) + this.type = "DAT"; + else + this.type = "XUAT SAC"; + } + + @Override + public String toString() { + return code + " " + name + " " + String.format("%.2f", sum) + " " + type; + } + } + + public static void main(String[] args) { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new ob(i + 1, sc.nextLine(), sc.nextDouble(), sc.nextDouble())); + } + a.sort((ob x, ob y) -> y.sum.compareTo(x.sum)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05014 - TUYỂN GIÁO VIÊN.java b/J05014 - TUYỂN GIÁO VIÊN.java new file mode 100644 index 0000000..25db9a9 --- /dev/null +++ b/J05014 - TUYỂN GIÁO VIÊN.java @@ -0,0 +1,56 @@ +import java.util.*; + +public class Main { + static String getSub(String s) { + if (s.startsWith("A")) + return "TOAN"; + if (s.startsWith("B")) + return "LY"; + return "HOA"; + } + + static double plus(String s) { + if (s.endsWith("1")) + return 2.0; + if (s.endsWith("2")) + return 1.5; + if (s.endsWith("3")) + return 1.0; + return 0.0; + } + static class ob { + String code, gcode, name, sub, type; + Double sum, pri; + + public ob(int i, String name, String gcode, double x, double y) { + this.code = String.format("GV%02d", i); + this.gcode = gcode; + this.name = name; + this.sub = getSub(gcode); + this.pri = plus(gcode); + this.sum = x * 2 + y + this.pri; + if (this.sum >= 18) + this.type = "TRUNG TUYEN"; + else + this.type = "LOAI"; + } + + @Override + public String toString() { + return code + " " + name + " " + sub +" "+ String.format("%.1f", sum) + " " + type; + } + } + + public static void main(String[] args) { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new ob(i + 1, sc.nextLine(), sc.nextLine(), sc.nextDouble(), sc.nextDouble())); + } + a.sort((ob x, ob y) -> y.sum.compareTo(x.sum)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05015 - ĐUA XE ĐẠP.java b/J05015 - ĐUA XE ĐẠP.java new file mode 100644 index 0000000..1c61f18 --- /dev/null +++ b/J05015 - ĐUA XE ĐẠP.java @@ -0,0 +1,44 @@ +import java.util.*; +import java.text.*; +public class Main { + static class ob { + String code, name, address; + long v; + Double time; + + public ob(String name, String address, String time) { + this.name = name; + this.address = address; + this.code = ""; + for (String i : address.trim().split("\\s+")) + this.code += i.charAt(0); + for (String i : name.trim().split("\\s+")) + this.code += i.charAt(0); + SimpleDateFormat f = new SimpleDateFormat("HH:mm"); + try{ + this.time = (f.parse(time).getTime() - f.parse("6:00").getTime()) / 3600000.0; + this.v = Math.round(120.0 / this.time); + } catch (ParseException e) { + + } + } + + @Override + public String toString() { + return code + " " + name + " " + address + " " + v + " Km/h"; + } + } + + public static void main(String[] args) { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for (int i = 0; i < n; i++) { + a.add(new ob(sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + a.sort((ob x, ob y) -> x.time.compareTo(y.time)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05016 - HÓA ĐƠN KHÁCH SẠN.java b/J05016 - HÓA ĐƠN KHÁCH SẠN.java new file mode 100644 index 0000000..49a8139 --- /dev/null +++ b/J05016 - HÓA ĐƠN KHÁCH SẠN.java @@ -0,0 +1,74 @@ +import java.util.*; +import java.util.zip.DataFormatException; +import java.io.*; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().split("[' ']+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + if (n[i].length() == 0) + continue; + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static int getPrice(int room) { + int x = room / 100; + if (x == 1) + return 25; + if (x == 2) + return 34; + if (x == 3) + return 50; + return 80; + } + + static String fomartDay(String s) { + String[] a = s.split("/"); + return (a[0].length() == 1 ? "0" + a[0] : a[0]) + '/' + (a[1].length() == 1 ? "0" + a[1] : a[1]) + '/' + a[2]; + } + + static class cus { + String code, name; + int room, days, bill; + + public cus(int i, String n, int r, String a, String l, int ex) { + code = String.format("KH%02d", i); + name = stdName(n); + room = r; + SimpleDateFormat d = new SimpleDateFormat("dd/MM/yyyy"); + try { + days = (int) ((d.parse(l).getTime() - d.parse(a).getTime()) / (24 * 60 * 60 * 1000) + 1); + } catch (ParseException e) { + + } + bill = getPrice(room) * days + ex; + } + + @Override + public String toString() { + return code + ' ' + name + room + ' ' + days + ' ' + bill; + } + } + + public static void main(String[] arg) throws IOException { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 1; i <= n; i++) { + sc.nextLine(); + a.add(new cus(i, sc.nextLine(), sc.nextInt(), fomartDay(sc.next()), fomartDay(sc.next()), sc.nextInt())); + } + Collections.sort(a, new Comparator() { + @Override + public int compare(cus a, cus b) { + return b.bill - a.bill; + } + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05017 - HÓA ĐƠN TIỀN NƯỚC.java b/J05017 - HÓA ĐƠN TIỀN NƯỚC.java new file mode 100644 index 0000000..f659b06 --- /dev/null +++ b/J05017 - HÓA ĐƠN TIỀN NƯỚC.java @@ -0,0 +1,45 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static class ob{ + String code, name; + Long total, sum, plus, fin; + + public ob(int i, String name, long pre, long af){ + this.code = String.format("KH%02d", i); + this.name = name; + this.total = af - pre; + this.sum = Math.min(50, this.total)*100; + this.plus = Math.round(this.sum*0.02); + if(this.total>50){ + this.sum += Math.min(50, this.total-50)*150; + this.plus = Math.round(this.sum*0.03); + } + if(this.total>100){ + this.sum += (this.total - 100)*200; + this.plus = Math.round(this.sum*0.05); + } + this.fin = this.sum + this.plus; + } + + @Override + public String toString(){ + return code + " " + name + " " + fin; + } + } + + public static void main(String[] args) throws IOException, ClassNotFoundException { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i y.fin.compareTo(x.fin)); + a.forEach(e -> System.out.println(e)); + } +} + diff --git a/J05018 - BẢNG ĐIỂM HỌC SINH.java b/J05018 - BẢNG ĐIỂM HỌC SINH.java new file mode 100644 index 0000000..1ed61aa --- /dev/null +++ b/J05018 - BẢNG ĐIỂM HỌC SINH.java @@ -0,0 +1,54 @@ +import java.util.*; +public class Main { + + static class o { + String code, name, type; + Double tbc; + + public o(int code, String name, Double x) { + this.code = "HS" + String.format("%02d", code); + this.name = name; + this.tbc = Math.round(x/12*10)/10.0; + if (tbc >= 9) + type = "XUAT SAC"; + else if (tbc >= 8) + type = "GIOI"; + else if (tbc >= 7) + type = "KHA"; + else if (tbc >= 5) + type = "TB"; + else + type = "YEU"; + } + + @Override + public String toString() { + return code + ' ' + name + ' ' + tbc + ' ' + type; + } + } + + public static void main(String[] args) { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 1; i <= n; i++) { + sc.nextLine(); + String name = sc.nextLine(); + double x = 0; + for (int j = 0; j < 10; j++) { + if (j <= 1) + x += sc.nextDouble() * 2; + else + x += sc.nextDouble(); + } + a.add(new o(i, name, x)); + } + a.sort((o x, o y) -> { + if (x.tbc.compareTo(y.tbc) == 0) + return x.code.compareTo(y.code); + return y.tbc.compareTo(x.tbc); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05019 - LƯỢNG MƯA TRUNG BÌNH.java b/J05019 - LƯỢNG MƯA TRUNG BÌNH.java new file mode 100644 index 0000000..f119e0d --- /dev/null +++ b/J05019 - LƯỢNG MƯA TRUNG BÌNH.java @@ -0,0 +1,57 @@ +import java.util.*; +import java.text.*; +public class Main { + + static String cleanName(String s) { + String[] a = s.trim().split("\\s+"); + for (int i = 0; i < a.length; i++) + a[i] = Character.toString(a[i].charAt(0)).toUpperCase() + a[i].substring(1).toLowerCase(); + return String.join(" ", a); + } + + static class ob { + String code, name; + long min, total; + Double hour, rain; + + public ob(int i, String name) { + this.code = String.format("T%02d", i); + this.name = name; + } + + public void getm(String t1, String t2, long total) { + SimpleDateFormat f = new SimpleDateFormat("hh:mm"); + try{ + min += (f.parse(t2).getTime() - f.parse(t1).getTime())/1000/60; + } catch (ParseException e) { + + } + this.total += total; + this.hour = this.min / 60.0; + rain = this.total / this.hour; + } + + @Override + public String toString() { + return code + " " + name + " " + String.format("%.2f", rain); + } + } + + public static void main(String[] arg) { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + HashMap a = new HashMap<>(); + ArrayList arr = new ArrayList<>(); + int n = sc.nextInt(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + String s = sc.nextLine(); + if (a.get(s) == null) { + a.put(s, new ob(a.size() + 1, s)); + arr.add(a.get(s)); + } + a.get(s).getm(sc.next(), sc.next(), sc.nextLong()); + } + arr.forEach(e -> System.out.println(e)); + } +} diff --git a/J05020 - SẮP XẾP SINH VIÊN THEO LỚP.java b/J05020 - SẮP XẾP SINH VIÊN THEO LỚP.java new file mode 100644 index 0000000..ea90f51 --- /dev/null +++ b/J05020 - SẮP XẾP SINH VIÊN THEO LỚP.java @@ -0,0 +1,56 @@ +import java.util.*; +public class Main { + static char up(char x) { + if ('a' <= x && x <= 'z') + return (char) ((int) x - 32); + return x; + } + + static String re(String name) { + String[] a = name.split("[' ']+"); + String r = ""; + for (int i = 0; i < a.length; i++) { + if (a[i].length() == 0) + continue; + String s = Character.toString(up(a[i].charAt(0))) + a[i].substring(1); + r += s + " "; + } + return r; + } + + static class student { + String code, name, method, mail; + + public student(String c, String n, String m, String em) { + code = c; + name = n; + method = m; + mail = em; + } + + public boolean big(student b) { + if (code.compareTo(b.code) > 0) + return true; + return false; + } + + public String toString() { + return code + " " + name + ' ' + method + " " + mail; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for (int i = 0; i < n; i++) { + a.add(new student(sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + a.sort((student x, student y) ->{ + if(x.method.compareTo(y.method) == 0) return x.code.compareTo(y.code); + return x.method.compareTo(y.method); + }); + a.forEach(e->System.out.println(e)); + } +} diff --git a/J05021 - SẮP XẾP THEO MÃ SINH VIÊN.java b/J05021 - SẮP XẾP THEO MÃ SINH VIÊN.java new file mode 100644 index 0000000..0f92b21 --- /dev/null +++ b/J05021 - SẮP XẾP THEO MÃ SINH VIÊN.java @@ -0,0 +1,51 @@ +import java.util.*; +public class Main { + static char up(char x) { + if ('a' <= x && x <= 'z') + return (char) ((int) x - 32); + return x; + } + + static String re(String name) { + String[] a = name.split("[' ']+"); + String r = ""; + for (int i = 0; i < a.length; i++) { + if (a[i].length() == 0) + continue; + String s = Character.toString(up(a[i].charAt(0))) + a[i].substring(1); + r += s + " "; + } + return r; + } + + static class student { + String code, name, method, mail; + + public student(String c, String n, String m, String em) { + code = c; + name = n; + method = m; + mail = em; + } + + public boolean big(student b) { + if (code.compareTo(b.code) > 0) + return true; + return false; + } + + public String toString() { + return code + " " + name + ' ' + method + " " + mail; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + while(sc.hasNextLine()) a.add(new student(sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + a.sort((student x, student y) ->{ + return x.code.compareTo(y.code); + }); + a.forEach(e->System.out.println(e)); + } +} diff --git a/J05022 - LIỆT KÊ SINH VIÊN THEO LỚP.java b/J05022 - LIỆT KÊ SINH VIÊN THEO LỚP.java new file mode 100644 index 0000000..c1ff59a --- /dev/null +++ b/J05022 - LIỆT KÊ SINH VIÊN THEO LỚP.java @@ -0,0 +1,59 @@ +import java.util.*; +public class Main { + static char up(char x) { + if ('a' <= x && x <= 'z') + return (char) ((int) x - 32); + return x; + } + + static String re(String name) { + String[] a = name.split("[' ']+"); + String r = ""; + for (int i = 0; i < a.length; i++) { + if (a[i].length() == 0) + continue; + String s = Character.toString(up(a[i].charAt(0))) + a[i].substring(1); + r += s + " "; + } + return r; + } + + static class student { + String code, name, method, mail; + + public student(String c, String n, String m, String em) { + code = c; + name = n; + method = m; + mail = em; + } + + public boolean big(student b) { + if (code.compareTo(b.code) > 0) + return true; + return false; + } + + public String toString() { + return code + " " + name + ' ' + method + " " + mail; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + sc.nextLine(); + for(int i=0;i0){ + String cl = sc.next(); + System.out.printf("DANH SACH SINH VIEN LOP %s:\n", cl); + a.forEach(e -> { + if(e.method.compareTo(cl) == 0) System.out.println(e); + }); + } + } +} diff --git a/J05023 - LIỆT KÊ SINH VIÊN THEO KHÓA.java b/J05023 - LIỆT KÊ SINH VIÊN THEO KHÓA.java new file mode 100644 index 0000000..ed13de7 --- /dev/null +++ b/J05023 - LIỆT KÊ SINH VIÊN THEO KHÓA.java @@ -0,0 +1,59 @@ +import java.util.*; +public class Main { + static char up(char x) { + if ('a' <= x && x <= 'z') + return (char) ((int) x - 32); + return x; + } + + static String re(String name) { + String[] a = name.split("[' ']+"); + String r = ""; + for (int i = 0; i < a.length; i++) { + if (a[i].length() == 0) + continue; + String s = Character.toString(up(a[i].charAt(0))) + a[i].substring(1); + r += s + " "; + } + return r; + } + + static class student { + String code, name, method, mail; + + public student(String c, String n, String m, String em) { + code = c; + name = n; + method = m; + mail = em; + } + + public boolean big(student b) { + if (code.compareTo(b.code) > 0) + return true; + return false; + } + + public String toString() { + return code + " " + name + ' ' + method + " " + mail; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + sc.nextLine(); + for(int i=0;i0){ + String cl = sc.next(); + System.out.printf("DANH SACH SINH VIEN KHOA %s:\n", cl); + a.forEach(e -> { + if(e.method.substring(1, 3).compareTo(cl.substring(2)) == 0) System.out.println(e); + }); + } + } +} diff --git a/J05024 - LIỆT KÊ SINH VIÊN THEO NGÀNH.java b/J05024 - LIỆT KÊ SINH VIÊN THEO NGÀNH.java new file mode 100644 index 0000000..2f086ba --- /dev/null +++ b/J05024 - LIỆT KÊ SINH VIÊN THEO NGÀNH.java @@ -0,0 +1,71 @@ +import java.util.*; +public class Main { + static char up(char x) { + if ('a' <= x && x <= 'z') + return (char) ((int) x - 32); + return x; + } + + static String re(String name) { + String[] a = name.split("[' ']+"); + String r = ""; + for (int i = 0; i < a.length; i++) { + if (a[i].length() == 0) + continue; + String s = Character.toString(up(a[i].charAt(0))) + a[i].substring(1); + r += s + " "; + } + return r; + } + + static class student { + String code, name, method, mail; + + public student(String c, String n, String m, String em) { + code = c; + name = n; + method = m; + mail = em; + } + + public boolean big(student b) { + if (code.compareTo(b.code) > 0) + return true; + return false; + } + + public String toString() { + return code + " " + name + ' ' + method + " " + mail; + } + } + + public static void main(String[] args) { + HashMap hm = new HashMap<>(); + hm.put("Ke toan", "DCKT"); + hm.put("Cong nghe thong tin", "DCCN"); + hm.put("An toan thong tin", "DCAT"); + hm.put("Vien thong", "DCVT"); + hm.put("Dien tu", "DCDT"); + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + sc.nextLine(); + for(int i=0;i0){ + String nganh = sc.nextLine(); + String s = hm.get(nganh); + System.out.printf("DANH SACH SINH VIEN NGANH %s:\n", nganh.toUpperCase()); + a.forEach(e -> { + if(s.compareTo("DCCN") == 0 || s.compareTo("DCAT") == 0){ + if(e.code.indexOf(s) > -1 && !e.method.startsWith("E")) System.out.println(e); + }else{ + if(e.code.indexOf(s) > -1) System.out.println(e); + } + }); + } + } +} diff --git a/J05025 - SẮP XẾP DANH SÁCH GIẢNG VIÊN.java b/J05025 - SẮP XẾP DANH SÁCH GIẢNG VIÊN.java new file mode 100644 index 0000000..7c97afb --- /dev/null +++ b/J05025 - SẮP XẾP DANH SÁCH GIẢNG VIÊN.java @@ -0,0 +1,38 @@ +import java.util.*; +public class Main { + + static class ob { + String code, name, field, last; + + public ob(int i, String name, String s){ + code = "GV" + String.format("%02d", i); + String[] a = name.split("\\s+"); + last = a[a.length - 1]; + this.name = name; + String[] b = s.split("\\s+"); + field = ""; + for(String x:b){ + field+=Character.toString(x.charAt(0)).toUpperCase(); + } + } + + public String toString() { + return code + ' ' + name + ' ' + field; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i { + if(x.last.compareTo(y.last) == 0) return x.code.compareTo(y.code); + return x.last.compareTo(y.last); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05026 - DANH SÁCH GIẢNG VIÊN THEO BỘ MÔN.java b/J05026 - DANH SÁCH GIẢNG VIÊN THEO BỘ MÔN.java new file mode 100644 index 0000000..d17e296 --- /dev/null +++ b/J05026 - DANH SÁCH GIẢNG VIÊN THEO BỘ MÔN.java @@ -0,0 +1,48 @@ +import java.util.*; +public class Main { + + static String first(String s){ + String[] a = s.split("\\s+"); + String r = ""; + for(String x:a){ + r+=Character.toString(x.charAt(0)).toUpperCase(); + } + return r; + } + + static class ob { + String code, name, field, last; + + public ob(int i, String name, String s){ + code = "GV" + String.format("%02d", i); + String[] a = name.split("\\s+"); + last = a[a.length - 1]; + this.name = name; + String[] b = s.split("\\s+"); + field = first(s); + } + + public String toString() { + return code + ' ' + name + ' ' + field; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i0){ + String s = first(sc.nextLine()); + System.out.printf("DANH SACH GIANG VIEN BO MON %s:\n", s.toUpperCase()); + a.forEach(e -> { + if(e.field.compareTo(s) == 0) System.out.println(e); + }); + } + } +} diff --git a/J05027 - TÌM KIẾM GIẢNG VIÊN.java b/J05027 - TÌM KIẾM GIẢNG VIÊN.java new file mode 100644 index 0000000..6b1332a --- /dev/null +++ b/J05027 - TÌM KIẾM GIẢNG VIÊN.java @@ -0,0 +1,50 @@ +import java.util.*; +public class Main { + + static String first(String s){ + String[] a = s.split("\\s+"); + String r = ""; + for(String x:a){ + r+=Character.toString(x.charAt(0)).toUpperCase(); + } + return r; + } + + static class ob { + String code, name, field, last, lowname; + + public ob(int i, String name, String s){ + code = "GV" + String.format("%02d", i); + String[] a = name.split("\\s+"); + last = a[a.length - 1]; + this.name = name; + lowname = name.toLowerCase(); + String[] b = s.split("\\s+"); + field = first(s); + } + + public String toString() { + return code + ' ' + name + ' ' + field; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i0){ + String s = sc.nextLine(); + String key = s.toLowerCase(); + System.out.printf("DANH SACH GIANG VIEN THEO TU KHOA %s:\n", s); + a.forEach(e -> { + if(e.lowname.contains(key)) System.out.println(e); + }); + } + } +} diff --git a/J05028 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 1.java b/J05028 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 1.java new file mode 100644 index 0000000..8c80267 --- /dev/null +++ b/J05028 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 1.java @@ -0,0 +1,33 @@ +import java.util.*; +public class Main { + + static class ob { + String code, name; + int student; + + public ob(String code, String name, int student){ + this.code = code; + this.name = name; + this.student = student; + } + + public String toString() { + return code + ' ' + name + ' ' + student; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + if(x.student == y.student) return x.code.compareTo(y.code); + return y.student - x.student; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05029 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 2.java b/J05029 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 2.java new file mode 100644 index 0000000..3055b2d --- /dev/null +++ b/J05029 - DANH SÁCH DOANH NGHIỆP NHẬN SINH VIÊN THỰC TẬP - 2.java @@ -0,0 +1,40 @@ +import java.util.*; +public class Main { + + static class ob { + String code, name; + int student; + + public ob(String code, String name, int student){ + this.code = code; + this.name = name; + this.student = student; + } + + public String toString() { + return code + ' ' + name + ' ' + student; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + if(x.student == y.student) return x.code.compareTo(y.code); + return y.student - x.student; + }); + int q = sc.nextInt(); + while(q-->0){ + int A = sc.nextInt(), b = sc.nextInt(); + System.out.printf("DANH SACH DOANH NGHIEP NHAN TU %d DEN %d SINH VIEN:\n", A, b); + a.forEach(e ->{ + if(e.student >= A && e.student <= b) System.out.println(e); + }); + } + } +} diff --git a/J05030 - BẢNG ĐIỂM THÀNH PHẦN - 1.java b/J05030 - BẢNG ĐIỂM THÀNH PHẦN - 1.java new file mode 100644 index 0000000..f6470ba --- /dev/null +++ b/J05030 - BẢNG ĐIỂM THÀNH PHẦN - 1.java @@ -0,0 +1,37 @@ +import java.util.*; +public class Main { + + static class ob { + String code, name, cl; + float a, b, c; + + public ob(String code, String name, String cl, float a, float b, float c){ + this.code = code; + this.name = name; + this.cl = cl; + this.a =a; + this.b=b; + this.c=c; + } + + public String toString() { + return code + ' ' + name + ' ' + cl + String.format(" %.1f %.1f %.1f", a, b, c); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + return x.code.compareTo(y.code); + }); + for(int i=1; i<=n; i++){ + System.out.printf("%d %s\n", i, a.get(i-1)); + } + } +} diff --git a/J05031 - BẢNG ĐIỂM THÀNH PHẦN - 2.java b/J05031 - BẢNG ĐIỂM THÀNH PHẦN - 2.java new file mode 100644 index 0000000..39b197f --- /dev/null +++ b/J05031 - BẢNG ĐIỂM THÀNH PHẦN - 2.java @@ -0,0 +1,37 @@ +import java.util.*; +public class Main { + + static class ob { + String code, name, cl; + float a, b, c; + + public ob(String code, String name, String cl, float a, float b, float c){ + this.code = code; + this.name = name; + this.cl = cl; + this.a =a; + this.b=b; + this.c=c; + } + + public String toString() { + return code + ' ' + name + ' ' + cl + String.format(" %.1f %.1f %.1f", a, b, c); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + return x.name.compareTo(y.name); + }); + for(int i=1; i<=n; i++){ + System.out.printf("%d %s\n", i, a.get(i-1)); + } + } +} diff --git a/J05032 - TRẺ NHẤT – GIÀ NHẤT.java b/J05032 - TRẺ NHẤT – GIÀ NHẤT.java new file mode 100644 index 0000000..660d54e --- /dev/null +++ b/J05032 - TRẺ NHẤT – GIÀ NHẤT.java @@ -0,0 +1,41 @@ +import java.util.*; +import java.text.*; +public class Main { + + static class ob { + String name, d, m, y; + Date date; + + public ob(String name, String date){ + this.name = name; + String[] a = date.split("/"); + d = a[0]; + m = a[1]; + y = a[2]; + } + + public String toString() { + return name; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + if(x.y.compareTo(y.y) == 0){ + if(x.m.compareTo(y.m) == 0){ + return x.d.compareTo(y.d); + } + return x.m.compareTo(y.m); + } + return x.y.compareTo(y.y); + }); + System.out.println(a.get(n-1)); + System.out.println(a.get(0)); + } +} diff --git a/J05033 - SẮP XẾP THỜI GIAN.java b/J05033 - SẮP XẾP THỜI GIAN.java new file mode 100644 index 0000000..785e81a --- /dev/null +++ b/J05033 - SẮP XẾP THỜI GIAN.java @@ -0,0 +1,29 @@ +import java.util.Scanner; + +public class Main{ + static int getSec(int h, int m, int s){ + return h*3600 + m*60 +s; + } + static void out(int x){ + System.out.printf("%d %d %d\n",x/3600,(x%3600)/60,(x%3600)%60); + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for(int i=0;i a[j]){ + tmp = a[i]; + a[i] = a[j]; + a[j] = tmp; + } + } + } + for(int i=0;i a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i { + return x.name.compareTo(y.name); + }); + int q = sc.nextInt(); + while(q-->0){ + String s = sc.next(); + a.forEach(e ->{ + if(e.is(s)) System.out.println(e); + }); + } + } +} diff --git a/J05035 - DANH SÁCH THỰC TẬP - 2.java b/J05035 - DANH SÁCH THỰC TẬP - 2.java new file mode 100644 index 0000000..75be50b --- /dev/null +++ b/J05035 - DANH SÁCH THỰC TẬP - 2.java @@ -0,0 +1,45 @@ +import java.util.*; +import java.text.*; +public class Main { + + static class ob { + String code, name, cl, mail, dn; + int stt; + public ob(int i, String code, String name, String cl,String mail, String dn){ + stt = i; + this.code = code; + this.name = name; + this.cl = cl; + this.mail = mail; + this.dn = dn; + } + + public boolean is(String s){ + return s.compareTo(dn) == 0; + } + + public String toString() { + return stt + " " + code + ' ' + name + ' ' + cl + ' ' + mail + ' ' + dn; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i { + return x.code.compareTo(y.code); + }); + int q = sc.nextInt(); + while(q-->0){ + String s = sc.next(); + a.forEach(e ->{ + if(e.is(s)) System.out.println(e); + }); + } + } +} diff --git a/J05036 - TÍNH GIÁ BÁN - 1.java b/J05036 - TÍNH GIÁ BÁN - 1.java new file mode 100644 index 0000000..9d981d9 --- /dev/null +++ b/J05036 - TÍNH GIÁ BÁN - 1.java @@ -0,0 +1,34 @@ +import java.util.*; +import java.text.*; +public class Main { + + static class ob { + String code, name, unit; + long price, mount, ship, total, sell; + public ob(int i, String name, String unit, long price, long mount){ + code = "MH" + String.format("%02d", i); + this.name = name; + this.unit = unit; + this.price = price; + this.mount = mount; + ship = Math.round((double) price*mount*0.05); + total = price*mount + ship; + sell = total + Math.round((double)total*0.02); + } + + public String toString() { + return code+' '+name+' '+unit+" "+ship+" "+total+" "+sell; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;iSystem.out.println(e)); + } +} diff --git a/J05037 - TÍNH GIÁ BÁN - 2.java b/J05037 - TÍNH GIÁ BÁN - 2.java new file mode 100644 index 0000000..de3ae20 --- /dev/null +++ b/J05037 - TÍNH GIÁ BÁN - 2.java @@ -0,0 +1,38 @@ +import java.util.*; +import java.text.*; +public class Main { + + static class ob { + String code, name, unit; + Long price, mount, ship, total, sell; + public ob(int i, String name, String unit, long price, long mount){ + code = "MH" + String.format("%02d", i); + this.name = name; + this.unit = unit; + this.price = price; + this.mount = mount; + ship = Math.round((double) price*mount*0.05); + total = price*mount + ship; + sell = Math.round((double)total*1.02/mount); + if(sell%100!=0) sell = sell - sell%100 + 100; + } + + public String toString() { + return code+' '+name+' '+unit+" "+ship+" "+total+" "+sell; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + return y.sell.compareTo(x.sell); + }); + a.forEach(e->System.out.println(e)); + } +} diff --git a/J05038 - BẢNG KÊ TIỀN LƯƠNG.java b/J05038 - BẢNG KÊ TIỀN LƯƠNG.java new file mode 100644 index 0000000..1933c51 --- /dev/null +++ b/J05038 - BẢNG KÊ TIỀN LƯƠNG.java @@ -0,0 +1,47 @@ +import java.util.*; +import java.text.*; +public class Main { + + static int sup(String s){ + if(s.compareTo("GD") == 0) return 250000; + else if(s.compareTo("PGD") == 0) return 200000; + else if(s.compareTo("TP") == 0) return 180000; + return 150000; + } + + static class ob { + String code, name, cv; + int sal, days, plus, sup, sum; + public ob(int i, String name, int sal, int days, String cv){ + code = "NV" + String.format("%02d", i); + this.name = name; + this.days = days; + this.sal = sal*days; + this.sup = sup(cv); + if(days>=25) plus = this.sal/5; + else if(days>=22) plus = this.sal/10; + else plus = 0; + sum = this.sal + this.sup + this.plus; + } + + public String toString() { + return code+' '+name+" "+sal+" "+plus+" "+sup+" "+sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i=25) plus = this.sal/5; + else if(days>=22) plus = this.sal/10; + else plus = 0; + sum = this.sal + this.sup + this.plus; + } + + public String toString() { + return code+' '+name+" "+sal+" "+plus+" "+sup+" "+sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05041 - SẮP XẾP BẢNG TÍNH CÔNG.java b/J05041 - SẮP XẾP BẢNG TÍNH CÔNG.java new file mode 100644 index 0000000..2297367 --- /dev/null +++ b/J05041 - SẮP XẾP BẢNG TÍNH CÔNG.java @@ -0,0 +1,43 @@ +import java.util.*; +import java.text.*; +public class Main { + + static int sup(String s){ + if(s.compareTo("GD") == 0) return 250000; + else if(s.compareTo("PGD") == 0) return 200000; + else if(s.compareTo("TP") == 0) return 180000; + return 150000; + } + + static class ob { + String code, name, cv; + int sal, days, plus, sup, sum; + public ob(int i, String name, int sal, int days, String cv){ + code = "NV" + String.format("%02d", i); + this.name = name; + this.days = days; + this.sal = sal*days; + this.sup = sup(cv); + if(days>=25) plus = this.sal/5; + else if(days>=22) plus = this.sal/10; + else plus = 0; + sum = this.sal + this.sup + this.plus; + } + + public String toString() { + return code+' '+name+" "+sal+" "+plus+" "+sup+" "+sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i y.sum - x.sum); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05042 - BẢNG XẾP HẠNG.java b/J05042 - BẢNG XẾP HẠNG.java new file mode 100644 index 0000000..06d52e2 --- /dev/null +++ b/J05042 - BẢNG XẾP HẠNG.java @@ -0,0 +1,34 @@ +import java.util.*; +public class Main { + static class ob { + String name; + int ac, sub; + public ob(String name, int ac, int sub){ + this.name = name; + this.ac = ac; + this.sub = sub; + } + + public String toString() { + return name + " " + ac + " " + sub; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i{ + if(x.ac == y.ac){ + if(x.sub == y.sub) return x.name.compareTo(y.name); + return x.sub - y.sub; + } + return y.ac - x.ac; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05043 - TÍNH THU NHẬP CHO NHÂN VIÊN.java b/J05043 - TÍNH THU NHẬP CHO NHÂN VIÊN.java new file mode 100644 index 0000000..0846443 --- /dev/null +++ b/J05043 - TÍNH THU NHẬP CHO NHÂN VIÊN.java @@ -0,0 +1,46 @@ +import java.util.*; + +public class Main { + static long sub(String s){ + if(s.compareTo("GD") == 0) return 500; + if(s.compareTo("PGD") == 0) return 400; + if(s.compareTo("TP") == 0) return 300; + if(s.compareTo("KT") == 0) return 250; + return 100; + } + + static long tu(long total){ + double x = (double) total; + if(x*2/3<25000) return Math.round(x*2/3/1000)*1000; + return 25000; + } + + static class ob { + String code, name; + long sub, total, tu, remain; + + public ob(int i, String name, String cv, long sday, long days){ + code = "NV" + String.format("%02d", i); + this.name = name; + this.sub = sub(cv); + this.total = sday*days; + this.tu = tu(this.total); + this.remain = this.total + this.sub - this.tu; + } + + public String toString() { + return code + " " + name + " " + sub + " " + total + " " + tu + " " + remain; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05044 - LIỆT KÊ NHÂN VIÊN THEO CHỨC VỤ.java b/J05044 - LIỆT KÊ NHÂN VIÊN THEO CHỨC VỤ.java new file mode 100644 index 0000000..db25745 --- /dev/null +++ b/J05044 - LIỆT KÊ NHÂN VIÊN THEO CHỨC VỤ.java @@ -0,0 +1,51 @@ +import java.util.*; + +public class Main { + static long sub(String s){ + if(s.compareTo("GD") == 0) return 500; + if(s.compareTo("PGD") == 0) return 400; + if(s.compareTo("TP") == 0) return 300; + if(s.compareTo("KT") == 0) return 250; + return 100; + } + + static long tu(long total){ + double x = (double) total; + if(x*2/3<25000) return Math.round(x*2/3/1000)*1000; + return 25000; + } + + static class ob { + String code, name, cv; + long sub, total, tu, remain; + + public ob(int i, String name, String cv, long sday, long days){ + code = "NV" + String.format("%02d", i); + this.name = name; + this.cv = cv; + this.sub = sub(cv); + this.total = sday*days; + this.tu = tu(this.total); + this.remain = this.total + this.sub - this.tu; + } + + public String toString() { + return code + " " + name + " " + sub + " " + total + " " + tu + " " + remain; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + if(e.cv.compareTo(cv) == 0) System.out.println(e); + }); + } +} diff --git a/J05045 - SẮP XẾP NHÂN VIÊN THEO THU NHẬP.java b/J05045 - SẮP XẾP NHÂN VIÊN THEO THU NHẬP.java new file mode 100644 index 0000000..b7864d0 --- /dev/null +++ b/J05045 - SẮP XẾP NHÂN VIÊN THEO THU NHẬP.java @@ -0,0 +1,52 @@ +import java.util.*; + +public class Main { + static long sub(String s){ + if(s.compareTo("GD") == 0) return 500; + if(s.compareTo("PGD") == 0) return 400; + if(s.compareTo("TP") == 0) return 300; + if(s.compareTo("KT") == 0) return 250; + return 100; + } + + static long tu(long total){ + double x = (double) total; + if(x*2/3<25000) return Math.round(x*2/3/1000)*1000; + return 25000; + } + + static class ob { + String code, name, cv; + long sub, total, tu, remain, sal; + + public ob(int i, String name, String cv, long sday, long days){ + code = "NV" + String.format("%02d", i); + this.name = name; + this.cv = cv; + this.sub = sub(cv); + this.total = sday*days; + this.tu = tu(this.total); + this.remain = this.total + this.sub - this.tu; + this.sal = this.total+this.sub; + } + + public String toString() { + return code + " " + name + " " + sub + " " + total + " " + tu + " " + remain; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + if(x.sal == y.sal) return x.code.compareTo(y.code); + return y.sal>x.sal?1:-1; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05046 - BẢNG KÊ NHẬP KHO.java b/J05046 - BẢNG KÊ NHẬP KHO.java new file mode 100644 index 0000000..fa774cd --- /dev/null +++ b/J05046 - BẢNG KÊ NHẬP KHO.java @@ -0,0 +1,46 @@ +import java.util.*; + +public class Main { + static long ck(long total, long sl){ + if(sl>10) return total/20; + if(sl>=8) return total/50; + if(sl>=5) return total/100; + return 0; + } + static String getCode(String name){ + String[] a = name.split("\\s+"); + return Character.toString(a[0].charAt(0)).toUpperCase() + Character.toString(a[1].charAt(0)).toUpperCase(); + } + + static class ob { + String code, name; + long ck, sum, total; + public ob(String code, String name, long sl, long price){ + this.code = code; + this.name = name; + this.total = price*sl; + this.ck = ck(this.total, sl); + this.sum = this.total - this.ck; + } + + public String toString() { + return code + " " + name + " " + ck + " " + sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + HashMap hm = new HashMap<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05047 - BẢNG KÊ NHẬP KHO SẮP XẾP THEO CHIẾT KHẤU.java b/J05047 - BẢNG KÊ NHẬP KHO SẮP XẾP THEO CHIẾT KHẤU.java new file mode 100644 index 0000000..71963ac --- /dev/null +++ b/J05047 - BẢNG KÊ NHẬP KHO SẮP XẾP THEO CHIẾT KHẤU.java @@ -0,0 +1,47 @@ +import java.util.*; + +public class Main { + static long ck(long total, long sl){ + if(sl>10) return total/20; + if(sl>=8) return total/50; + if(sl>=5) return total/100; + return 0; + } + static String getCode(String name){ + String[] a = name.split("\\s+"); + return Character.toString(a[0].charAt(0)).toUpperCase() + Character.toString(a[1].charAt(0)).toUpperCase(); + } + + static class ob { + String code, name; + Long ck, sum, total; + public ob(String code, String name, long sl, long price){ + this.code = code; + this.name = name; + this.total = price*sl; + this.ck = ck(this.total, sl); + this.sum = this.total - this.ck; + } + + public String toString() { + return code + " " + name + " " + ck + " " + sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + HashMap hm = new HashMap<>(); + for(int i=0;i y.ck.compareTo(x.ck)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05048 - BẢNG THEO DÕI NHẬP XUẤT HÀNG.java b/J05048 - BẢNG THEO DÕI NHẬP XUẤT HÀNG.java new file mode 100644 index 0000000..73c1d21 --- /dev/null +++ b/J05048 - BẢNG THEO DÕI NHẬP XUẤT HÀNG.java @@ -0,0 +1,46 @@ +import java.util.*; + +public class Main { + static long xuat(String code, long nhap){ + if(code.charAt(0) == 'A') return Math.round(nhap*0.6); + else return Math.round(nhap*0.7); + } + static long price(String code){ + return code.charAt(4)=='Y'?110000:135000; + } + static long tax(String code, long total){ + if(code.charAt(0)=='A'){ + if(code.charAt(4)=='Y') return total*8/100; + return total*11/100; + } + if(code.charAt(4)=='Y') return total*17/100; + return total*22/100; + } + + static class ob { + String code; + Long nhap, xuat, price, sum, tax; + public ob(String code, long sl){ + this.code = code; + this.nhap = sl; + this.xuat = xuat(code, sl); + this.price = price(code); + this.sum = this.xuat * this.price; + this.tax = tax(code, this.sum); + } + + public String toString() { + return code + " " + nhap + " " + xuat + " " + price + " " + sum + " " + tax; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05049 - LIỆT KÊ NHẬP XUẤT HÀNG THEO NHÓM.java b/J05049 - LIỆT KÊ NHẬP XUẤT HÀNG THEO NHÓM.java new file mode 100644 index 0000000..807cbe1 --- /dev/null +++ b/J05049 - LIỆT KÊ NHẬP XUẤT HÀNG THEO NHÓM.java @@ -0,0 +1,50 @@ +import java.util.*; + +public class Main { + static long xuat(String code, long nhap){ + if(code.charAt(0) == 'A') return Math.round(nhap*0.6); + else return Math.round(nhap*0.7); + } + static long price(String code){ + return code.charAt(4)=='Y'?110000:135000; + } + static long tax(String code, long total){ + if(code.charAt(0)=='A'){ + if(code.charAt(4)=='Y') return total*8/100; + return total*11/100; + } + if(code.charAt(4)=='Y') return total*17/100; + return total*22/100; + } + + static class ob { + String code; + Long nhap, xuat, price, sum, tax; + public ob(String code, long sl){ + this.code = code; + this.nhap = sl; + this.xuat = xuat(code, sl); + this.price = price(code); + this.sum = this.xuat * this.price; + this.tax = tax(code, this.sum); + } + + public String toString() { + return code + " " + nhap + " " + xuat + " " + price + " " + sum + " " + tax; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i y.tax.compareTo(x.tax)); + String x = sc.next(); + a.forEach(e ->{ + if(e.code.startsWith(x)) System.out.println(e); + }); + } +} diff --git a/J05050 - TÍNH TIỀN ĐIỆN.java b/J05050 - TÍNH TIỀN ĐIỆN.java new file mode 100644 index 0000000..8618351 --- /dev/null +++ b/J05050 - TÍNH TIỀN ĐIỆN.java @@ -0,0 +1,43 @@ +import java.util.*; + +public class Main { + static long x(String s){ + if(s.compareTo("KD") == 0) return 3; + if(s.compareTo("NN") == 0) return 5; + if(s.compareTo("TT") == 0) return 4; + return 2; + } + + static long plus(long total, long dis){ + if(dis<50) return 0; + if(dis<=100) return Math.round(total/100.0*35); + return total; + } + + static class ob { + String code; + Long x, total, plus, sum, dis; + public ob(int i, String type, long pre, long af){ + this.code = "KH" + String.format("%02d", i); + this.x = x(type); + this.dis = af - pre; + this.total = this.dis * this.x * 550; + this.plus = plus(this.total, this.dis); + this.sum = this.total + this.plus; + } + + public String toString() { + return code + " " + this.x + " " + this.total + " " + this.plus + " " + this.sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05051 - SẮP XẾP BẢNG TÍNH TIỀN ĐIỆN.java b/J05051 - SẮP XẾP BẢNG TÍNH TIỀN ĐIỆN.java new file mode 100644 index 0000000..80bf936 --- /dev/null +++ b/J05051 - SẮP XẾP BẢNG TÍNH TIỀN ĐIỆN.java @@ -0,0 +1,44 @@ +import java.util.*; + +public class Main { + static long x(String s){ + if(s.compareTo("KD") == 0) return 3; + if(s.compareTo("NN") == 0) return 5; + if(s.compareTo("TT") == 0) return 4; + return 2; + } + + static long plus(long total, long dis){ + if(dis<50) return 0; + if(dis<=100) return Math.round(total/100.0*35); + return total; + } + + static class ob { + String code; + Long x, total, plus, sum, dis; + public ob(int i, String type, long pre, long af){ + this.code = "KH" + String.format("%02d", i); + this.x = x(type); + this.dis = af - pre; + this.total = this.dis * this.x * 550; + this.plus = plus(this.total, this.dis); + this.sum = this.total + this.plus; + } + + public String toString() { + return code + " " + this.x + " " + this.total + " " + this.plus + " " + this.sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i y.sum.compareTo(x.sum)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05052 - TRA CỨU ĐƠN HÀNG.java b/J05052 - TRA CỨU ĐƠN HÀNG.java new file mode 100644 index 0000000..7cbffef --- /dev/null +++ b/J05052 - TRA CỨU ĐƠN HÀNG.java @@ -0,0 +1,37 @@ +import java.util.*; + +public class Main { + static long off(String s, long total){ + if (s.charAt(s.length()-1) == '1') return total/2; + return total*3/10; + } + + static class ob { + String code, name, stt; + long total, sum, off; + + public ob(String name, String code, long price, long sl){ + this.name = name; + this.code = code; + this.stt = code.substring(1,4); + this.total = price*sl; + this.off = off(code, this.total); + this.sum = this.total - this.off; + } + + public String toString() { + return name + " " + this.code + " " + this.stt + " " + this.off + " " + this.sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05053 - SẮP XẾP ĐƠN HÀNG.java b/J05053 - SẮP XẾP ĐƠN HÀNG.java new file mode 100644 index 0000000..88da4e2 --- /dev/null +++ b/J05053 - SẮP XẾP ĐƠN HÀNG.java @@ -0,0 +1,38 @@ +import java.util.*; + +public class Main { + static long off(String s, long total){ + if (s.charAt(s.length()-1) == '1') return total/2; + return total*3/10; + } + + static class ob { + String code, name, stt; + long total, sum, off; + + public ob(String name, String code, long price, long sl){ + this.name = name; + this.code = code; + this.stt = code.substring(1,4); + this.total = price*sl; + this.off = off(code, this.total); + this.sum = this.total - this.off; + } + + public String toString() { + return name + " " + this.code + " " + this.stt + " " + this.off + " " + this.sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i x.stt.compareTo(y.stt)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05054 - XẾP HẠNG HỌC SINH.java b/J05054 - XẾP HẠNG HỌC SINH.java new file mode 100644 index 0000000..c544206 --- /dev/null +++ b/J05054 - XẾP HẠNG HỌC SINH.java @@ -0,0 +1,51 @@ +import java.util.*; + +public class Main { + static long off(String s, long total){ + if (s.charAt(s.length()-1) == '1') return total/2; + return total*3/10; + } + + static class ob { + String code, name, type; + Float sum; + int rank; + + public ob(int i, String name, float sum){ + this.code = "HS" + String.format("%02d", i); + this.name = name; + this.sum = sum; + if(sum >= 9) type = "Gioi"; + else if(sum>=7) type = "Kha"; + else if(sum>=5) type = "Trung Binh"; + else type = "Yeu"; + } + + public String toString() { + return code + " " + name + " " + String.format("%.1f", sum) + " " + type + " " + String.format("%d", rank); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + ArrayList b = new ArrayList<>(); + for(int i=0;i y.sum.compareTo(x.sum)); + a.forEach(e -> { + for(int i=0;i a = new ArrayList<>(); + ArrayList b = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i x.fin.compareTo(y.fin)); + a.forEach(e -> { + for(int i=0;i a = new ArrayList<>(); + ArrayList b = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i x.fin.compareTo(y.fin)); + a.sort((ob x, ob y) -> x.fin.compareTo(y.fin)); + a.forEach(e -> { + for(int i=0;i= 24) this.result = "TRUNG TUYEN"; + else this.result = "TRUOT"; + } + + public String toString() { + return code + " " + name + " " + fF(pri) + " " + fF(sum) + " " +this.result; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05058 - SẮP XẾP KẾT QUẢ TUYỂN SINH.java b/J05058 - SẮP XẾP KẾT QUẢ TUYỂN SINH.java new file mode 100644 index 0000000..16d6a39 --- /dev/null +++ b/J05058 - SẮP XẾP KẾT QUẢ TUYỂN SINH.java @@ -0,0 +1,46 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static String fF(double x){ + if((int) x == x) return String.format("%.0f", x); + return String.format("%.1f", x); + } + + static class ob { + String code, name, result; + Double sum, fin, pri; + + public ob(String code, String name, double a, double b, double c){ + this.code = code; + this.name = name; + if(code.startsWith("KV1")) this.pri = 0.5; + else if(code.startsWith("KV2")) this.pri = 1.0; + else if(code.startsWith("KV3")) this.pri = 2.5; + this.sum = a*2 + b + c; + this.fin = this.sum + this.pri; + if(this.fin >= 24) this.result = "TRUNG TUYEN"; + else this.result = "TRUOT"; + } + + public String toString() { + return code + " " + name + " " + fF(pri) + " " + fF(fin) + " " +this.result; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i{ + if(x.fin.compareTo(y.fin) == 0) return x.code.compareTo(y.code); + return y.fin.compareTo(x.fin); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05059 - XÁC ĐỊNH DANH SÁCH TRÚNG TUYỂN.java b/J05059 - XÁC ĐỊNH DANH SÁCH TRÚNG TUYỂN.java new file mode 100644 index 0000000..1d2a62c --- /dev/null +++ b/J05059 - XÁC ĐỊNH DANH SÁCH TRÚNG TUYỂN.java @@ -0,0 +1,67 @@ +import java.util.*; +public class Main { + static double diemChuan ; + private static class ThiSinh implements Comparable{ + private String id,name; + private double scoreT,scoreL,scoreH,priorityScore,totalScore; + private String tt; + + ThiSinh(String id, String name, double scoreT, double scoreL, double scoreH) { + this.id = id; + this.name = chuanHoaTen(name); + this.scoreT = scoreT; + this.scoreL = scoreL; + this.scoreH = scoreH; + this.priorityScore = 0; + if(id.startsWith("KV1")) this.priorityScore = 0.5; + if(id.startsWith("KV2")) this.priorityScore = 1.0; + if(id.startsWith("KV3")) this.priorityScore = 2.5; + this.totalScore = scoreT*2+scoreL+scoreH+ this.priorityScore; + + } + static String chuanHoaTen(String s){ + s = s.trim().toLowerCase(); + String res = "" + Character.toUpperCase(s.charAt(0)); + for(int i=1; i< s.length();i++){ + if(Character.isLetter(s.charAt(i))){ + if(s.charAt(i-1) == ' ') res+= " "+ Character.toUpperCase(s.charAt(i)); + else res += s.charAt(i); + } + } + return res; + } + + @Override + public int compareTo(ThiSinh o) { + if(this.totalScoreo.totalScore) return -1; + return this.id.compareTo(o.id); + } + + void inThongTin(){ + System.out.print(this.id+' '+this.name+' '); + if((int)this.priorityScore == this.priorityScore ) System.out.printf("%.0f ",this.priorityScore); + else System.out.printf("%.1f ",this.priorityScore); + if((int)this.totalScore == this.totalScore ) System.out.printf("%.0f ",this.totalScore); + else System.out.printf("%.1f ",this.totalScore); + if(this.totalScore>=diemChuan) this.tt = "TRUNG TUYEN"; + else this.tt = "TRUOT"; + System.out.println(this.tt); + } + } + public static void main(String []args){ + Scanner sc = new Scanner(System.in); + ArrayList ds = new ArrayList<>(); + int t = sc.nextInt(); + while(t-->0){ + sc.nextLine(); + ds.add(new ThiSinh(sc.nextLine(),sc.nextLine(),sc.nextDouble(),sc.nextDouble(),sc.nextDouble())); + } + int k = sc.nextInt(); + Collections.sort(ds); + diemChuan = ds.get(k-1).totalScore; + System.out.printf("%.1f\n",diemChuan); + for(ThiSinh tmp : ds) + tmp.inThongTin(); + } +} diff --git a/J05060 - KẾT QUẢ XÉT TUYỂN.java b/J05060 - KẾT QUẢ XÉT TUYỂN.java new file mode 100644 index 0000000..a95274d --- /dev/null +++ b/J05060 - KẾT QUẢ XÉT TUYỂN.java @@ -0,0 +1,46 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static Double plus(Double a, Double b){ + if(a>=8 && b>=8) return 1.0; + if(a>=7.2 && b>=7.2) return 0.5; + return 0.0; + } + + static class ob { + String code, name, result; + Double sum, plus; + Long fin, age; + + public ob(int i, String name, String date, double a, double b){ + this.code = "PH" + String.format("%02d", i); + this.name = name; + this.age = 2021 - Long.parseLong(date.split("/")[2]); + this.plus = plus(a, b); + this.sum = (a + b)/2 + this.plus; + this.fin = Math.min(Math.round(this.sum), 10); + if(this.fin < 5) this.result = "Truot"; + else if(this.fin<7) this.result = "Trung binh"; + else if(this.fin == 7) this.result = "Kha"; + else if(this.fin == 8) this.result = "Gioi"; + else this.result = "Xuat sac"; + } + + public String toString() { + return code + " " + name + " " + age + " " + fin + " " + result; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05061 - SẮP XẾP KẾT QUẢ XÉT TUYỂN.java b/J05061 - SẮP XẾP KẾT QUẢ XÉT TUYỂN.java new file mode 100644 index 0000000..d0347bf --- /dev/null +++ b/J05061 - SẮP XẾP KẾT QUẢ XÉT TUYỂN.java @@ -0,0 +1,50 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static Double plus(Double a, Double b){ + if(a>=8 && b>=8) return 1.0; + if(a>=7.2 && b>=7.2) return 0.5; + return 0.0; + } + + static class ob { + String code, name, result; + Double sum, plus; + Long fin, age; + + public ob(int i, String name, String date, double a, double b){ + this.code = "PH" + String.format("%02d", i); + this.name = name; + this.age = 2021 - Long.parseLong(date.split("/")[2]); + this.plus = plus(a, b); + this.sum = (a + b)/2 + this.plus; + this.fin = Math.min(Math.round(this.sum), 10); + if(this.fin < 5) this.result = "Truot"; + else if(this.fin<7) this.result = "Trung binh"; + else if(this.fin == 7) this.result = "Kha"; + else if(this.fin == 8) this.result = "Gioi"; + else this.result = "Xuat sac"; + } + + public String toString() { + return code + " " + name + " " + age + " " + fin + " " + result; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i { + if(x.fin.compareTo(y.fin) == 0) return x.code.compareTo(y.code); + return y.fin.compareTo(x.fin); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05062 - HỌC BỔNG SINH VIÊN.java b/J05062 - HỌC BỔNG SINH VIÊN.java new file mode 100644 index 0000000..0a63373 --- /dev/null +++ b/J05062 - HỌC BỔNG SINH VIÊN.java @@ -0,0 +1,68 @@ +import java.util.*; + +public class Main { + + static String cleanName(String s) { + String[] a = s.trim().split("\\s+"); + for (int i = 0; i < a.length; i++) + a[i] = Character.toString(a[i].charAt(0)).toUpperCase() + a[i].substring(1).toLowerCase(); + return String.join(" ", a); + } + + static class ob { + String name, type; + int i, rl; + Double gpa; + public ob(int i, String name, double gpa, int rl) { + this.i = i; + this.name = cleanName(name); + this.gpa = gpa; + this.rl = rl; + if (gpa >= 3.6 && rl >= 90) + type = "XUATSAC"; + else if (gpa > 3.2 && rl >= 80) + type = "GIOI"; + else if (gpa > 2.5 && rl >= 70) + type = "KHA"; + else + type = "KHONG"; + } + + @Override + public String toString() { + return name + ": " + type; + } + } + + public static void main(String[] arg) { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), m = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new ob(i, sc.nextLine(), sc.nextDouble(), sc.nextInt())); + } + a.sort((ob x, ob y) -> { + if (y.gpa == x.gpa) + return y.rl - x.rl; + return y.gpa.compareTo(x.gpa); + }); + int i = m; + while (i < n) { + if (a.get(i).gpa.compareTo(a.get(i - 1).gpa) == 0) + i++; + else + break; + } + while (i < n) { + a.get(i).type = "KHONG"; + i++; + } + for (i = 0; i < n; i++) { + for (ob x : a) { + if(x.i == i) System.out.println(x); + } + } + } +} diff --git a/J05063 - TỔNG ĐA THỨC.java b/J05063 - TỔNG ĐA THỨC.java new file mode 100644 index 0000000..cd647ad --- /dev/null +++ b/J05063 - TỔNG ĐA THỨC.java @@ -0,0 +1,85 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static class HangTu{ + int base, exp; + public HangTu(int x, int y){ + base = x; + exp = y; + } + public HangTu(String s){ + String[] a = s.replace("*x^", " ").split("\\s+"); + base = Integer.parseInt(a[0]); + exp = Integer.parseInt(a[1]); + } + @Override + public String toString(){ + return String.format("%d*x^%d", base, exp); + } + } + + static class DaThuc{ + ArrayList a; + + public DaThuc(String s){ + a = new ArrayList<>(); + String[] arr = s.replace("+", " ").split("\\s+"); + for(int i=0;i(); + } + + public DaThuc cong(DaThuc b){ + DaThuc r = new DaThuc(); + int i = 0, u = 0; + while(i b.a.get(u).exp){ + r.a.add(new HangTu(a.get(i).toString())); + i++; + }else{ + HangTu x = new HangTu(a.get(i).base + b.a.get(u).base, a.get(i).exp); + if(x.base != 0) r.a.add(x); + i++; + u++; + } + } + return r; + } + + @Override + public String toString(){ + String[] arr = new String[a.size()]; + for(int i=0;i0){ + DaThuc p = new DaThuc(sc.nextLine()); + DaThuc q = new DaThuc(sc.nextLine()); + DaThuc r = p.cong(q); + System.out.println(r); + } + } + public static void main902701(String[] args) { + Scanner sc = new Scanner(System.in); + int t = Integer.parseInt(sc.nextLine()); + while(t-->0){ + DaThuc p = new DaThuc(sc.nextLine()); + DaThuc q = new DaThuc(sc.nextLine()); + DaThuc r = p.cong(q); + System.out.println(r); + } + } +} diff --git a/J05064 - BẢNG THU NHẬP GIÁO VIÊN.java b/J05064 - BẢNG THU NHẬP GIÁO VIÊN.java new file mode 100644 index 0000000..b1c32ef --- /dev/null +++ b/J05064 - BẢNG THU NHẬP GIÁO VIÊN.java @@ -0,0 +1,55 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static Long x(String s){ + return Long.parseLong(s.substring(2)); + } + + static int count(ArrayList a, ob x){ + String s = x.code.substring(0,2); + int cnt = 0; + for(int i=0; i a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05065 - LIỆT KÊ NHÂN VIÊN THEO NHÓM.java b/J05065 - LIỆT KÊ NHÂN VIÊN THEO NHÓM.java new file mode 100644 index 0000000..1dca155 --- /dev/null +++ b/J05065 - LIỆT KÊ NHÂN VIÊN THEO NHÓM.java @@ -0,0 +1,65 @@ +import java.util.*; + +public class Main { + static long off(String s, long total){ + if (s.charAt(s.length()-1) == '1') return total/2; + return total*3/10; + } + + static class ob { + String cv, x, code, name; + Long hs; + + public ob(String code, String name){ + cv = code.substring(0,2); + x = code.substring(2,4); + this.code = code.substring(4); + this.name = name; + hs = Long.parseLong(x); + } + + public String toString() { + return name + " " + cv + " " + code + " " + x; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + int gd=0, tp=0, pp=0; + for(int i=0;i { + if(x.hs == y.hs) return x.code.compareTo(y.code); + return y.hs.compareTo(x.hs); + }); + int q = sc.nextInt(); + while(q-->0){ + String code = sc.next(); + a.forEach(e -> { + if(e.cv.compareTo(code) == 0) System.out.println(e); + }); + System.out.println(); + } + } +} diff --git a/J05066 - TÌM KIẾM NHÂN VIÊN THEO TÊN.java b/J05066 - TÌM KIẾM NHÂN VIÊN THEO TÊN.java new file mode 100644 index 0000000..f115d75 --- /dev/null +++ b/J05066 - TÌM KIẾM NHÂN VIÊN THEO TÊN.java @@ -0,0 +1,65 @@ +import java.util.*; + +public class Main { + static long off(String s, long total){ + if (s.charAt(s.length()-1) == '1') return total/2; + return total*3/10; + } + + static class ob { + String cv, x, code, name; + Long hs; + + public ob(String code, String name){ + cv = code.substring(0,2); + x = code.substring(2,4); + this.code = code.substring(4); + int stt = Integer.parseInt(this.code); + if(cv.compareTo("GD") == 0 && stt > 1) cv = "NV"; + else if(cv.compareTo("TP") == 0 || cv.compareTo("PP") == 0){ + if(stt > 3) cv = "NV"; + } + this.name = name; + hs = Long.parseLong(x); + } + + public String toString() { + return name + " " + cv + " " + code + " " + x; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + int gd=0, tp=0, pp=0; + for(int i=0;i { + if(x.hs == y.hs) return x.code.compareTo(y.code); + return y.hs.compareTo(x.hs); + }); + int q = sc.nextInt(); + sc.nextLine(); + while(q-->0){ + String code = sc.nextLine().toLowerCase(); + a.forEach(e -> { + if(e.name.toLowerCase().contains(code)) System.out.println(e); + }); + System.out.println(); + } + } +} diff --git a/J05067 - QUẢN LÝ KHO XĂNG DẦU.java b/J05067 - QUẢN LÝ KHO XĂNG DẦU.java new file mode 100644 index 0000000..432e394 --- /dev/null +++ b/J05067 - QUẢN LÝ KHO XĂNG DẦU.java @@ -0,0 +1,55 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static String getName(String s){ + if(s.endsWith("BP")) return "British Petro"; + if(s.endsWith("ES")) return "Esso"; + if(s.endsWith("SH")) return "Shell"; + if(s.endsWith("CA")) return "Castrol"; + if(s.endsWith("MO")) return "Mobil"; + return "Trong Nuoc"; + } + + static long tax(long x, String code){ + if(code.endsWith("TN")) return 0; + if(code.startsWith("X")) return x*3/100; + if(code.startsWith("D")) return x*7/200; + return x/50; + } + + static long price(String code){ + if(code.startsWith("X")) return 128000; + if(code.startsWith("D")) return 11200; + return 9700; + } + + static class ob { + String code, name; + Long price, tax, sum, fin; + + public ob(String code, long sl){ + this.code = code; + this.name = getName(code); + this.price = price(code); + this.sum = this.price * sl; + this.tax = tax(this.sum, code); + this.fin = this.sum + this.tax; + } + + public String toString() { + return code + " " + name + " " + price + " " + tax + " " + fin; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05068 - SẮP XẾP BẢNG GIÁ XĂNG DẦU.java b/J05068 - SẮP XẾP BẢNG GIÁ XĂNG DẦU.java new file mode 100644 index 0000000..51eba6f --- /dev/null +++ b/J05068 - SẮP XẾP BẢNG GIÁ XĂNG DẦU.java @@ -0,0 +1,56 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static String getName(String s){ + if(s.endsWith("BP")) return "British Petro"; + if(s.endsWith("ES")) return "Esso"; + if(s.endsWith("SH")) return "Shell"; + if(s.endsWith("CA")) return "Castrol"; + if(s.endsWith("MO")) return "Mobil"; + return "Trong Nuoc"; + } + + static long tax(long x, String code){ + if(code.endsWith("TN")) return 0; + if(code.startsWith("X")) return x*3/100; + if(code.startsWith("D")) return x*7/200; + return x/50; + } + + static long price(String code){ + if(code.startsWith("X")) return 128000; + if(code.startsWith("D")) return 11200; + return 9700; + } + + static class ob { + String code, name; + Long price, tax, sum, fin; + + public ob(String code, long sl){ + this.code = code; + this.name = getName(code); + this.price = price(code); + this.sum = this.price * sl; + this.tax = tax(this.sum, code); + this.fin = this.sum + this.tax; + } + + public String toString() { + return code + " " + name + " " + price + " " + tax + " " + fin; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i y.fin.compareTo(x.fin)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J05069 - CÂU LẠC BỘ BÓNG ĐÁ - 1.java b/J05069 - CÂU LẠC BỘ BÓNG ĐÁ - 1.java new file mode 100644 index 0000000..bc3a1ec --- /dev/null +++ b/J05069 - CÂU LẠC BỘ BÓNG ĐÁ - 1.java @@ -0,0 +1,57 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name; + Long price; + + public ob(String code, String name, long price){ + this.code = code; + this.name = name; + this.price = price; + } + } + + static class ob2{ + ob o; + String code; + long total; + public ob2(ob o, String code, long sl){ + this.code = code; + this.o = o; + this.total = o.price*sl; + } + + @Override + public String toString(){ + return code + " " + o.name + " " + total; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + ArrayList b= new ArrayList<>(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05070 - CÂU LẠC BỘ BÓNG ĐÁ - 2.java b/J05070 - CÂU LẠC BỘ BÓNG ĐÁ - 2.java new file mode 100644 index 0000000..69a04fa --- /dev/null +++ b/J05070 - CÂU LẠC BỘ BÓNG ĐÁ - 2.java @@ -0,0 +1,61 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name; + Long price; + + public ob(String code, String name, long price){ + this.code = code; + this.name = name; + this.price = price; + } + } + + static class ob2{ + ob o; + String code; + Long total; + public ob2(ob o, String code, long sl){ + this.code = code; + this.o = o; + this.total = o.price*sl; + } + + @Override + public String toString(){ + return code + " " + o.name + " " + total; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + ArrayList b= new ArrayList<>(); + for(int i=0;i { + if(x.total.compareTo(y.total) == 0) return x.o.name.compareTo(y.o.name); + return y.total.compareTo(x.total); + }); + b.forEach(e -> System.out.println(e)); + } +} diff --git a/J05071 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 1.java b/J05071 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 1.java new file mode 100644 index 0000000..a94bf88 --- /dev/null +++ b/J05071 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 1.java @@ -0,0 +1,83 @@ +import java.util.Scanner; +import java.util.ArrayList; + +class Imformation{ + protected String code, name; + protected int price; + + public Imformation(String code, String name, int price){ + this.code = code; + this.name = name; + this.price = price; + } +} + +class Call { + private Imformation thongtin; + private String so, bd, kt; + + public Call(Imformation thongtin, String so, String bd, String kt){ + this.thongtin = thongtin; + this.so = so; + this.bd = bd; + this.kt = kt; + } + + public int thoiGian(String s1, String s2, Imformation a){ + int tam = (Integer.parseInt(s2.substring(0,2))-Integer.parseInt(s1.substring(0,2)))*60+Integer.parseInt(s2.substring(3))-Integer.parseInt(s1.substring(3)); + if(a.code.equals("100")==true){ + if(tam%3==0) return tam/3; + return tam/3+1; + } + return tam; + } + + public int kq(int a, Imformation b){ + return a*b.price; + } + + @Override + public String toString(){ + return String.format("%s %s %d %d", so, thongtin.name, thoiGian(bd, kt, thongtin), kq(thoiGian(bd, kt, thongtin), thongtin)); + } +} + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = Integer.parseInt(sc.nextLine()); + ArrayList arr1 = new ArrayList<>(); + for(int i=1;i<=n;i++){ + String code = sc.nextLine(); + String name = sc.nextLine(); + int price = Integer.parseInt(sc.nextLine()); + Imformation a = new Imformation(code, name, price); + arr1.add(a); + } + int m = Integer.parseInt(sc.nextLine()); + ArrayList arr2 = new ArrayList<>(); + for(int i=1;i<=m;i++){ + String[] s = sc.nextLine().trim().split("\\s+"); + String so = s[0]; + String bd = s[1]; + String kt = s[2]; + if(so.charAt(0)!='0'){ + Imformation tam = new Imformation("100", "Noi mang", 800); + Call a = new Call(tam, so, bd, kt); + arr2.add(a); + } + else{ + for(Imformation j:arr1){ + if(j.code.equals(so.substring(1,3))==true){ + Call a = new Call(j, so, bd, kt); + arr2.add(a); + break; + } + } + } + } + for(Call i:arr2){ + System.out.println(i); + } + } +} diff --git a/J05072 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 2.java b/J05072 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 2.java new file mode 100644 index 0000000..4d58b35 --- /dev/null +++ b/J05072 - TÍNH CƯỚC ĐIỆN THOẠI CỐ ĐỊNH - 2.java @@ -0,0 +1,86 @@ +import java.util.Scanner; +import java.util.ArrayList; + +class Imformation{ + protected String code, name; + protected int price; + + public Imformation(String code, String name, int price){ + this.code = code; + this.name = name; + this.price = price; + } +} + +class Call{ + private Imformation thongtin; + private String so, bd, kt; + int sum; + public Call(Imformation thongtin, String so, String bd, String kt){ + this.thongtin = thongtin; + this.so = so; + this.bd = bd; + this.kt = kt; + this.sum = kq(thoiGian(bd, kt, thongtin), thongtin); + } + + public int thoiGian(String s1, String s2, Imformation a){ + int tam = (Integer.parseInt(s2.substring(0,2))-Integer.parseInt(s1.substring(0,2)))*60+Integer.parseInt(s2.substring(3))-Integer.parseInt(s1.substring(3)); + if(a.code.equals("100")==true){ + if(tam%3==0) return tam/3; + return tam/3+1; + } + return tam; + } + + public int kq(int a, Imformation b){ + return a*b.price; + } + + + @Override + public String toString(){ + return String.format("%s %s %d %d", so, thongtin.name, thoiGian(bd, kt, thongtin), sum); + } +} + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = Integer.parseInt(sc.nextLine()); + ArrayList arr1 = new ArrayList<>(); + for(int i=1;i<=n;i++){ + String code = sc.nextLine(); + String name = sc.nextLine(); + int price = Integer.parseInt(sc.nextLine()); + Imformation a = new Imformation(code, name, price); + arr1.add(a); + } + int m = Integer.parseInt(sc.nextLine()); + ArrayList arr2 = new ArrayList<>(); + for(int i=1;i<=m;i++){ + String[] s = sc.nextLine().trim().split("\\s+"); + String so = s[0]; + String bd = s[1]; + String kt = s[2]; + if(so.charAt(0)!='0'){ + Imformation tam = new Imformation("100", "Noi mang", 800); + Call a = new Call(tam, so, bd, kt); + arr2.add(a); + } + else{ + for(Imformation j:arr1){ + if(j.code.equals(so.substring(1,3))==true){ + Call a = new Call(j, so, bd, kt); + arr2.add(a); + break; + } + } + } + } + arr2.sort((Call x, Call y) -> y.sum - x.sum); + for(Call i:arr2){ + System.out.println(i); + } + } +} diff --git a/J05073 - TÍNH TOÁN GIÁ BÁN.java b/J05073 - TÍNH TOÁN GIÁ BÁN.java new file mode 100644 index 0000000..dde1a78 --- /dev/null +++ b/J05073 - TÍNH TOÁN GIÁ BÁN.java @@ -0,0 +1,52 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static double ship(String code, long sum){ + if(code.startsWith("T")) return sum*0.04; + if(code.startsWith("C")) return sum*0.03; + if(code.startsWith("D")) return sum*0.025; + return sum*0.005; + } + + static double tax(String code, long sum){ + if(code.startsWith("T")) return sum*0.29; + if(code.startsWith("C")) return sum*0.1; + if(code.startsWith("D")) return sum*0.08; + return sum*0.02; + } + + static class ob{ + String code; + Long price, sl, sum; + Double sell, tax, ship; + + public ob(String code, long price, long sl){ + this.code = code; + this.price = price; + this.sl = sl; + this.sum = price * sl; + this.tax = tax(code, this.sum); + this.ship = ship(code, this.sum); + if(code.endsWith("C")) this.tax *= 0.95; + this.sell = this.sum*1.0 + this.tax + this.ship; + this.sell *= 1.2; + this.sell /= this.sl; + } + + @Override + public String toString(){ + return code + " " + String.format("%.2f", sell); + } + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05074 - ĐIỂM DANH - 1.java b/J05074 - ĐIỂM DANH - 1.java new file mode 100644 index 0000000..76430d5 --- /dev/null +++ b/J05074 - ĐIỂM DANH - 1.java @@ -0,0 +1,55 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name, cl, status; + int ck; + + public ob(String code, String name, String cl){ + this.code = code; + this.name = name; + this.cl = cl; + this.ck = 10; + this.status = ""; + } + + public void get(String s){ + int cntv = 0, cntm = 0; + for(int i=0;i a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J05075 - ĐIỂM DANH - 2.java b/J05075 - ĐIỂM DANH - 2.java new file mode 100644 index 0000000..a5e7e0d --- /dev/null +++ b/J05075 - ĐIỂM DANH - 2.java @@ -0,0 +1,58 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name, cl, status; + int ck; + + public ob(String code, String name, String cl){ + this.code = code; + this.name = name; + this.cl = cl; + this.ck = 10; + this.status = ""; + } + + public void get(String s){ + int cntv = 0, cntm = 0; + for(int i=0;i a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i{ + if(e.cl.compareTo(cl) == 0) System.out.println(e); + }); + } +} diff --git a/J05076 - NHẬP XUẤT HÀNG.java b/J05076 - NHẬP XUẤT HÀNG.java new file mode 100644 index 0000000..073c1e3 --- /dev/null +++ b/J05076 - NHẬP XUẤT HÀNG.java @@ -0,0 +1,67 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name, c; + + public ob(String code, String name, String c){ + this.code = code; + this.name = name; + this.c = c; + } + } + + static long sum(String c, long total){ + if(c.compareTo("A") == 0) return total/100*8; + if(c.compareTo("B") == 0) return total/100*5; + if(c.compareTo("C") == 0) return total/100*2; + return 0; + } + + static class ob2 { + ob o; + String code; + Long slnhap, price, slxuat; + Long sumnhap, sumxuat; + public ob2(ob o, String code, long slnhap, long price, long slxuat){ + this.o = o; + this.code = code; + this.slnhap = slnhap; + this.price = price; + this.slxuat = slxuat; + this.sumnhap = slnhap*price; + this.sumxuat = price*slxuat + sum(o.c, price*slxuat); + } + + @Override + public String toString(){ + return code + " " + o.name + " " + sumnhap + " " + sumxuat; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i b = new ArrayList<>(); + for(int j=0;j System.out.println(e)); + } +} diff --git a/J05077 - TÍNH LƯƠNG.java b/J05077 - TÍNH LƯƠNG.java new file mode 100644 index 0000000..7e88038 --- /dev/null +++ b/J05077 - TÍNH LƯƠNG.java @@ -0,0 +1,81 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name; + + public ob(String code, String name){ + this.code = code; + this.name = name; + } + } + + static long x(String s){ + long y = Long.parseLong(s.substring(1,3)); + if (1<=y && y<=3){ + if(s.charAt(0)=='A') return 10; + if(s.charAt(0)=='B') return 10; + if(s.charAt(0)=='C') return 9; + return 8; + } + if(4<=y && y<=8){ + if(s.charAt(0)=='A') return 12; + if(s.charAt(0)=='B') return 11; + if(s.charAt(0)=='C') return 10; + return 9; + } + if(9<=y && y<=15){ + if(s.charAt(0)=='A') return 14; + if(s.charAt(0)=='B') return 13; + if(s.charAt(0)=='C') return 12; + return 11; + } + if(s.charAt(0)=='A') return 20; + if(s.charAt(0)=='B') return 16; + if(s.charAt(0)=='C') return 14; + return 13; + } + static class ob2 { + ob o; + String code, name; + Long x, sum; + public ob2(ob o, String code, String name, long sday, long days){ + this.o = o; + this.code = code; + this.name = name; + this.x = x(code); + this.sum = sday*days*this.x*1000; + } + + @Override + public String toString(){ + return code + " " + name + " " + o.name + " " + sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i b = new ArrayList<>(); + for(int j=0;j System.out.println(e)); + } +} diff --git a/J05078 - BẢNG LƯƠNG THEO PHÒNG BAN.java b/J05078 - BẢNG LƯƠNG THEO PHÒNG BAN.java new file mode 100644 index 0000000..a12a664 --- /dev/null +++ b/J05078 - BẢNG LƯƠNG THEO PHÒNG BAN.java @@ -0,0 +1,92 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name; + + public ob(String code, String name){ + this.code = code; + this.name = name; + } + } + + static long x(String s){ + long y = Long.parseLong(s.substring(1,3)); + if (1<=y && y<=3){ + if(s.charAt(0)=='A') return 10; + if(s.charAt(0)=='B') return 10; + if(s.charAt(0)=='C') return 9; + return 8; + } + if(4<=y && y<=8){ + if(s.charAt(0)=='A') return 12; + if(s.charAt(0)=='B') return 11; + if(s.charAt(0)=='C') return 10; + return 9; + } + if(9<=y && y<=15){ + if(s.charAt(0)=='A') return 14; + if(s.charAt(0)=='B') return 13; + if(s.charAt(0)=='C') return 12; + return 11; + } + if(s.charAt(0)=='A') return 20; + if(s.charAt(0)=='B') return 16; + if(s.charAt(0)=='C') return 14; + return 13; + } + static class ob2 { + ob o; + String code, name; + Long x, sum; + public ob2(ob o, String code, String name, long sday, long days){ + this.o = o; + this.code = code; + this.name = name; + this.x = x(code); + this.sum = sday*days*this.x*1000; + } + + @Override + public String toString(){ + return code + " " + name + " " + sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i b = new ArrayList<>(); + for(int j=0;j{ + if(e.o.code.compareTo(s) == 0) System.out.println(e); + }); + } +} diff --git a/J05079 - LỚP HỌC PHẦN – 1.java b/J05079 - LỚP HỌC PHẦN – 1.java new file mode 100644 index 0000000..85640e1 --- /dev/null +++ b/J05079 - LỚP HỌC PHẦN – 1.java @@ -0,0 +1,61 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name; + + public ob(String code, String name){ + this.code = code; + this.name = name; + } + + @Override + public String toString(){ + return code + " " + name; + } + } + + static class ob2 { + ArrayList a; + String code, name; + + public ob2(String code, String name){ + this.code = code; + this.name = name; + this.a = new ArrayList<>(); + } + + public void add(ob o){ + this.a.add(o); + } + + public void out(){ + System.out.printf("Danh sach nhom lop mon %s:\n", name); + a.forEach(e -> System.out.println(e)); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + HashMap hm = new HashMap<>(); + sc.nextLine(); + for(int i=0;i{ + v.a.sort((ob x, ob y) -> x.code.compareTo(y.code)); + }); + int m = sc.nextInt(); + for(int i=0;i a; + String name; + + public ob2( String name){ + this.name = name; + this.a = new ArrayList<>(); + } + + public void add(ob o){ + this.a.add(o); + } + + public void out(){ + System.out.printf("Danh sach cho giang vien %s:\n", name); + a.forEach(e -> System.out.println(e)); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + HashMap hm = new HashMap<>(); + sc.nextLine(); + for(int i=0;i{ + v.a.sort((ob x, ob y) -> { + if(x.code.compareTo(y.code) == 0) return x.cl.compareTo(y.cl); + return x.code.compareTo(y.code); + }); + }); + int m = sc.nextInt(); + sc.nextLine(); + for(int i=0;i b.code; + return pro < b.pro; + } + String name, unit; + int buy,sell,pro,code; + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + goods[] a = new goods[n]; + for(int i=0; i a = new ArrayList<>(); + int n = sc.nextInt(); + sc.nextLine(); + for(int i=0;i{ + if(x.date.compareTo(y.date)==0){ + return x.code.compareTo(y.code); + } + return x.date.compareTo(y.date); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J06001 - TÍNH TOÁN HÓA ĐƠN BÁN QUẦN ÁO.java b/J06001 - TÍNH TOÁN HÓA ĐƠN BÁN QUẦN ÁO.java new file mode 100644 index 0000000..ac40cab --- /dev/null +++ b/J06001 - TÍNH TOÁN HÓA ĐƠN BÁN QUẦN ÁO.java @@ -0,0 +1,87 @@ +import java.util.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class stuff { + String code, name; + int l1, l2; + + public stuff(String m, String n, int x, int y) { + code = m; + name = n; + l1 = x; + l2 = y; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + + public int getPrice(String s) { + if (s.charAt(2) == '1') + return l1; + return l2; + } + } + + static class bill { + String code, name; + int cnt, off, sum, fin; + + public bill(int i, String c, String name, int count, int price) { + code = c + '-' + String.format("%03d", i); + this.name = name; + cnt = count; + sum = price * cnt; + if (cnt >= 150) { + off = sum / 2; + } else if (cnt >= 100) { + off = sum * 3 / 10; + } else if (cnt >= 50) { + off = sum * 15 / 100; + }else off = 0; + + fin = sum - off; + } + + @Override + public String toString() { + return code + ' ' + name + ' ' + off + ' ' + fin; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new stuff(sc.nextLine(), sc.nextLine(), sc.nextInt(), sc.nextInt())); + } + int m = sc.nextInt(); + ArrayList b = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + String code = sc.next(); + int cnt = sc.nextInt(); + stuff x = a.get(0); + for (int j = 0; j < n; j++) { + if (a.get(j).isStuff(code)) { + x = a.get(j); + break; + } + } + b.add(new bill(i, code, x.name, cnt, x.getPrice(code))); + } + b.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J06002 - SẮP XẾP HÓA ĐƠN BÁN QUẦN ÁO.java b/J06002 - SẮP XẾP HÓA ĐƠN BÁN QUẦN ÁO.java new file mode 100644 index 0000000..3c26a57 --- /dev/null +++ b/J06002 - SẮP XẾP HÓA ĐƠN BÁN QUẦN ÁO.java @@ -0,0 +1,90 @@ +import java.util.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class stuff { + String code, name; + int l1, l2; + + public stuff(String m, String n, int x, int y) { + code = m; + name = n; + l1 = x; + l2 = y; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + + public int getPrice(String s) { + if (s.charAt(2) == '1') + return l1; + return l2; + } + } + + static class bill { + String code, name; + int cnt, off, sum, fin; + + public bill(int i, String c, String name, int count, int price) { + code = c + '-' + String.format("%03d", i); + this.name = name; + cnt = count; + sum = price * cnt; + if (cnt >= 150) { + off = sum / 2; + } else if (cnt >= 100) { + off = sum * 3 / 10; + } else if (cnt >= 50) { + off = sum * 15 / 100; + }else off = 0; + + fin = sum - off; + } + + @Override + public String toString() { + return code + ' ' + name + ' ' + off + ' ' + fin; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new stuff(sc.nextLine(), sc.nextLine(), sc.nextInt(), sc.nextInt())); + } + int m = sc.nextInt(); + ArrayList b = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + String code = sc.next(); + int cnt = sc.nextInt(); + stuff x = a.get(0); + for (int j = 0; j < n; j++) { + if (a.get(j).isStuff(code)) { + x = a.get(j); + break; + } + } + b.add(new bill(i, code, x.name, cnt, x.getPrice(code))); + } + b.sort((bill x, bill y) -> { + return y.fin - x.fin; + }); + b.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J06003 - QUẢN LÝ BÀI TẬP NHÓM – 1.java b/J06003 - QUẢN LÝ BÀI TẬP NHÓM – 1.java new file mode 100644 index 0000000..fdb71a5 --- /dev/null +++ b/J06003 - QUẢN LÝ BÀI TẬP NHÓM – 1.java @@ -0,0 +1,52 @@ +import java.util.*; + +public class non { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String msv, name, sdt; + int index; + + public sv(String m, String n, String s, int i) { + msv = m; + name = n; + sdt = s; + index = i; + } + + @Override + public String toString(){ + return msv + " " + name + " " + sdt; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), m = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new sv(sc.nextLine(), sc.nextLine(), sc.next(), sc.nextInt())); + } + String[] thread = new String[m + 1]; + sc.nextLine(); + for (int i = 1; i <= m; i++) + thread[i] = sc.nextLine(); + int q = sc.nextInt(); + while(q-->0){ + int th = sc.nextInt(); + System.out.printf("DANH SACH NHOM %d:\n", th); + a.forEach(e -> { + if(e.index == th) System.out.println(e); + }); + System.out.printf("Bai tap dang ky: %s\n", thread[th]); + } + } +} diff --git a/J06004 - QUẢN LÝ BÀI TẬP NHÓM – 2.java b/J06004 - QUẢN LÝ BÀI TẬP NHÓM – 2.java new file mode 100644 index 0000000..3bbea9a --- /dev/null +++ b/J06004 - QUẢN LÝ BÀI TẬP NHÓM – 2.java @@ -0,0 +1,44 @@ +import java.util.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class sv { + String msv, name, sdt; + int index; + + public sv(String m, String n, String s, int i) { + msv = m; + name = n; + sdt = s; + index = i; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(), m = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new sv(sc.nextLine(), sc.nextLine(), sc.next(), sc.nextInt())); + } + a.sort((sv x, sv y) -> { + return x.msv.compareTo(y.msv); + }); + String[] thread = new String[m + 1]; + sc.nextLine(); + for (int i = 1; i <= m; i++) + thread[i] = sc.nextLine(); + a.forEach(e -> { + System.out.printf("%s %s %s %d %s\n", e.msv, e.name, e.sdt, e.index, thread[e.index]); + }); + } +} diff --git a/J06005 - QUẢN LÝ BÁN HÀNG – 1.java b/J06005 - QUẢN LÝ BÁN HÀNG – 1.java new file mode 100644 index 0000000..6ba6a9d --- /dev/null +++ b/J06005 - QUẢN LÝ BÁN HÀNG – 1.java @@ -0,0 +1,106 @@ +import java.util.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class stuff { + String code, name, unit; + long l1, l2; + + public stuff(int i, String n, String m, long x, long y) { + code = "MH" + String.format("%03d", i); + name = n; + unit = m; + l1 = x; + l2 = y; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + } + + static class person { + String code, name, gender, date, address; + + public person(int i, String n, String g, String d, String a) { + code = "KH" + String.format("%03d", i); + name = n; + gender = g; + date = d; + address = a; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + + } + + static class bill { + stuff s; + String code; + person p; + long sum, cnt; + + public bill(int i, stuff a, person b, long cnt) { + code = "HD" + String.format("%03d", i); + s = a; + p = b; + this.cnt = cnt; + sum = s.l2 * cnt; + } + + @Override + public String toString() { + return code + ' ' + p.name + ' ' + p.address + ' ' + s.name + ' ' + s.unit + ' ' + s.l1 + ' ' + s.l2 + ' ' + + cnt + ' ' + sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList p = new ArrayList<>(); + sc.nextLine(); + for (int i = 1; i <= n; i++) { + p.add(new person(i, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + int m = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + sc.nextLine(); + a.add(new stuff(i, sc.nextLine(), sc.nextLine(), sc.nextLong(), sc.nextLong())); + } + int k = sc.nextInt(); + ArrayList b = new ArrayList<>(); + for (int i = 1; i <= k; i++) { + String pcode = sc.next(); + String scode = sc.next(); + long cnt = sc.nextLong(); + stuff s = a.get(0); + person per = p.get(0); + for (int j = 0; j < n; j++) { + if (p.get(j).isStuff(pcode)) { + per = p.get(j); + } + } + for (int j = 0; j < m; j++) { + if (a.get(j).isStuff(scode)) { + s = a.get(j); + } + } + b.add(new bill(i, s, per, cnt)); + } + b.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J06006 - QUẢN LÝ BÁN HÀNG – 2.java b/J06006 - QUẢN LÝ BÁN HÀNG – 2.java new file mode 100644 index 0000000..9ee4cb1 --- /dev/null +++ b/J06006 - QUẢN LÝ BÁN HÀNG – 2.java @@ -0,0 +1,110 @@ +import java.util.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class stuff { + String code, name, unit; + long l1, l2; + + public stuff(int i, String n, String m, long x, long y) { + code = "MH" + String.format("%03d", i); + name = n; + unit = m; + l1 = x; + l2 = y; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + } + + static class person { + String code, name, gender, date, address; + + public person(int i, String n, String g, String d, String a) { + code = "KH" + String.format("%03d", i); + name = n; + gender = g; + date = d; + address = a; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + + } + + static class bill { + stuff s; + String code; + person p; + Long sum, cnt, pro; + + public bill(int i, stuff a, person b, long cnt) { + code = "HD" + String.format("%03d", i); + s = a; + p = b; + this.cnt = cnt; + sum = s.l2 * cnt; + pro = (s.l2 - s.l1)*cnt; + } + + @Override + public String toString() { + return code + ' ' + p.name + ' ' + p.address + ' ' + s.name + " " + cnt + " " + sum + " " + pro; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList p = new ArrayList<>(); + sc.nextLine(); + for (int i = 1; i <= n; i++) { + p.add(new person(i, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + int m = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + sc.nextLine(); + a.add(new stuff(i, sc.nextLine(), sc.nextLine(), sc.nextLong(), sc.nextLong())); + } + int k = sc.nextInt(); + ArrayList b = new ArrayList<>(); + for (int i = 1; i <= k; i++) { + String pcode = sc.next(); + String scode = sc.next(); + long cnt = sc.nextLong(); + stuff s = a.get(0); + person per = p.get(0); + for (int j = 0; j < n; j++) { + if (p.get(j).isStuff(pcode)) { + per = p.get(j); + } + } + for (int j = 0; j < m; j++) { + if (a.get(j).isStuff(scode)) { + s = a.get(j); + } + } + b.add(new bill(i, s, per, cnt)); + } + b.sort((bill x, bill y) -> { + if(x.pro == y.pro) return x.code.compareTo(y.code); + return y.pro.compareTo(x.pro); + }); + b.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J06007 - BẢNG TÍNH GIỜ CHUẨN.java b/J06007 - BẢNG TÍNH GIỜ CHUẨN.java new file mode 100644 index 0000000..b025b6a --- /dev/null +++ b/J06007 - BẢNG TÍNH GIỜ CHUẨN.java @@ -0,0 +1,62 @@ +import java.util.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class gv { + String code, name; + double sum; + + public gv(String s) { + sum = 0; + String[] a = s.trim().split(" ",2); + code = a[0]; + name = a[1]; + } + + public boolean is(String s) { + return s.startsWith(code); + } + + @Override + public String toString() { + return name + ' ' + String.format("%.2f", sum); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + sc.nextLine(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + } + n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for (int i = 1; i <= n; i++) + a.add(new gv(sc.nextLine())); + int m = sc.nextInt(); + for (int i = 0; i < m; i++) { + String gcode = sc.next(); + sc.next(); + double time = sc.nextDouble(); + int ind = 0; + for (int j = 0; j < n; j++) { + if (a.get(j).is(gcode)) { + ind = j; + break; + } + } + a.get(ind).sum += time; + } + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J06008 - TÍNH GIỜ CHUẨN CHO TỪNG GIẢNG VIÊN.java b/J06008 - TÍNH GIỜ CHUẨN CHO TỪNG GIẢNG VIÊN.java new file mode 100644 index 0000000..8d3b3c1 --- /dev/null +++ b/J06008 - TÍNH GIỜ CHUẨN CHO TỪNG GIẢNG VIÊN.java @@ -0,0 +1,119 @@ +import java.util.*; + +public class Main { + static class sub { + String code, name; + double sum; + + public sub(String s) { + String[] a = s.trim().split(" ", 2); + code = a[0]; + name = a[1]; + } + + public sub(sub x) { + code = x.code; + name = x.name; + sum = x.sum; + } + + public boolean is(String s) { + return s.startsWith(code); + } + + @Override + public String toString() { + return name + ' ' + sum; + } + } + + static class gv { + String code, name; + double sum; + ArrayList a; + + public gv(String s) { + a = new ArrayList<>(); + sum = 0; + String[] a = s.trim().split(" ", 2); + code = a[0]; + name = a[1]; + } + + public boolean is(String s) { + return s.startsWith(code); + } + + public boolean contain(sub x) { + for (int i = 0; i < a.size(); i++) { + if (a.get(i).is(x.code)) + return true; + } + return false; + } + + public void add(sub x) { + if (this.contain(x)) { + for (int i = 0; i < a.size(); i++) { + if (a.get(i).is(x.code)) { + a.get(i).sum += x.sum; + break; + } + } + } else { + this.a.add(x); + } + } + + @Override + public String toString() { + return name + ' ' + String.format("%.2f", sum); + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int k = sc.nextInt(); + ArrayList s = new ArrayList<>(); + sc.nextLine(); + for (int i = 0; i < k; i++) { + s.add(new sub(sc.nextLine())); + } + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for (int i = 1; i <= n; i++) + a.add(new gv(sc.nextLine())); + int m = sc.nextInt(); + for (int i = 0; i < m; i++) { + String gcode = sc.next(); + String scode = sc.next(); + double time = sc.nextDouble(); + int ind = 0; + sub x = new sub(s.get(0)); + for (int j = 0; j < n; j++) { + if (a.get(j).is(gcode)) { + ind = j; + break; + } + } + for (int j = 0; j < k; j++) { + if (s.get(j).is(scode)) { + x=new sub(s.get(j)); + break; + } + } + x.sum = time; + a.get(ind).add(x); + a.get(ind).sum += x.sum; + } + String code = sc.next(); + for (int i = 0; i < n; i++) { + if(a.get(i).is(code)){ + System.out.printf("Giang vien: %s\n", a.get(i).name); + a.get(i).a.forEach(e -> System.out.println(e)); + System.out.printf("Tong: %.2f", a.get(i).sum); + } + } + } +} diff --git a/J07001 - ĐỌC FILE VĂN BẢN.java b/J07001 - ĐỌC FILE VĂN BẢN.java new file mode 100644 index 0000000..b05e34c --- /dev/null +++ b/J07001 - ĐỌC FILE VĂN BẢN.java @@ -0,0 +1,17 @@ +import java.util.Scanner; +import java.io.File; +import java.io.FileNotFoundException; +public class Main{ + public static void main(String args[]){ + File x = new File("DATA.in"); + try{ + Scanner sc = new Scanner(x); + while(sc.hasNext()){ + System.out.println(sc.nextLine()); + } + }catch(FileNotFoundException e){ + + } + + } +} diff --git a/J07002 - TÍNH TỔNG.java b/J07002 - TÍNH TỔNG.java new file mode 100644 index 0000000..7b7ca12 --- /dev/null +++ b/J07002 - TÍNH TỔNG.java @@ -0,0 +1,25 @@ +import java.util.Scanner; +import java.io.File; +import java.io.FileNotFoundException; + +public class Main{ + public static void main(String args[]){ + File x = new File("DATA.in"); + try{ + long s = 0; + Scanner sc = new Scanner(x); + while(sc.hasNext()){ + try{ + String t = sc.next(); + s += Integer.parseInt(t); + }catch(NumberFormatException e){ + + } + } + System.out.println(s); + }catch(FileNotFoundException e){ + + } + + } +} diff --git a/J07003 - TÁCH ĐÔI VÀ TÍNH TỔNG.java b/J07003 - TÁCH ĐÔI VÀ TÍNH TỔNG.java new file mode 100644 index 0000000..441f026 --- /dev/null +++ b/J07003 - TÁCH ĐÔI VÀ TÍNH TỔNG.java @@ -0,0 +1,24 @@ +import java.util.Scanner; +import java.io.File; +import java.math.BigInteger; +import java.io.FileNotFoundException; + +public class Main{ + public static void main(String args[]){ + File x = new File("DATA.in"); + try{ + Scanner sc = new Scanner(x); + BigInteger s = sc.nextBigInteger(); + while(s.toString().length() > 1){ + int length = s.toString().length(); + BigInteger a = new BigInteger(s.toString().substring(0,length/2)); + BigInteger b = new BigInteger(s.toString().substring(length/2,length)); + s = a.add(b); + System.out.println(s); + } + sc.close(); + }catch(FileNotFoundException e){ + + } + } +} diff --git a/J07004 - SỐ KHÁC NHAU TRONG FILE - 1.java b/J07004 - SỐ KHÁC NHAU TRONG FILE - 1.java new file mode 100644 index 0000000..e89fadf --- /dev/null +++ b/J07004 - SỐ KHÁC NHAU TRONG FILE - 1.java @@ -0,0 +1,24 @@ +import java.util.Scanner; +import java.io.File; +import java.util.HashMap; +import java.io.FileNotFoundException; + +public class Main{ + public static void main(String args[]){ + File x = new File("DATA.in"); + try{ + Scanner sc = new Scanner(x); + HashMap a = new HashMap(); + while(sc.hasNext()){ + int n = sc.nextInt(); + if(a.get(n) == null) a.put(n, 1); + else a.put(n, a.get(n)+1); + } + a.forEach((key, value) ->{ + System.out.printf("%d %d\n",key, value); + }); + sc.close(); + }catch(FileNotFoundException e){ + } + } +} diff --git a/J07005 - SỐ KHÁC NHAU TRONG FILE - 2.java b/J07005 - SỐ KHÁC NHAU TRONG FILE - 2.java new file mode 100644 index 0000000..c68b3fd --- /dev/null +++ b/J07005 - SỐ KHÁC NHAU TRONG FILE - 2.java @@ -0,0 +1,17 @@ +import java.util.*; +import java.io.*; + +public class Main{ + public static void main(String[] args) throws IOException, FileNotFoundException { + DataInputStream is = new DataInputStream(new FileInputStream("DATA.IN")); + TreeMap a = new TreeMap<>(); + for(int i=0;i<100000;i++){ + int x = is.readInt(); + if(a.get(x) == null) a.put(x, 1); + else a.put(x, a.get(x)+1); + } + a.forEach((k,v) -> { + System.out.printf("%d %d\n", k , v); + }); + } +} diff --git a/J07006 - SỐ KHÁC NHAU TRONG FILE - 3.java b/J07006 - SỐ KHÁC NHAU TRONG FILE - 3.java new file mode 100644 index 0000000..8b787d6 --- /dev/null +++ b/J07006 - SỐ KHÁC NHAU TRONG FILE - 3.java @@ -0,0 +1,17 @@ +import java.util.*; +import java.io.*; + +public class Main{ + public static void main(String[] args) throws IOException, FileNotFoundException, ClassNotFoundException { + ObjectInputStream is = new ObjectInputStream(new FileInputStream("DATA.in")); + TreeMap a = new TreeMap<>(); + ArrayList l = (ArrayList) is.readObject(); + l.forEach( x -> { + if(a.get(x) == null) a.put(x, 1); + else a.put(x, a.get(x)+1); + }); + a.forEach((k,v) -> { + System.out.printf("%d %d\n", k , v); + }); + } +} diff --git a/J07007 - LIỆT KÊ TỪ KHÁC NHAU.java b/J07007 - LIỆT KÊ TỪ KHÁC NHAU.java new file mode 100644 index 0000000..a47ce0f --- /dev/null +++ b/J07007 - LIỆT KÊ TỪ KHÁC NHAU.java @@ -0,0 +1,42 @@ +package nyagami; + +import java.io.File; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.util.Scanner; +import java.util.TreeSet; +import java.util.HashMap; + +public class test { + public static class WordSet{ + String str; + public WordSet(String file){ + str = ""; + File in = new File(file); + try{ + Scanner sc = new Scanner(in); + TreeSet tree = new TreeSet(); +// HashMap set = new HashMap(); + while(sc.hasNext()){ + tree.add(sc.next().toLowerCase()); + } + tree.forEach(s -> { + str += s + '\n'; + }); + }catch(FileNotFoundException e){ + + } + } + public String toString(){ + return str; + } + } + public static void main(String[] args) throws IOException { + WordSet ws = new WordSet("VANBAN.in"); + System.out.println(ws); + } + public static void main4139063(String[] args) throws IOException { + WordSet ws = new WordSet("VANBAN.in"); + System.out.println(ws); + } +} diff --git a/J07008 - DÃY CON TĂNG DẦN.java b/J07008 - DÃY CON TĂNG DẦN.java new file mode 100644 index 0000000..e592b04 --- /dev/null +++ b/J07008 - DÃY CON TĂNG DẦN.java @@ -0,0 +1,30 @@ +import java.util.Scanner; +import java.util.TreeSet; +import java.io.IOException; +import java.io.File; + +public class Main{ + static void Try(int start, int num, String r, int[] a, int[] ans, int n, TreeSet ts){ + if(num > 1) ts.add(r); + if(num == n) return; + for(int i=start; i ans[num-1]){ + ans[num] = a[i]; + }else continue; + Try(i+1, num+1, r + Integer.toString(a[i]) + " ", a, ans, n ,ts); + } + } + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("DAYSO.in")); + TreeSet ts = new TreeSet<>(); + int n = sc.nextInt(); + int [] a = new int[n]; + int [] ans = new int[n]; + for(int i=0; i System.out.println(s)); + } +} diff --git a/J07009 - LỚP INTSET - 2.java b/J07009 - LỚP INTSET - 2.java new file mode 100644 index 0000000..95e37af --- /dev/null +++ b/J07009 - LỚP INTSET - 2.java @@ -0,0 +1,55 @@ +import java.util.*; +import java.io.*; +public class non { + static class IntSet { + TreeSet a; + + public IntSet(int[] arr) { + a = new TreeSet<>(); + for (int i : arr) + a.add(i); + } + + public IntSet(){ + a = new TreeSet<>(); + } + + public IntSet intersection(IntSet b) { + IntSet o = new IntSet(); + a.forEach(e -> { + if(b.a.contains(e)) o.a.add(e); + }); + return o; + } + @Override + public String toString() { + String s = ""; + Object[] r = a.toArray(); + for (int i = 0; i < r.length; i++) + s += r[i] + " "; + return s; + } + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("DATA.in")); + int n = sc.nextInt(), m = sc.nextInt(), a[] = new int[n], b[] = new int[m]; + for(int i = 0; i m = new TreeMap<>(); +// String re1 = "\\d+"; +// String re2 = "\\w+"; + int max = 0; + while(sc.hasNextLine()) { + String s = sc.nextLine().toLowerCase(); + if(s.length() == 0) continue; + + String a[] = s.trim().split("[^a-z0-9]"); + + for (String x : a) { + + if (x.length()>0) { + if (m.containsKey(x)) { + int fre = m.get(x); + m.put(x, fre + 1); + max = Math.max(fre + 1, max); + } else { + m.put(x, 1); + max = Math.max(max, 1); + } + } + } + } + while (max > 0) { + for (Map.Entry e : m.entrySet()) { + if(e.getValue()==max) System.out.println(e.getKey() + " " + e.getValue()); + } + max--; + } + } +} +// +//3 +//PTIT duy tri hoc phi on dinh nam 2019 va khong tang trong nam 2020-2021 va 2021-2022! +//Khi dich benh xuat hien PTIT trich hon 6 ty dong ho tro sinh vien PTIT +//voi muc ho tro 500000 dong/sinh vien PTIT. diff --git a/J07012 - THỐNG KÊ TỪ KHÁC NHAU TRONG FILE NHỊ PHÂN.java b/J07012 - THỐNG KÊ TỪ KHÁC NHAU TRONG FILE NHỊ PHÂN.java new file mode 100644 index 0000000..7b628c0 --- /dev/null +++ b/J07012 - THỐNG KÊ TỪ KHÁC NHAU TRONG FILE NHỊ PHÂN.java @@ -0,0 +1,48 @@ +import java.util.*; +import java.io.*; + +public class non { + + static class pair { + String s; + int cnt; + + public pair(String s) { + this.s = s; + cnt = 1; + } + + @Override + public String toString() { + return s + " " + cnt; + } + } + + public static void main(String[] args) throws IOException, ClassNotFoundException { + ObjectInputStream o = new ObjectInputStream(new FileInputStream("DATA.in")); + ArrayList lines = (ArrayList) o.readObject(); + HashMap hm = new HashMap<>(); + ArrayList a = new ArrayList<>(); + for (String line : lines) { + if (line.length() == 0) + continue; + String[] arr = line.toLowerCase().trim().split("[^a-z0-9]"); + for (int i = 0; i < arr.length; i++) { + if (arr[i].length() > 0) { + if (hm.get(arr[i]) == null) { + pair x = new pair(arr[i]); + hm.put(arr[i], x); + a.add(x); + } else + hm.get(arr[i]).cnt++; + } + } + } + a.sort((pair x, pair y) -> { + if (x.cnt == y.cnt) + return x.s.compareTo(y.s); + return y.cnt - x.cnt; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07013 - DANH SÁCH SINH VIÊN TRONG FILE NHỊ PHÂN.java b/J07013 - DANH SÁCH SINH VIÊN TRONG FILE NHỊ PHÂN.java new file mode 100644 index 0000000..c6d3eeb --- /dev/null +++ b/J07013 - DANH SÁCH SINH VIÊN TRONG FILE NHỊ PHÂN.java @@ -0,0 +1,40 @@ +danhsachsinhvien1/SinhVien.java +package danhsachsinhvien1; + +import java.io.*; +import java.text.*; +import java.util.*; + +public class SinhVien implements Serializable{ + private String ma, ten, lop; + private Date ngaysinh; + private float gpa; + + public SinhVien(int id, String ten, String lop, String ngaysinh, float gpa) throws ParseException{ + this.ma = String.format("B20DCCN%03d", id); + this.ten = ten; + this.lop = lop; + SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy"); + this.ngaysinh = f.parse(ngaysinh); + this.gpa = gpa; + } + @Override + public String toString(){ + SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy"); + return ma + " " + ten + " " + lop + " " + f.format(ngaysinh) + " " + String.format("%.2f", gpa); + } +} + +danhsachsinhvien1/test.java +package danhsachsinhvien1; +import java.util.*; +import java.io.*; + +public class test { + public static void main(String[] args) throws IOException, ClassNotFoundException{ + ObjectInputStream o = new ObjectInputStream(new FileInputStream("SV.in")); + ArrayList a = (ArrayList) o.readObject(); + a.forEach(e -> System.out.println(e)); + } +} + diff --git a/J07014 - HỢP VÀ GIAO CỦA HAI FILE VĂN BẢN.java b/J07014 - HỢP VÀ GIAO CỦA HAI FILE VĂN BẢN.java new file mode 100644 index 0000000..9303563 --- /dev/null +++ b/J07014 - HỢP VÀ GIAO CỦA HAI FILE VĂN BẢN.java @@ -0,0 +1,60 @@ +import java.io.File; +import java.io.IOException; +import java.util.*; + +public class Main { + static class WordSet { + TreeSet a; + + public WordSet(String filename) throws IOException { + Scanner sc = new Scanner(new File(filename)); + String s = ""; + while(sc.hasNextLine()) s+=sc.nextLine() + " "; + a = new TreeSet<>(); + String[] r = s.toLowerCase().trim().split("\\s+"); + for (int i = 0; i < r.length; i++) + a.add(r[i]); + } + + public WordSet() { + a = new TreeSet<>(); + } + + public WordSet union(WordSet b) { + WordSet c = new WordSet(); + for(String i : this.a) c.a.add(i); + for(String i : b.a) c.a.add(i); + return c; + } + + public WordSet intersection(WordSet b) { + WordSet c = new WordSet(); + for (String i : this.a) { + for (String j : b.a) { + if (i.compareTo(j) == 0) + c.a.add(i); + } + } + return c; + } + @Override + public String toString() { + return String.join(" ", a); + } + } + + public static void main(String[] args) throws IOException { + WordSet s1 = new WordSet("DATA1.in"); + WordSet s2 = new WordSet("DATA2.in"); + System.out.println(s1.union(s2)); + System.out.println(s1.intersection(s2)); + } + public static void main1889176(String[] args) throws IOException { + WordSet s1 = new WordSet("DATA1.in"); + WordSet s2 = new WordSet("DATA2.in"); + System.out.println(s1.union(s2)); + System.out.println(s1.intersection(s2)); + } +} + + diff --git a/J07015 - SỐ NGUYÊN TỐ TRONG FILE NHỊ PHÂN.java b/J07015 - SỐ NGUYÊN TỐ TRONG FILE NHỊ PHÂN.java new file mode 100644 index 0000000..0a19b38 --- /dev/null +++ b/J07015 - SỐ NGUYÊN TỐ TRONG FILE NHỊ PHÂN.java @@ -0,0 +1,26 @@ +import java.util.*; +import java.io.*; + +public class Main{ + public static void main(String[] args) throws IOException, ClassNotFoundException{ + boolean[] f = new boolean[100005]; + for(int i=2; i a = (ArrayList) ois.readObject(); + TreeMap hm = new TreeMap<>(); + a.forEach(e ->{ + if(f[e]){ + if(hm.get(e) == null) hm.put(e, 1); + else hm.put(e, hm.get(e)+1); + } + }); + hm.forEach((k, v) -> { + System.out.println(k + " " + v); + }); + } +} diff --git a/J07016 - SỐ NGUYÊN TỐ TRONG HAI FILE NHỊ PHÂN.java b/J07016 - SỐ NGUYÊN TỐ TRONG HAI FILE NHỊ PHÂN.java new file mode 100644 index 0000000..c4611e1 --- /dev/null +++ b/J07016 - SỐ NGUYÊN TỐ TRONG HAI FILE NHỊ PHÂN.java @@ -0,0 +1,42 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static boolean prime(int x){ + if(x<2) return false; + if(x==2) return true; + if(x%2==0) return false; + for(int i=3;i <= (int)(Math.sqrt(x));i+=2){ + if(x%i==0) return false; + } + return true; + } + + public static void main(String[] args) throws IOException, ClassNotFoundException { + ObjectInputStream o1 = new ObjectInputStream(new FileInputStream("DATA1.in")); + ObjectInputStream o2 = new ObjectInputStream(new FileInputStream("DATA2.in")); + ArrayList a1 = (ArrayList) o1.readObject(); + ArrayList a2 = (ArrayList) o2.readObject(); + TreeMap h1 = new TreeMap<>(); + TreeMap h2 = new TreeMap<>(); + a1.forEach(e -> { + if(prime(e)){ + if(h1.get(e) == null) h1.put(e, 1); + else h1.put(e, h1.get(e)+1); + } + }); + a2.forEach(e -> { + if(prime(e)){ + if(h2.get(e) == null) h2.put(e, 1); + else h2.put(e, h2.get(e)+1); + } + }); + h1.forEach((k, v) -> { + if(h2.get(k) != null){ + System.out.printf("%d %d %d\n", k, v, h2.get(k)); + } + }); + } +} + diff --git a/J07017 - LỚP PAIR (generic).java b/J07017 - LỚP PAIR (generic).java new file mode 100644 index 0000000..65a41c3 --- /dev/null +++ b/J07017 - LỚP PAIR (generic).java @@ -0,0 +1,65 @@ +package nyagami; + +import java.util.*; +import java.io.*; +public class test{ + + static boolean prime(Integer x){ + if(x<2) return false; + if(x==2) return true; + if(x%2==0) return false; + Integer can = (int)Math.sqrt(x.doubleValue()); + for(Integer i=3; i<=can; i+=2){ + if(x%i==0) return false; + } + return true; + } + + static class Pair{ + public K a; + public V b; + public Pair(K key, V value){ + a=key;b=value; + } + public boolean isPrime(){ + return prime((Integer) a) && prime((Integer) b); + } + public String toString(){ + return a.toString()+" "+b.toString(); + } + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("DATA.in")); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + boolean check = false; + for(int i = 2; i <= 2*Math.sqrt(n); i++){ + Pair p = new Pair<>(i, n-i); + if(p.isPrime()){ + System.out.println(p); + check = true; + break; + } + } + if(!check) System.out.println(-1); + } + } + public static void main7034472(String[] args) throws IOException { + Scanner sc = new Scanner(new File("DATA.in")); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + boolean check = false; + for(int i = 2; i <= 2*Math.sqrt(n); i++){ + Pair p = new Pair<>(i, n-i); + if(p.isPrime()){ + System.out.println(p); + check = true; + break; + } + } + if(!check) System.out.println(-1); + } + } +} diff --git a/J07018 - CHUẨN HÓA DANH SÁCH SINH VIÊN.java b/J07018 - CHUẨN HÓA DANH SÁCH SINH VIÊN.java new file mode 100644 index 0000000..930f604 --- /dev/null +++ b/J07018 - CHUẨN HÓA DANH SÁCH SINH VIÊN.java @@ -0,0 +1,50 @@ +import java.util.*; +import java.io.*; +public class Main { + + static String cleanName(String s) { + String[] a = s.trim().split("\\s+"); + for (int i = 0; i < a.length; i++) { + a[i] = Character.toString(a[i].charAt(0)).toUpperCase() + a[i].substring(1).toLowerCase(); + } + return String.join(" ", a); + } + + static String cleanDate(String s) { + String[] a = s.split("/"); + for (int i = 0; i <= 1; i++) { + a[i] = String.format("%02d", Integer.parseInt(a[i])); + } + return String.join("/", a); + } + + static class ob { + String code, name, cl, date; + Double gpa; + + public ob(int i, String name, String cl, String date, double gpa) { + this.code = "B20DCCN" + String.format("%03d", i); + this.name = cleanName(name); + this.cl = cl; + this.date = cleanDate(date); + this.gpa = gpa; + } + + @Override + public String toString() { + return code + " " + name + " " + cl + " " + date + " " + String.format("%.02f", gpa); + } + } + + public static void main(String[] args) throws IOException { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(new File("SINHVIEN.in")); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + sc.nextLine(); + a.add(new ob(i + 1, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextDouble())); + } + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07019 - HÓA ĐƠN - 1.java b/J07019 - HÓA ĐƠN - 1.java new file mode 100644 index 0000000..1918efc --- /dev/null +++ b/J07019 - HÓA ĐƠN - 1.java @@ -0,0 +1,88 @@ +import java.util.*; +import java.io.*; +public class non { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class stuff { + String code, name; + int l1, l2; + + public stuff(String m, String n, int x, int y) { + code = m; + name = n; + l1 = x; + l2 = y; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + + public int getPrice(String s) { + if (s.charAt(2) == '1') + return l1; + return l2; + } + } + + static class bill { + String code, name; + int cnt, off, sum, fin; + + public bill(int i, String c, String name, int count, int price) { + code = c + '-' + String.format("%03d", i); + this.name = name; + cnt = count; + sum = price * cnt; + if (cnt >= 150) { + off = sum / 2; + } else if (cnt >= 100) { + off = sum * 3 / 10; + } else if (cnt >= 50) { + off = sum * 15 / 100; + }else off = 0; + + fin = sum - off; + } + + @Override + public String toString() { + return code + ' ' + name + ' ' + off + ' ' + fin; + } + } + + public static void main(String[] args) throws IOException { + Scanner s_sc = new Scanner(new File("DATA1.in")); + Scanner b_sc = new Scanner(new File("DATA2.in")); + int n = s_sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < n; i++) { + s_sc.nextLine(); + a.add(new stuff(s_sc.nextLine(), s_sc.nextLine(), s_sc.nextInt(), s_sc.nextInt())); + } + int m = b_sc.nextInt(); + ArrayList b = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + String code = b_sc.next(); + int cnt = b_sc.nextInt(); + stuff x = a.get(0); + for (int j = 0; j < n; j++) { + if (a.get(j).isStuff(code)) { + x = a.get(j); + break; + } + } + b.add(new bill(i, code, x.name, cnt, x.getPrice(code))); + } + b.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J07020 - HÓA ĐƠN - 2.java b/J07020 - HÓA ĐƠN - 2.java new file mode 100644 index 0000000..f3680ed --- /dev/null +++ b/J07020 - HÓA ĐƠN - 2.java @@ -0,0 +1,109 @@ +import java.io.*; +import java.util.*; + +public class non { + static String stdName(String s) { + String[] n = s.toLowerCase().trim().split("\\s+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static class stuff { + String code, name, unit; + long l1, l2; + + public stuff(int i, String n, String m, long x, long y) { + code = "MH" + String.format("%03d", i); + name = n; + unit = m; + l1 = x; + l2 = y; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + } + + static class person { + String code, name, gender, date, address; + + public person(int i, String n, String g, String d, String a) { + code = "KH" + String.format("%03d", i); + name = n; + gender = g; + date = d; + address = a; + } + + public boolean isStuff(String c) { + return c.startsWith(code); + } + + } + + static class bill { + stuff s; + String code; + person p; + long sum, cnt; + + public bill(int i, stuff a, person b, long cnt) { + code = "HD" + String.format("%03d", i); + s = a; + p = b; + this.cnt = cnt; + sum = s.l2 * cnt; + } + + @Override + public String toString() { + return code + ' ' + p.name + ' ' + p.address + ' ' + s.name + ' ' + s.unit + ' ' + s.l1 + ' ' + s.l2 + ' ' + + cnt + ' ' + sum; + } + } + + public static void main(String[] args) throws IOException { + Scanner kh_sc = new Scanner(new File("KH.in")); + Scanner mh_sc = new Scanner(new File("MH.in")); + Scanner hd_sc = new Scanner(new File("HD.in")); + int n = kh_sc.nextInt(); + ArrayList p = new ArrayList<>(); + kh_sc.nextLine(); + for (int i = 1; i <= n; i++) { + p.add(new person(i, kh_sc.nextLine(), kh_sc.nextLine(), kh_sc.nextLine(), kh_sc.nextLine())); + } + int m = mh_sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + mh_sc.nextLine(); + a.add(new stuff(i, mh_sc.nextLine(), mh_sc.nextLine(), mh_sc.nextLong(), mh_sc.nextLong())); + } + int k = hd_sc.nextInt(); + ArrayList b = new ArrayList<>(); + for (int i = 1; i <= k; i++) { + String pcode = hd_sc.next(); + String scode = hd_sc.next(); + long cnt = hd_sc.nextLong(); + stuff s = a.get(0); + person per = p.get(0); + for (int j = 0; j < n; j++) { + if (p.get(j).isStuff(pcode)) { + per = p.get(j); + } + } + for (int j = 0; j < m; j++) { + if (a.get(j).isStuff(scode)) { + s = a.get(j); + } + } + b.add(new bill(i, s, per, cnt)); + } + b.forEach(e -> { + System.out.println(e); + }); + } +} diff --git a/J07021 - CHUẨN HÓA XÂU HỌ TÊN TRONG FILE.java b/J07021 - CHUẨN HÓA XÂU HỌ TÊN TRONG FILE.java new file mode 100644 index 0000000..c7a5bc6 --- /dev/null +++ b/J07021 - CHUẨN HÓA XÂU HỌ TÊN TRONG FILE.java @@ -0,0 +1,28 @@ +import java.util.Scanner; +import java.io.File; +import java.io.IOException; +public class Main{ + static char up(char x){ + if('a'<=x && x<='z') return (char)((int)x-32); + return x; + } + static String re(String name){ + String[] a = name.split("[' ']+"); + String r = ""; + for(int i=0; i a = new ArrayList<>(); + while(sc.hasNext()){ + String s; + s = sc.next(); + try{ + int t = Integer.parseInt(s); + }catch(NumberFormatException e){ + a.add(s); + } + } + a.sort(new Comparator() { + @Override + public int compare(String a, String b){ + return a.compareTo(b); + } + }); + a.forEach(s -> System.out.print(s+" ")); + } +} diff --git a/J07023 - NGUYÊN TỐ VÀ THUẬN NGHỊCH.java b/J07023 - NGUYÊN TỐ VÀ THUẬN NGHỊCH.java new file mode 100644 index 0000000..7670506 --- /dev/null +++ b/J07023 - NGUYÊN TỐ VÀ THUẬN NGHỊCH.java @@ -0,0 +1,63 @@ +import java.io.*; +import java.util.*; + +public class non { + + static boolean tn(int x) { + String s = String.format("%d", x); + for (int i = 0; i < s.length() / 2; i++) { + if (s.charAt(i) != s.charAt(s.length() - 1 - i)) + return false; + } + s = null; + return true; + } + + static int N = 10000; + static int[] nt = new int[N+5]; + + public static void main(String[] args) throws IOException, ClassNotFoundException { + for (int i = 2; i <= N; i++) + nt[i] = 1; + for (int i = 2; i <= (int) Math.sqrt(N); i++) { + if (nt[i] == 1) { + for (int u = i; u <= N / i; u++) + nt[i * u] = 0; + } + } + ObjectInputStream o1 = new ObjectInputStream(new FileInputStream("DATA1.in")); + ArrayList a1 = (ArrayList) o1.readObject(); + o1.close(); + TreeMap h1 = new TreeMap<>(); + while (!a1.isEmpty()) { + int e = a1.get(a1.size()-1); + a1.remove(a1.size() - 1); + if (nt[e]==1 && tn(e)) { + if (h1.get(e) == null) + h1.put(e, 1); + else + h1.put(e, h1.get(e) + 1); + } + } + + ObjectInputStream o2 = new ObjectInputStream(new FileInputStream("DATA2.in")); + ArrayList a2 = (ArrayList) o2.readObject(); + o2.close(); + TreeMap h2 = new TreeMap<>(); + while (!a2.isEmpty()) { + int e = a2.get(a2.size() - 1); + a2.remove(a2.size() - 1); + if (nt[e]==1 && tn(e)) { + if (h2.get(e) == null) + h2.put(e, 1); + else + h2.put(e, h2.get(e) + 1); + } + } + h1.forEach((k, v) -> { + if (h2.get(k) != null) { + System.out.printf("%d %d %d\n", k, v, h2.get(k)); + } + }); + } +} diff --git a/J07024 - HIỆU CỦA HAI TẬP TỪ.java b/J07024 - HIỆU CỦA HAI TẬP TỪ.java new file mode 100644 index 0000000..06e0834 --- /dev/null +++ b/J07024 - HIỆU CỦA HAI TẬP TỪ.java @@ -0,0 +1,52 @@ +import java.io.File; +import java.io.IOException; +import java.util.*; + +public class Main { + static class WordSet { + TreeSet a; + + public WordSet(String filename) throws IOException { + Scanner sc = new Scanner(new File(filename)); + String s = ""; + while (sc.hasNextLine()) + s += sc.nextLine() + " "; + a = new TreeSet<>(); + String[] r = s.toLowerCase().trim().split("\\s+"); + for (int i = 0; i < r.length; i++) + a.add(r[i]); + } + + public WordSet() { + a = new TreeSet<>(); + } + + public WordSet difference(WordSet b) { + WordSet r = new WordSet(); + a.forEach(e -> { + if (!b.a.contains(e)) + r.a.add(e); + }); + return r; + } + + @Override + public String toString() { + return String.join(" ", a); + } + } + + public static void main(String[] args) throws IOException { + WordSet s1 = new WordSet("DATA1.in"); + WordSet s2 = new WordSet("DATA2.in"); + System.out.println(s1.difference(s2)); + System.out.println(s2.difference(s1)); + } + public static void main1951045(String[] args) throws IOException { + WordSet s1 = new WordSet("DATA1.in"); + WordSet s2 = new WordSet("DATA2.in"); + System.out.println(s1.difference(s2)); + System.out.println(s2.difference(s1)); + } +} + diff --git a/J07025 - DANH SÁCH KHÁCH HÀNG TRONG FILE.java b/J07025 - DANH SÁCH KHÁCH HÀNG TRONG FILE.java new file mode 100644 index 0000000..01476b4 --- /dev/null +++ b/J07025 - DANH SÁCH KHÁCH HÀNG TRONG FILE.java @@ -0,0 +1,58 @@ +import java.util.*; +import java.io.*; +import java.text.*; +public class Main { + + static String cleanName(String s) { + String[] a = s.trim().split("\\s+"); + for (int i = 0; i < a.length; i++) { + a[i] = Character.toString(a[i].charAt(0)).toUpperCase() + a[i].substring(1).toLowerCase(); + } + return String.join(" ", a); + } + + static String cleanDate(String s) { + String[] a = s.split("/"); + for (int i = 0; i <= 1; i++) { + a[i] = String.format("%02d", Integer.parseInt(a[i])); + } + return String.join("/", a); + } + + static class ob { + String code, name, gender, strdate, address; + Long date; + + public ob(int i, String name, String gender, String date, String address) { + this.code = "KH" + String.format("%03d", i); + this.name = cleanName(name); + this.gender = gender; + this.strdate = cleanDate(date); + this.address = address; + try{ + SimpleDateFormat f = new SimpleDateFormat("dd/mm/yyyy"); + this.date = f.parse(date).getTime(); + } catch (ParseException e) { + + } + } + + @Override + public String toString() { + return code + " " + name + " " + gender + " " + address + " " + strdate; + } + } + + public static void main(String[] args) throws IOException { + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(new File("KHACHHANG.in")); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for (int i = 0; i < n; i++) { + a.add(new ob(i + 1, sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine())); + } + a.sort((ob x, ob y) -> x.date.compareTo(y.date)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07027 - QUẢN LÝ BÀI TẬP NHÓM.java b/J07027 - QUẢN LÝ BÀI TẬP NHÓM.java new file mode 100644 index 0000000..73f9bf1 --- /dev/null +++ b/J07027 - QUẢN LÝ BÀI TẬP NHÓM.java @@ -0,0 +1,59 @@ +import java.util.*; +import java.io.*; +public class Main { + static class bt{ + int code; + String name; + public bt(int code, String name){ + this.code = code; + this.name = name; + } + } + static class sv{ + bt o; + String code, name, sdt; + public sv(String code, String name, String sdt){ + this.code = code; + this.name = name; + this.sdt = sdt; + } + + @Override + public String toString(){ + return code + " " + name + " " + sdt + " " + o.code + " " + o.name; + } + } + + public static void main(String[] args) throws IOException { + Scanner sc_sv = new Scanner(new File("SINHVIEN.in")); + Scanner sc_bt = new Scanner(new File("BAITAP.in")); + Scanner sc_gr = new Scanner(new File("NHOM.in")); + HashMap hsv = new HashMap<>(); + HashMap hbt = new HashMap<>(); + ArrayList a = new ArrayList<>(); + + int n = sc_sv.nextInt(); + sc_sv.nextLine(); + for(int i=0;i0){ + String msv = sc_gr.next(); + int stt = sc_gr.nextInt(); + hsv.get(msv).o = hbt.get(stt); + } + + a.sort((sv x, sv y) -> x.code.compareTo(y.code)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07028 - TÍNH GIỜ CHUẨN.java b/J07028 - TÍNH GIỜ CHUẨN.java new file mode 100644 index 0000000..01190a8 --- /dev/null +++ b/J07028 - TÍNH GIỜ CHUẨN.java @@ -0,0 +1,65 @@ +import java.util.*; +import java.io.*; +public class giochuan{ + static class MH{ + String code, name; + public MH(String code, String name){ + this.code=code; + this.name=name; + } + } + + static class GV{ + String code, name; + Double sum; + public GV(String code, String name){ + this.code=code; + this.name=name; + this.sum=0.0; + } + @Override + public String toString(){ + return name + " " + String.format("%.2f", sum); + } + } + + static class bill{ + MH mh; + GV gv; + Double sum; + public bill(GV gv, MH mh, double sum){ + this.gv = gv; + this.mh = mh; + this.sum = sum; + } + + } + + public static void main(String[] args) throws IOException { + Scanner sc1 = new Scanner(new File("MONHOC.in")); + Scanner sc2 = new Scanner(new File("GIANGVIEN.in")); + Scanner sc3 = new Scanner(new File("GIOCHUAN.in")); + HashMap hm1 = new HashMap<>(); + HashMap hm2 = new HashMap<>(); + ArrayList a = new ArrayList<>(); + int n = sc1.nextInt(); + sc1.nextLine(); + for(int i=0;i System.out.println(e)); + } +} diff --git a/J07029 - SỐ NGUYÊN TỐ LỚN NHẤT TRONG FILE.java b/J07029 - SỐ NGUYÊN TỐ LỚN NHẤT TRONG FILE.java new file mode 100644 index 0000000..62b6703 --- /dev/null +++ b/J07029 - SỐ NGUYÊN TỐ LỚN NHẤT TRONG FILE.java @@ -0,0 +1,28 @@ +import java.util.*; +import java.io.*; + +public class Main{ + public static void main(String[] args) throws IOException, ClassNotFoundException{ + boolean[] f = new boolean[1000005]; + for(int i=2; i a = (ArrayList) ois.readObject(); + TreeMap hm = new TreeMap<>(); + a.forEach(e ->{ + if(f[e]){ + if(hm.get(e) == null) hm.put(e, 1); + else hm.put(e, hm.get(e)+1); + } + }); + for(int i=0; i<10; i++){ + int k = hm.lastKey(); + System.out.println(k + " " + hm.get(k)); + hm.remove(k); + } + } +} diff --git a/J07030 - CẶP SỐ NGUYÊN TỐ TRONG FILE - 1.java b/J07030 - CẶP SỐ NGUYÊN TỐ TRONG FILE - 1.java new file mode 100644 index 0000000..fad7b38 --- /dev/null +++ b/J07030 - CẶP SỐ NGUYÊN TỐ TRONG FILE - 1.java @@ -0,0 +1,25 @@ +import java.util.*; +import java.io.*; + +public class Main{ + public static void main(String[] args) throws IOException, ClassNotFoundException{ + boolean[] f = new boolean[1000005]; + for(int i=2; i a1 = (ArrayList) o1.readObject(); + ArrayList a2 = (ArrayList) o2.readObject(); + TreeSet t = new TreeSet<>(a1); + t.forEach(e -> { + if(f[e] && n-e > e && f[n-e]){ + if(a2.contains(n-e)) System.out.println(e + " " + (n-e)); + } + }); + } +} diff --git a/J07031 - CẶP SỐ NGUYÊN TỐ TRONG FILE 2.java b/J07031 - CẶP SỐ NGUYÊN TỐ TRONG FILE 2.java new file mode 100644 index 0000000..a014ef1 --- /dev/null +++ b/J07031 - CẶP SỐ NGUYÊN TỐ TRONG FILE 2.java @@ -0,0 +1,26 @@ +import java.util.*; +import java.io.*; + +public class Main{ + public static void main(String[] args) throws IOException, ClassNotFoundException{ + boolean[] f = new boolean[1000005]; + for(int i=2; i a1 = (ArrayList) o1.readObject(); + ArrayList a2 = (ArrayList) o2.readObject(); + TreeSet t = new TreeSet<>(a1); + t.forEach(e1 -> { + int e2 = n - e1; + if(e2 > e1 && f[e1] && f[e2] && a1.contains(e2) && !a2.contains(e1) && !a2.contains(e2)){ + System.out.println(e1 + " " + e2); + } + }); + } +} diff --git a/J07032 - SỐ THUẬN NGHỊCH TRONG FILE.java b/J07032 - SỐ THUẬN NGHỊCH TRONG FILE.java new file mode 100644 index 0000000..91b7209 --- /dev/null +++ b/J07032 - SỐ THUẬN NGHỊCH TRONG FILE.java @@ -0,0 +1,48 @@ +import java.util.*; +import java.io.*; + +public class Main{ + static boolean check(Integer x){ + String s = x.toString(); + for(int i=0;i 1){ + for(int i=0; i a1 = (ArrayList) o1.readObject(); + ArrayList a2 = (ArrayList) o2.readObject(); + HashMap h1 = new HashMap<>(); + HashMap h2 = new HashMap<>(); + a1.forEach(e -> { + if(check(e)){ + if(h1.get(e) == null) h1.put(e, 1); + else h1.put(e, h1.get(e)+1); + } + }); + a2.forEach(e -> { + if(check(e)){ + if(h2.get(e) == null) h2.put(e, 1); + else h2.put(e, h2.get(e)+1); + } + }); + TreeMap ans = new TreeMap<>(); + h1.forEach((k,v) -> { + if(h2.get(k) != null) ans.put(k, v + h2.get(k)); + }); + for(int i=0;i<10;i++){ + if(ans.isEmpty()) break; + System.out.println(ans.firstKey() + " " + ans.get(ans.firstKey())); + ans.remove(ans.firstKey()); + } + } +} diff --git a/J07033 - DANH SÁCH SINH VIÊN TRONG FILE - 1.java b/J07033 - DANH SÁCH SINH VIÊN TRONG FILE - 1.java new file mode 100644 index 0000000..aa7bfab --- /dev/null +++ b/J07033 - DANH SÁCH SINH VIÊN TRONG FILE - 1.java @@ -0,0 +1,58 @@ +import java.util.Scanner; +import java.io.File; +import java.io.IOException; +import java.util.TreeSet; + +public class Main{ + static char up(char x){ + if('a'<=x && x<='z') return (char)((int)x-32); + return x; + } + static String re(String name){ + String[] a = name.split("[' ']+"); + String r = ""; + for(int i=0; i 0) return true; + return false; + } + public String toString(){ + return code + " " + name + method + " " + mail; + } + } + public static void main(String[] args)throws IOException{ + Scanner sc = new Scanner(new File("SINHVIEN.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + student[] a = new student[n]; + sc.nextLine(); + for(int i=0; i 0) return true; + return false; + } + public String toString(){ + return code + " " + name + " " + method; + } + } + public static void main(String[] args)throws IOException{ + Scanner sc = new Scanner(new File("MONHOC.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + sub[] a = new sub[n]; + sc.nextLine(); + for(int i=0; i hsv = new HashMap<>(); + HashMap hmh = new HashMap<>(); + int nsv = sc_sv.nextInt(); + sc_sv.nextLine(); + for(int i=0;i a = new ArrayList<>(); + for(int i=0;i { + if(x.Point == y.Point) return x.sv.code.compareTo(y.sv.code); + return y.Point.compareTo(x.Point); + }); + int q = sc_bd.nextInt(); + while(q-->0){ + String code = sc_bd.next(); + System.out.printf("BANG DIEM MON %s:\n", hmh.get(code)); + a.forEach(e -> { + if(e.mh.code.compareTo(code) == 0) System.out.println(e); + }); + } + } +} diff --git a/J07036 - BẢNG ĐIỂM THEO LỚP.java b/J07036 - BẢNG ĐIỂM THEO LỚP.java new file mode 100644 index 0000000..d8801a0 --- /dev/null +++ b/J07036 - BẢNG ĐIỂM THEO LỚP.java @@ -0,0 +1,91 @@ +import java.util.*; +import java.io.*; +import java.text.*; +public class Main { + + static String cleanName(String name){ + String[] a = name.trim().split("\\s+"); + for(int i=0;i hsv = new HashMap<>(); + HashMap hmh = new HashMap<>(); + int nsv = sc_sv.nextInt(); + sc_sv.nextLine(); + for(int i=0;i a = new ArrayList<>(); + for(int i=0;i { + if(x.mh.code.compareTo(y.mh.code) == 0) return x.sv.code.compareTo(y.sv.code); + return x.mh.code.compareTo(y.mh.code); + }); + int q = sc_bd.nextInt(); + while(q-->0){ + String code = sc_bd.next(); + System.out.printf("BANG DIEM lop %s:\n", code); + a.forEach(e -> { + if(e.sv.cl.compareTo(code) == 0) System.out.println(e); + }); + } + } +} diff --git a/J07037 - DANH SÁCH DOANH NGHIỆP.java b/J07037 - DANH SÁCH DOANH NGHIỆP.java new file mode 100644 index 0000000..9a73b45 --- /dev/null +++ b/J07037 - DANH SÁCH DOANH NGHIỆP.java @@ -0,0 +1,43 @@ +import java.util.Scanner; +import java.io.File; +import java.io.IOException; +import java.util.TreeSet; + +public class Main{ + static class student{ + String code, name, method, mail; + public student(String c, String n, String m){ + code=c; + name=n; + method=m; + } + public boolean big(student b){ + if(code.compareTo(b.code) > 0) return true; + return false; + } + public String toString(){ + return code + " " + name + " " + method; + } + } + public static void main(String[] args)throws IOException{ + Scanner sc = new Scanner(new File("DN.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + student[] a = new student[n]; + sc.nextLine(); + for(int i=0; i a; + String code, name; + int max; + + public dn(String code, String name, int max) { + a = new ArrayList<>(); + this.code = code; + this.name = name; + this.max = max; + } + + @Override + public String toString() { + String s = String.format("DANH SACH THUC TAP TAI %s:\n", name); + String[] arr = new String[Math.min(a.size(), max)]; + for (int i = 0; i < arr.length; i++) + arr[i] = a.get(i).toString(); + return s + String.join("\n", arr); + } + } + + public static void main(String[] args) throws IOException { + Scanner sv_sc = new Scanner(new File("SINHVIEN.in")); + Scanner dn_sc = new Scanner(new File("DN.in")); + Scanner tt_sc = new Scanner(new File("THUCTAP.in")); + HashMap hsv = new HashMap<>(); + HashMap hdn = new HashMap<>(); + int nsv = sv_sc.nextInt(); + sv_sc.nextLine(); + for (int i = 0; i < nsv; i++) { + sv x = new sv(sv_sc.nextLine(), sv_sc.nextLine(), sv_sc.nextLine(), sv_sc.nextLine()); + hsv.put(x.code, x); + } + sv_sc.close(); + int ndn = dn_sc.nextInt(); + for (int i = 0; i < ndn; i++) { + dn_sc.nextLine(); + dn x = new dn(dn_sc.nextLine(), dn_sc.nextLine(), dn_sc.nextInt()); + hdn.put(x.code, x); + } + dn_sc.close(); + int ntt = tt_sc.nextInt(); + for (int i = 0; i < ntt; i++) { + String sv_code = tt_sc.next(); + String dn_code = tt_sc.next(); + dn x = hdn.get(dn_code); + x.a.add(hsv.get(sv_code)); + } + hdn.forEach((k, v) -> { + v.a.sort((sv x, sv y) -> x.code.compareTo(y.code)); + }); + int q = tt_sc.nextInt(); + while (q-- > 0) { + String code = tt_sc.next(); + System.out.println(hdn.get(code)); + } + } +} diff --git a/J07040 - LIỆT KÊ THEO THỨ TỰ XUẤT HIỆN.java b/J07040 - LIỆT KÊ THEO THỨ TỰ XUẤT HIỆN.java new file mode 100644 index 0000000..49d0428 --- /dev/null +++ b/J07040 - LIỆT KÊ THEO THỨ TỰ XUẤT HIỆN.java @@ -0,0 +1,28 @@ +import java.util.*; +import java.io.*; +import java.nio.charset.StandardCharsets; + +public class Main{ + public static void main(String[] arg)throws IOException, ClassNotFoundException { + ObjectInputStream o = new ObjectInputStream(new FileInputStream("NHIPHAN.in")); + ArrayList a = (ArrayList) o.readObject(); + ArrayList b = new ArrayList<>(); + a.forEach(s -> { + InputStream is = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8)); + Scanner ss = new Scanner(is); + while(ss.hasNext()){ + String x = ss.next().toLowerCase(); + if(!b.contains(x)) b.add(x); + } + }); + ArrayList doc = new ArrayList<>(); + Scanner sc = new Scanner(new File("VANBAN.in")); + while(sc.hasNext()){ + String s = sc.next().toLowerCase(); + if(!doc.contains(s)) doc.add(s); + } + doc.forEach(e -> { + if(b.contains(e)) System.out.println(e); + }); + } +} diff --git a/J07041 - LIỆT KÊ CẶP SỐ - 1.java b/J07041 - LIỆT KÊ CẶP SỐ - 1.java new file mode 100644 index 0000000..983f92e --- /dev/null +++ b/J07041 - LIỆT KÊ CẶP SỐ - 1.java @@ -0,0 +1,43 @@ +test/Main.java +package test; + +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException, ClassNotFoundException { + ObjectInputStream o = new ObjectInputStream(new FileInputStream("DATA.in")); + ArrayList a = (ArrayList) o.readObject(); + Collections.sort(a); + HashSet h = new HashSet<>(); + for(Pair i:a){ + if(i.getFirst() < i.getSecond() && !h.contains(i.toString())){ + h.add(i.toString()); + System.out.println(i); + } + } + } +} + +test/Pair.java +package test; +import java.io.*; + +public class Pair implements Serializable, Comparable{ + private int first, second; + + public Pair(int first, int second){ + this.first = first; + this.second = second; + } + public int getFirst(){return first;} + public int getSecond(){return second;} + public int compareTo(Pair o) { + return this.first - o.first; + } + + public String toString(){ + return "(" + first + ", " + second + ")"; + } +} + diff --git a/J07042 - LIỆT KÊ CẶP SỐ - 2.java b/J07042 - LIỆT KÊ CẶP SỐ - 2.java new file mode 100644 index 0000000..4803f13 --- /dev/null +++ b/J07042 - LIỆT KÊ CẶP SỐ - 2.java @@ -0,0 +1,53 @@ +test/Main.java +package test; + +import java.io.*; +import java.util.*; + +public class Main { + + static int gcd(int a, int b){ + if(b==0) return a; + return gcd(b, a%b); + } + + static boolean check(int a, int b){ + if(a>=b) return false; + return gcd(a, b) == 1; + } + public static void main(String[] args) throws IOException, ClassNotFoundException { + ObjectInputStream o = new ObjectInputStream(new FileInputStream("DATA.in")); + ArrayList a = (ArrayList) o.readObject(); + Collections.sort(a); + HashSet h = new HashSet<>(); + for(Pair i:a){ + if(check(i.getFirst(), i.getSecond()) && !h.contains(i.toString())){ + h.add(i.toString()); + System.out.println(i); + } + } + } +} + +test/Pair.java +package test; +import java.io.*; + +public class Pair implements Serializable, Comparable{ + private int first, second; + + public Pair(int first, int second){ + this.first = first; + this.second = second; + } + public int getFirst(){return first;} + public int getSecond(){return second;} + public int compareTo(Pair o) { + return this.first - o.first; + } + + public String toString(){ + return "(" + first + ", " + second + ")"; + } +} + diff --git a/J07045 - LOẠI PHÒNG.java b/J07045 - LOẠI PHÒNG.java new file mode 100644 index 0000000..cefde77 --- /dev/null +++ b/J07045 - LOẠI PHÒNG.java @@ -0,0 +1,56 @@ +import java.util.*; +import java.io.*; +import java.nio.charset.StandardCharsets; + +public class Main{ + static class LoaiPhong implements Comparable{ + String p, name; + public LoaiPhong(String s){ + p = s; + InputStream is = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8)); + Stack st = new Stack<>(); + Scanner sc = new Scanner(is); + sc.next(); + while(sc.hasNext()){ + st.push(sc.next()); + } + st.pop(); + st.pop(); + name = ""; + while(!st.empty()){ + name = st.pop() + " " + name; + } + } + public String toString(){ + return p; + } + @Override + public int compareTo(LoaiPhong o) { + return name.compareTo(o.name); + } + } + public static void main(String[] args) throws IOException { + ArrayList ds = new ArrayList<>(); + Scanner in = new Scanner(new File("PHONG.in")); + int n = Integer.parseInt(in.nextLine()); + while(n-->0){ + ds.add(new LoaiPhong(in.nextLine())); + } + Collections.sort(ds); + for(LoaiPhong tmp : ds){ + System.out.println(tmp); + } + } + public static void main6777130(String[] args) throws IOException { + ArrayList ds = new ArrayList<>(); + Scanner in = new Scanner(new File("PHONG.in")); + int n = Integer.parseInt(in.nextLine()); + while(n-->0){ + ds.add(new LoaiPhong(in.nextLine())); + } + Collections.sort(ds); + for(LoaiPhong tmp : ds){ + System.out.println(tmp); + } + } +} diff --git a/J07046 - DANH SÁCH LƯU TRÚ.java b/J07046 - DANH SÁCH LƯU TRÚ.java new file mode 100644 index 0000000..5f6712a --- /dev/null +++ b/J07046 - DANH SÁCH LƯU TRÚ.java @@ -0,0 +1,46 @@ +import java.util.*; +import java.io.*; +import java.text.*; + +public class Main{ + static long getTime(String s1, String s2) throws ParseException{ + SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy"); + return f.parse(s2).getTime() - f.parse(s1).getTime(); + } + static class kh{ + String code, name, room; + long d; + public kh(int i, String n, String r, String cd, String ld){ + code = String.format("%02d", i); + code = "KH" + code; + name = n; + room = r; + try{ + d = getTime(cd, ld) / (1000 * 60 * 60 * 24) % 365; + }catch(ParseException e){ + + } + } + public String toString(){ + return String.format("%s %s %s %d", code, name, room, d); + } + } + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("KHACH.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0; i() { + @Override + public int compare(kh a, kh b){ + return (int)(b.d - a.d); + } + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07047 - QUẢN LÝ KHÁCH SẠN.java b/J07047 - QUẢN LÝ KHÁCH SẠN.java new file mode 100644 index 0000000..2c939b1 --- /dev/null +++ b/J07047 - QUẢN LÝ KHÁCH SẠN.java @@ -0,0 +1,70 @@ +import java.util.*; +import java.io.*; +import java.text.*; + +public class Main{ + + static class phong{ + String c; + double price, phi; + public phong(String c,double price,double phi ){ + this.c = c; + this.price = price; + this.phi = phi; + } + } + + static class kh{ + phong o; + String code, name, room; + Long day; + Double total, plus, fin; + public kh(phong o,int i, String name, String room, String d1, String d2){ + this.o = o; + this.code = String.format("KH%02d",i); + this.name = name; + this.room = room; + SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy"); + try{ + this.day = (f.parse(d2).getTime() - f.parse(d1).getTime())/1000/3600/24; + }catch(ParseException e){ + + } + this.total = o.price * this.day; + if(this.day == 0) this.total = o.price; + if(this.day > 30) this.total*=0.94; + else if(this.day >=20) this.total*=0.96; + else if(this.day >=10) this.total*=0.98; + this.plus = this.total * this.o.phi; + this.fin = this.total + this.plus; + } + + @Override + public String toString(){ + return code + " " + name + " " + room + " " + day + " " + String.format("%.2f", fin); + } + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("DATA.in")); + // Scanner sc = new Scanner(System.in); + HashMap hm = new HashMap<>(); + int n =sc.nextInt(); + for(int i=0;i a = new ArrayList<>(); + for(int i=0;i y.day.compareTo(x.day)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07048 - DANH SÁCH SẢN PHẨM – 2.java b/J07048 - DANH SÁCH SẢN PHẨM – 2.java new file mode 100644 index 0000000..1e74c1d --- /dev/null +++ b/J07048 - DANH SÁCH SẢN PHẨM – 2.java @@ -0,0 +1,38 @@ +import java.util.*; +import java.io.*; + +public class Main{ + + static class goods implements Comparable{ + String code, name; + int cost, time; + public goods(String c, String n, int x, int y){ + code = c; + name = n; + cost = x; + time = y; + } + + @Override + public int compareTo(goods o){ + if(cost == o.cost) return code.compareTo(o.code); + return o.cost - cost; + } + + public String toString(){ + return String.format("%s %s %d %d", code, name, cost, time); + } + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("SANPHAM.in")); + // Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + for(int i=0;i System.out.println(i)); + } +} diff --git a/J07049 - TÍNH NGÀY HẾT HẠN BẢO HÀNH.java b/J07049 - TÍNH NGÀY HẾT HẠN BẢO HÀNH.java new file mode 100644 index 0000000..e4e5320 --- /dev/null +++ b/J07049 - TÍNH NGÀY HẾT HẠN BẢO HÀNH.java @@ -0,0 +1,78 @@ +import java.util.*; +import java.io.*; +import java.text.*; +public class Main { + + static String outdate(String s, long time){ + String[] a = s.split("/"); + Long m = Long.parseLong(a[1]); + Long y = Long.parseLong(a[2]); + m += time; + y += m/12; + m%=12; + if(m==0){ + m=(long)12; + y--; + } + return String.format("%s/%02d/%04d", a[0], m, y); + } + + static class sp{ + String code, name; + Long price, time; + public sp(String code, String name, long price, long time){ + this.code = code; + this.name = name; + this.price = price; + this.time = time; + } + } + + static class kh{ + sp o; + String code, name, address, date, outdate; + Long sl, total; + Date time; + public kh(int i, String name, String address, sp o, long sl, String date){ + this.o = o; + this.code = String.format("KH%02d", i); + this.name = name; + this.address = address; + this.sl = sl; + this.date = date; + this.outdate = outdate(date, o.time); + this.total = sl * o.price; + SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy"); + try{ + this.time = f.parse(this.outdate); + }catch(ParseException e){ + + } + } + + @Override + public String toString(){ + return code + " " + name + " " + address + " " + o.code + " " + total + " " + outdate; + } + } + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("MUAHANG.in")); + // Scanner sc = new Scanner(System.in); + HashMap hm = new HashMap<>(); + int n = sc.nextInt(); + for(int i=0;i a = new ArrayList<>(); + for(int i=1;i<=m;i++){ + sc.nextLine(); + a.add(new kh(i, sc.nextLine(), sc.nextLine(), hm.get(sc.next()), sc.nextInt(), sc.next())); + } + a.sort((kh x, kh y) -> x.time.compareTo(y.time)); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07050 - SẮP XẾP MẶT HÀNG.java b/J07050 - SẮP XẾP MẶT HÀNG.java new file mode 100644 index 0000000..215994f --- /dev/null +++ b/J07050 - SẮP XẾP MẶT HÀNG.java @@ -0,0 +1,43 @@ +import java.util.*; +import java.io.*; + +public class Main{ + + static class goods implements Comparable{ + String code, name, type; + float buy, sell, pro; + + public goods(int i, String n, String t, float x, float y){ + code = Integer.toString(i); + while(code.length()<2) code = "0" + code; + code = "MH" + code; + name = n; + type = t; + buy = x; + sell = y; + pro = sell - buy; + } + + @Override + public int compareTo(goods o){ + return (int)(o.pro - pro); + } + + public String toString(){ + return String.format("%s %s %s %.2f", code, name, type, pro); + } + } + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("MATHANG.in")); + // Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + for(int i=0;i System.out.println(i)); + } +} diff --git a/J07051 - TÍNH TIỀN PHÒNG.java b/J07051 - TÍNH TIỀN PHÒNG.java new file mode 100644 index 0000000..05e20d2 --- /dev/null +++ b/J07051 - TÍNH TIỀN PHÒNG.java @@ -0,0 +1,66 @@ +import java.util.*; +import java.util.zip.DataFormatException; +import java.io.*; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +public class Main{ + static String stdName(String s){ + String[] n = s.toLowerCase().split("[' ']+"); + String r = ""; + for(int i=0; i a = new ArrayList<>(); + for(int i=1; i<=n; i++){ + sc.nextLine(); + a.add(new cus(i, sc.nextLine(), sc.nextInt(), fomartDay(sc.next()), fomartDay(sc.next()), sc.nextInt())); + } + Collections.sort(a, new Comparator() { + @Override + public int compare(cus a, cus b){ + return b.bill - a.bill; + } + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07052 - DANH SÁCH TRÚNG TUYỂN.java b/J07052 - DANH SÁCH TRÚNG TUYỂN.java new file mode 100644 index 0000000..24db209 --- /dev/null +++ b/J07052 - DANH SÁCH TRÚNG TUYỂN.java @@ -0,0 +1,76 @@ +package VaoRaFile; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Scanner; +/** + * + * @author Houta + */ +public class DanhSachTrungTuyen { + static double diemChuan ; + private static class ThiSinh implements Comparable{ + private String id,name; + private double scoreT,scoreL,scoreH,priorityScore,totalScore; + private String tt; + + ThiSinh(String id, String name, double scoreT, double scoreL, double scoreH) { + this.id = id; + this.name = chuanHoaTen(name); + this.scoreT = scoreT; + this.scoreL = scoreL; + this.scoreH = scoreH; + this.priorityScore = 0; + if(id.startsWith("KV1")) this.priorityScore = 0.5; + if(id.startsWith("KV2")) this.priorityScore = 1.0; + if(id.startsWith("KV3")) this.priorityScore = 2.5; + this.totalScore = scoreT*2+scoreL+scoreH+ this.priorityScore; + + } + static String chuanHoaTen(String s){ + s = s.trim().toLowerCase(); + String res = "" + Character.toUpperCase(s.charAt(0)); + for(int i=1; i< s.length();i++){ + if(Character.isLetter(s.charAt(i))){ + if(s.charAt(i-1) == ' ') res+= " "+ Character.toUpperCase(s.charAt(i)); + else res += s.charAt(i); + } + } + return res; + } + + @Override + public int compareTo(ThiSinh o) { + if(this.totalScoreo.totalScore) return -1; + return this.id.compareTo(o.id); + } + + void inThongTin(){ + System.out.print(this.id+' '+this.name+' '); + if((int)this.priorityScore == this.priorityScore ) System.out.printf("%.0f ",this.priorityScore); + else System.out.printf("%.1f ",this.priorityScore); + if((int)this.totalScore == this.totalScore ) System.out.printf("%.0f ",this.totalScore); + else System.out.printf("%.1f ",this.totalScore); + if(this.totalScore>=diemChuan) this.tt = "TRUNG TUYEN"; + else this.tt = "TRUOT"; + System.out.println(this.tt); + } + } + public static void main(String []args) throws FileNotFoundException{ + Scanner sc = new Scanner(new File("THISINH.in")); + ArrayList ds = new ArrayList<>(); + int t = sc.nextInt(); + while(t-->0){ + sc.nextLine(); + ds.add(new ThiSinh(sc.nextLine(),sc.nextLine(),sc.nextDouble(),sc.nextDouble(),sc.nextDouble())); + } + int k = sc.nextInt(); + Collections.sort(ds); + diemChuan = ds.get(k-1).totalScore; + System.out.printf("%.1f\n",diemChuan); + for(ThiSinh tmp : ds) + tmp.inThongTin(); + } +} diff --git a/J07053 - XÉT TUYỂN.java b/J07053 - XÉT TUYỂN.java new file mode 100644 index 0000000..2f272e8 --- /dev/null +++ b/J07053 - XÉT TUYỂN.java @@ -0,0 +1,63 @@ +import java.util.*; +import java.io.*; +import java.text.DecimalFormat; + +public class Main{ + static String stdDate(String s){ + String[] a = s.split("/"); + String r = ""; + for(String i:a){ + if(i.length() == 1) i = "0" + i; + r = r + i + '/'; + } + return r; + } + static String stdName(String s){ + String[] n = s.toLowerCase().split("[' ']+"); + String r = ""; + for(int i=0; i= 8 && b >= 8) plus = 1; + else if(a >= 7.5 && b >= 7.5) plus = 0.5; + else plus = 0; + sum = (int)(Math.round((lt + th) / 2 + plus)); + if(sum > 10) sum = 10; + if(sum >= 9) type = "Xuat sac"; + else if(sum == 8) type = "Gioi"; + else if(sum == 7) type = "Kha"; + else if(sum >= 5) type = "Trung binh"; + else type = "Truot"; + } + + @Override + public String toString(){ + return code + ' ' + name + age + ' ' + sum + ' ' + type; + } + } + public static void main(String[] arg)throws IOException{ + // Scanner sc = new Scanner(System.in); + Scanner sc = new Scanner(new File("XETTUYEN.in")); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=1; i<=n; i++){ + sc.nextLine(); + a.add(new person(i, sc.nextLine(), sc.next(), sc.nextDouble(), sc.nextDouble())); + } + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07054 - TÍNH ĐIỂM TRUNG BÌNH.java b/J07054 - TÍNH ĐIỂM TRUNG BÌNH.java new file mode 100644 index 0000000..845b477 --- /dev/null +++ b/J07054 - TÍNH ĐIỂM TRUNG BÌNH.java @@ -0,0 +1,54 @@ +import java.util.*; +import java.io.*; + +public class Main{ + static String stdName(String s){ + String[] n = s.toLowerCase().split("[' ']+"); + String r = ""; + for(int i=0; i a = new ArrayList<>(); + for(int i=1; i<=n; i++){ + sc.nextLine(); + a.add(new person(i, sc.nextLine(), sc.nextDouble(), sc.nextDouble(), sc.nextDouble())); + } + Collections.sort(a, new Comparator() { + @Override + public int compare(person a, person b){ + if(a.tbc.compareTo(b.tbc) == 0) return a.code.compareTo(b.code); + return -a.tbc.compareTo(b.tbc); + } + }); + + int rank = 1; + for(int i=0; i0 && a.get(i).tbc.compareTo(a.get(i-1).tbc) == 0){ + a.get(i).rank = a.get(i-1).rank; + rank++; + }else{ + a.get(i).rank = rank; + rank++; + } + person x = a.get(i); + System.out.println(x.code + ' ' + x.name + x.tbc + ' ' + x.rank); + } + } +} diff --git a/J07055 - XẾP LOẠI.java b/J07055 - XẾP LOẠI.java new file mode 100644 index 0000000..09818c7 --- /dev/null +++ b/J07055 - XẾP LOẠI.java @@ -0,0 +1,52 @@ +import java.util.*; +import java.io.*; + +public class Main{ + static String stdName(String s){ + String[] n = s.toLowerCase().split("[' ']+"); + String r = ""; + for(int i=0; i=8) type = "GIOI"; + else if(tbc>=6.5) type = "KHA"; + else if(tbc>=5) type = "TRUNG BINH"; + else type = "KEM"; + TBC = String.format("%.2f", tbc); + } + + @Override + public String toString(){ + return code + ' ' + name + TBC + ' ' + type; + } + } + public static void main(String[] arg)throws IOException{ + // Scanner sc = new Scanner(System.in); + Scanner sc = new Scanner(new File("BANGDIEM.in")); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=1; i<=n; i++){ + sc.nextLine(); + a.add(new person(i, sc.nextLine(), sc.nextDouble(), sc.nextDouble(), sc.nextDouble())); + } + Collections.sort(a, new Comparator() { + @Override + public int compare(person a, person b){ + int c = a.TBC.compareTo(b.TBC); + if(c==0) return a.code.compareTo(b.code); + return -c; + } + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07056 - TÍNH TIỀN ĐIỆN.java b/J07056 - TÍNH TIỀN ĐIỆN.java new file mode 100644 index 0000000..698be89 --- /dev/null +++ b/J07056 - TÍNH TIỀN ĐIỆN.java @@ -0,0 +1,61 @@ +import java.util.*; +import java.io.*; + +public class Main { + static String stdName(String s) { + String[] n = s.toLowerCase().split("[' ']+"); + String r = ""; + for (int i = 0; i < n.length; i++) { + if (n[i].length() == 0) + continue; + r = r + Character.toString(n[i].charAt(0)).toUpperCase() + n[i].substring(1) + " "; + } + return r; + } + + static int dm(char c) { + if (c == 'A') + return 100; + if (c == 'B') + return 500; + return 200; + } + + static class kh { + String code, name; + int in, out, vat, sum; + + public kh(int i, String n, char c, int f, int l) { + code = String.format("KH%02d", i); + name = stdName(n); + int d = dm(c); + int e = l - f; + in = Math.min(e, d) * 450; + out = Math.max(0, e - d) * 1000; + vat = out / 20; + sum = in + out + vat; + } + @Override + public String toString() { + return code + ' ' + name + in + ' ' + out + ' ' + vat + ' ' + sum; + } + } + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("KHACHHANG.in")); + // Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int n = sc.nextInt(); + for (int i = 1; i <= n; i++) { + sc.nextLine(); + a.add(new kh(i, sc.nextLine(), sc.next().charAt(0), sc.nextInt(), sc.nextInt())); + } + Collections.sort(a, new Comparator() { + @Override + public int compare(kh a, kh b) { + return b.sum - a.sum; + } + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07057 - ĐIỂM TUYỂN SINH.java b/J07057 - ĐIỂM TUYỂN SINH.java new file mode 100644 index 0000000..f8ba7f5 --- /dev/null +++ b/J07057 - ĐIỂM TUYỂN SINH.java @@ -0,0 +1,97 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package J07057_DiemTuyenSinh; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Scanner; + +/** + * + * @author admin + */ +class ThiSinh{ + private String maTS, hoTen, danToc, khuVuc; + private float diemThi; + private static int id = 1; + public ThiSinh(String hoTen, String danToc, String khuVuc, float diemThi) { + this.maTS = "TS" + String.format("%02d", id++); + this.hoTen = hoTen; + this.danToc = danToc; + this.khuVuc = khuVuc; + this.diemThi = diemThi; + } + + public String getMaTS() { + return maTS; + } + public void chuanHoaTen(){ + String[] arr = this.hoTen.trim().split("\\s+"); + StringBuilder sb = new StringBuilder(); + for(String x : arr){ + sb.append(Character.toUpperCase(x.charAt(0))); + for(int j = 1; j < x.length(); j++){ + sb.append(Character.toLowerCase(x.charAt(j))); + } + sb.append(" "); + } + sb.deleteCharAt(sb.length() - 1); + this.hoTen = sb.toString(); + } + public float diemUuTien(){ + float diem = 0; + if("1".equals(this.khuVuc)) diem += 1.5; + else if("2".equals(this.khuVuc)) diem += 1; + if(!"Kinh".equals(this.danToc)) diem += 1.5; + return diem; + } + public float tongDiem(){ + return this.diemThi + this.diemUuTien(); + } + public String trangThai(){ + if(this.tongDiem() >= 20.5) return "Do"; + return "Truot"; + } + + @Override + public String toString(){ + return this.maTS + " " + this.hoTen + " " + String.format("%.1f", this.tongDiem()) + " " + this.trangThai(); + } +} +public class J07057 { + public static void main(String[] args) throws FileNotFoundException { + Scanner sc = new Scanner(new File("THISINH.in")); + int n = sc.nextInt(); + ArrayList list = new ArrayList<>(); + while(n-- > 0){ + sc.nextLine(); + String hoTen = sc.nextLine(); + float diemThi = sc.nextFloat(); + sc.nextLine(); + String danToc = sc.nextLine(); + String khuVuc = sc.next(); + ThiSinh ts = new ThiSinh(hoTen, danToc, khuVuc, diemThi); + ts.chuanHoaTen(); + list.add(ts); + } + Collections.sort(list, new Comparator(){ + @Override + public int compare(ThiSinh o1, ThiSinh o2) { + if(o2.tongDiem() == o1.tongDiem()) + return o1.getMaTS().compareTo(o2.getMaTS()); + if(o1.tongDiem() < o2.tongDiem()) + return 1; + return -1; + } + }); + for(ThiSinh x : list){ + System.out.println(x); + } + } +} diff --git a/J07058 - DANH SÁCH MÔN THI.java b/J07058 - DANH SÁCH MÔN THI.java new file mode 100644 index 0000000..20e95e5 --- /dev/null +++ b/J07058 - DANH SÁCH MÔN THI.java @@ -0,0 +1,42 @@ +import java.util.Scanner; +import java.io.File; +import java.io.IOException; +import java.util.TreeSet; + +public class Main{ + static class sub{ + String code, name, method; + public sub(String c, String n, String m){ + code=c; + name=n; + method=m; + } + public boolean big(sub b){ + if(code.compareTo(b.code) > 0) return true; + return false; + } + public String toString(){ + return code + " " + name + " " + method; + } + } + public static void main(String[] args)throws IOException{ + Scanner sc = new Scanner(new File("MONHOC.in")); + int n = sc.nextInt(); + sub[] a = new sub[n]; + sc.nextLine(); + for(int i=0; i a = new ArrayList<>(); + for(int i=1;i<=n;i++){ + a.add(new ob(i, sc.next(), sc.next(), sc.next())); + } + Collections.sort(a, (ob a1, ob b) -> { + if (a1.total == b.total) { + return a1.code.compareTo(b.code); + } + if (a1.total > b.total) { + return 1; + } + return -1; + }); + a.forEach(e -> System.out.println(e)); + } + +} diff --git a/J07060 - SẮP XẾP LỊCH THI.java b/J07060 - SẮP XẾP LỊCH THI.java new file mode 100644 index 0000000..ada6129 --- /dev/null +++ b/J07060 - SẮP XẾP LỊCH THI.java @@ -0,0 +1,83 @@ +import java.io.*; +import java.util.*; +import java.text.*; +public class Main { + + static class MT { + String code, name, method; + + public MT(String code, String name, String method) { + this.code = code; + this.name = name; + this.method = method; + } + } + + static class CA { + String code, date, time, room; + + public CA(int i, String date, String time, String room) { + this.code = String.format("C%03d", i); + this.date = date; + this.time = time; + this.room = room; + } + } + + static class L { + MT mt; + CA ca; + String code; + int sv; + Date date; + public L(MT mt, CA ca, String code, int sv) { + this.mt = mt; + this.ca = ca; + this.code = code; + this.sv = sv; + SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy hh:mm"); + try{ + this.date = f.parse(ca.date + " " + ca.time); + } catch (ParseException e) { + + } + } + + @Override + public String toString() { + return ca.date + " " + ca.time + " " + ca.room + " " + mt.name + " " + code + " " + sv; + } + } + + public static void main(String[] args) throws IOException { + Scanner sc1 = new Scanner(new File("MONTHI.in")); + Scanner sc2 = new Scanner(new File("CATHI.in")); + Scanner sc3 = new Scanner(new File("LICHTHI.in")); + HashMap hmt = new HashMap<>(); + HashMap hca = new HashMap<>(); + int n = sc1.nextInt(); + sc1.nextLine(); + for (int i = 0; i < n; i++) { + MT x = new MT(sc1.nextLine(), sc1.nextLine(), sc1.nextLine()); + hmt.put(x.code, x); + } + int m = sc2.nextInt(); + sc2.nextLine(); + for (int i = 0; i < m; i++) { + CA x = new CA(i + 1, sc2.nextLine(), sc2.nextLine(), sc2.nextLine()); + hca.put(x.code, x); + } + int k = sc3.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 0; i < k; i++) { + String ccode = sc3.next(); + String mcode = sc3.next(); + a.add(new L(hmt.get(mcode), hca.get(ccode), sc3.next(), sc3.nextInt())); + } + a.sort((L x, L y) -> { + if (x.date.compareTo(y.date) == 0) return x.ca.code.compareTo(y.ca.code); + return x.date.compareTo(y.date); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07071 - TÊN VIẾT TẮT.java b/J07071 - TÊN VIẾT TẮT.java new file mode 100644 index 0000000..5edd77b --- /dev/null +++ b/J07071 - TÊN VIẾT TẮT.java @@ -0,0 +1,73 @@ + /* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package test; +import java.util.*; +import java.io.*; + +/** + * + * @author GIGABYTE + */ +public class Test { + + /** + * @param args the command line arguments + * @throws java.io.IOException + */ + static class ob{ + String sys,full, first, last; + public ob(String name){ + sys=""; + full = name; + String[] s = name.split("\\s+"); + first = s[0]; + last = s[s.length -1]; + for (String item : s) { + sys += item.charAt(0); + } + }; + + public boolean suit(String s){ + String[] a = s.split("['.']"); + if(a.length != sys.length()) return false; + for(int i=0;i a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i { + if(x.last.compareTo(y.last) == 0) return x.first.compareTo(y.first); + return x.last.compareTo(y.last); + }); + int q = sc.nextInt(); + while(q-->0){ + String s = sc.next(); + for(int i=0;i a = new ArrayList<>(); + while(sc.hasNextLine()){ + a.add(new ob(sc.nextLine().toLowerCase())); + } + a.sort((ob x, ob y) -> { + if(x.last.compareTo(y.last) == 0){ + if(x.first.compareTo(y.first)==0) return x.mid.compareTo(y.mid); + return x.first.compareTo(y.first); + } + return x.last.compareTo(y.last); + }); + a.forEach(e->System.out.println(e)); + } + +} diff --git a/J07073 - ĐĂNG KÝ HÌNH THỨC GIẢNG DẠY.java b/J07073 - ĐĂNG KÝ HÌNH THỨC GIẢNG DẠY.java new file mode 100644 index 0000000..dc73910 --- /dev/null +++ b/J07073 - ĐĂNG KÝ HÌNH THỨC GIẢNG DẠY.java @@ -0,0 +1,46 @@ +import java.util.*; +import java.io.*; + +/** + * + * @author GIGABYTE + */ +public class Main { + static class ob{ + String code, name, i, lt, th; + + public ob(String a, String b, String c, String d, String e){ + code = a; + name = b; + i = c; + lt = d; + th = e; + }; + + public boolean oke(){ + if(th.compareTo("Truc tuyen") == 0) return true; + if(th.endsWith(".ptit.edu.vn")) return true; + return false; + } + + @Override + public String toString(){ + return code + ' ' + name + ' ' + i + ' ' + lt + ' ' + th; + } + + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("MONHOC.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + while(n-->0) a.add(new ob(sc.nextLine(),sc.nextLine(),sc.nextLine(),sc.nextLine(),sc.nextLine())); + a.sort((ob x, ob y) -> { + return x.code.compareTo(y.code); + }); + a.forEach(e ->{ + if(e.oke()) System.out.println(e); + }); + } +} diff --git a/J07074 - LỊCH GIẢNG DẠY THEO MÔN HỌC.java b/J07074 - LỊCH GIẢNG DẠY THEO MÔN HỌC.java new file mode 100644 index 0000000..35b5673 --- /dev/null +++ b/J07074 - LỊCH GIẢNG DẠY THEO MÔN HỌC.java @@ -0,0 +1,82 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static class lich { + int thu, kip; + String gv, room, code, mcode; + + public lich(int i, String mcode, int thu, int kip, String gv, String room) { + this.code = String.format("HP%03d", i); + this.mcode = mcode; + this.thu = thu; + this.kip = kip; + this.gv = gv; + this.room = room; + } + @Override + public String toString() { + return code + " " + thu + " " + kip + " " + gv + " " + room; + } + } + + static class mh { + ArrayList a; + String code, name; + int num; + + public mh(String code, String name, int num) { + a = new ArrayList<>(); + this.code = code; + this.name = name; + this.num = num; + } + + public void sort() { + a.sort((lich x, lich y) -> { + if (x.thu == y.thu) { + if (x.kip == y.kip) + return x.gv.compareTo(y.gv); + return x.kip - y.kip; + } + return x.thu - y.thu; + }); + } + + @Override + public String toString() { + String s = String.format("LICH GIANG DAY MON %s:\n", name); + String[] arr = new String[a.size()]; + for (int i = 0; i < arr.length; i++) { + arr[i] = a.get(i).toString(); + } + return s + String.join("\n", arr); + } + } + + public static void main(String[] args) throws IOException { + Scanner mh_sc = new Scanner(new File("MONHOC.in")); + Scanner lich_sc = new Scanner(new File("LICHGD.in")); + HashMap hmh = new HashMap<>(); + int n = mh_sc.nextInt(); + for (int i = 0; i < n; i++) { + mh_sc.nextLine(); + mh x = new mh(mh_sc.nextLine(), mh_sc.nextLine(), mh_sc.nextInt()); + hmh.put(x.code, x); + } + mh_sc.close(); + int m = lich_sc.nextInt(); + for (int i = 1; i <= m; i++) { + String code = lich_sc.next(); + int thu = lich_sc.nextInt(); + int kip = lich_sc.nextInt(); + lich_sc.nextLine(); + lich x = new lich(i, code, thu, kip, lich_sc.nextLine(), lich_sc.nextLine()); + hmh.get(code).a.add(x); + } + String code = lich_sc.next(); + hmh.get(code).sort(); + System.out.println(hmh.get(code)); + } +} diff --git a/J07075 - LỊCH GIẢNG DẠY THEO GIẢNG VIÊN.java b/J07075 - LỊCH GIẢNG DẠY THEO GIẢNG VIÊN.java new file mode 100644 index 0000000..0b876d7 --- /dev/null +++ b/J07075 - LỊCH GIẢNG DẠY THEO GIẢNG VIÊN.java @@ -0,0 +1,71 @@ +import java.io.*; +import java.util.*; + +public class Main { + + static class lich { + mh o; + int thu, kip; + String gv, room, code, mcode; + + public lich(int i, mh o, int thu, int kip, String gv, String room) { + this.code = String.format("HP%03d", i); + this.o = o; + this.thu = thu; + this.kip = kip; + this.gv = gv; + this.room = room; + } + @Override + public String toString() { + return code + " " + o.name + " " + thu + " " + kip + " " + room; + } + } + + static class mh { + String code, name; + int num; + + public mh(String code, String name, int num) { + this.code = code; + this.name = name; + this.num = num; + } + } + + public static void main(String[] args) throws IOException { + Scanner mh_sc = new Scanner(new File("MONHOC.in")); + Scanner lich_sc = new Scanner(new File("LICHGD.in")); + HashMap hmh = new HashMap<>(); + int n = mh_sc.nextInt(); + for (int i = 0; i < n; i++) { + mh_sc.nextLine(); + mh x = new mh(mh_sc.nextLine(), mh_sc.nextLine(), mh_sc.nextInt()); + hmh.put(x.code, x); + } + mh_sc.close(); + int m = lich_sc.nextInt(); + ArrayList a = new ArrayList<>(); + for (int i = 1; i <= m; i++) { + String code = lich_sc.next(); + int thu = lich_sc.nextInt(); + int kip = lich_sc.nextInt(); + lich_sc.nextLine(); + lich x = new lich(i, hmh.get(code), thu, kip, lich_sc.nextLine(), lich_sc.nextLine()); + a.add(x); + } + String gv = lich_sc.nextLine(); + a.sort((lich x, lich y) -> { + if (x.thu == y.thu) { + if (x.kip == y.kip) + return x.gv.compareTo(y.gv); + return x.kip - y.kip; + } + return x.thu - y.thu; + }); + System.out.printf("LICH GIANG DAY GIANG VIEN %s:\n", gv); + a.forEach(e -> { + if(e.gv.compareTo(gv) == 0) System.out.println(e); + }); + } +} diff --git a/J07076 - SẮP XẾP MA TRẬN.java b/J07076 - SẮP XẾP MA TRẬN.java new file mode 100644 index 0000000..c39648d --- /dev/null +++ b/J07076 - SẮP XẾP MA TRẬN.java @@ -0,0 +1,38 @@ +import java.util.*; +import java.io.*; + +public class Main { + + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("MATRIX.in")); + // Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt(); + int[][] a = new int[n][m]; + for(int i=0;i b[j]){ + int tmp = b[i]; + b[i] = b[j]; + b[j] = tmp; + } + } + } + for(int i=0;i'9') return false; + } + return true; + } + + static Long cal(String a, String b, String op){ + Long x = Long.parseLong(a); + Long y = Long.parseLong(b); + if(op.compareTo("*") == 0) return x*y; + if(op.compareTo("/") == 0) return x/y; + if(op.compareTo("+") == 0) return x+y; + return x-y; + } + + static String process(Stack a){ + Stack st = new Stack<>(); + while(!a.empty()){ + String x = a.pop(); + if("*/".contains(x)){ + String m = st.pop(); + String n = a.pop(); + st.push(cal(m, n, x).toString()); + }else st.push(x); + } + while(!st.empty()) a.push(st.pop()); + Long r = Long.parseLong(a.pop()); + while(!a.empty()){ + String op = a.pop(); + String m = a.pop(); + r = cal(r.toString(), m, op); + } + return r.toString(); + } + + static void solve(String s){ + Stack st = new Stack<>(); + Stack ST = new Stack<>(); + Queue q = new LinkedList<>(); + for(int i=0;i ex = new Stack<>(); + while(st.lastElement().compareTo("(") != 0) ex.push(st.pop()); + st.pop(); + st.push(process(ex)); + }else st.push(x); + } + System.out.println(st.pop()); + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("BIEUTHUC.in")); + // Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + sc.nextLine(); + while(T-->0) solve("("+sc.nextLine()+")"); + } +} diff --git a/J07078 - TÌM VỊ TRÍ XÂU CON.java b/J07078 - TÌM VỊ TRÍ XÂU CON.java new file mode 100644 index 0000000..c7d6727 --- /dev/null +++ b/J07078 - TÌM VỊ TRÍ XÂU CON.java @@ -0,0 +1,26 @@ +import java.io.*; +import java.util.*; + +public class non { + + static boolean sub(String a, String b, int l, int r) { + for (int i = 0; i < b.length(); i++) { + if (a.charAt(i + l) != b.charAt(i)) + return false; + } + return true; + } + public static void main(String[] args) throws IOException{ + Scanner sc = new Scanner(new File("STRING.in")); + int t = sc.nextInt(); + while (t-- > 0) { + String s1 = sc.next(); + String s2 = sc.next(); + for (int i = 0; i <= s1.length() - s2.length(); i++) { + if (sub(s1, s2, i, i + s2.length() - 1)) + System.out.printf("%d ", i + 1); + } + System.out.println(); + } + } +} diff --git a/J07081 - SẮP XẾP DANH SÁCH SINH VIÊN.java b/J07081 - SẮP XẾP DANH SÁCH SINH VIÊN.java new file mode 100644 index 0000000..6d2b67f --- /dev/null +++ b/J07081 - SẮP XẾP DANH SÁCH SINH VIÊN.java @@ -0,0 +1,41 @@ +import java.util.*; +import java.io.*; + +public class Main { + static class ob{ + String first, last, full, msv, sdt, email; + public ob(String m, String n, String s, String e){ + msv = m; + sdt = s; + String[] a = n.trim().split("\\s+"); + first = a[0]; + last = a[a.length-1]; + full = n; + email = e; + } + + @Override + public String toString(){ + return msv + ' ' + full + ' ' + sdt + ' ' + email; + } + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("SINHVIEN.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i { + if(x.last.compareTo(y.last) == 0){ + if(x.first.compareTo(y.first) == 0){ + if(x.full.compareTo(y.full) == 0) return x.msv.compareTo(y.msv); + return x.full.compareTo(y.full); + } + return x.first.compareTo(y.first); + } + return x.last.compareTo(y.last); + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07084 - THỜI GIAN ONLINE LIÊN TỤC.java b/J07084 - THỜI GIAN ONLINE LIÊN TỤC.java new file mode 100644 index 0000000..891ca4d --- /dev/null +++ b/J07084 - THỜI GIAN ONLINE LIÊN TỤC.java @@ -0,0 +1,39 @@ +import java.util.*; +import java.io.*; +import java.text.*; + +public class Main { + static class ob{ + String full, start, end; + long total; + public ob(String n, String s, String e){ + full = n; + start = s; + end = e; + SimpleDateFormat f = new SimpleDateFormat("dd/mm/yyyy HH:mm:ss"); + try{ + total = f.parse(end).getTime() - f.parse(start).getTime(); + }catch(ParseException ex){ + + } + } + + @Override + public String toString(){ + return full + ' ' + total/60000; + } + } + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(new File("ONLINE.in")); + // Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + sc.nextLine(); + for(int i=0;i { + if(x.total == y.total) return x.full.compareTo(y.full); + return y.total > x.total ? 1 : -1; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J07085 - TỔNG CHỮ SỐ.java b/J07085 - TỔNG CHỮ SỐ.java new file mode 100644 index 0000000..fd116cd --- /dev/null +++ b/J07085 - TỔNG CHỮ SỐ.java @@ -0,0 +1,26 @@ +import java.util.*; +import java.io.*; + +public class Main { + static int tcs(String s){ + int r = 0 ; + for(int i=0;i a = (ArrayList) o.readObject(); + a.forEach(e -> { + String s[] = e.split("[a-zA-Z]+"); + String r=""; + for(String i : s) r+=i; + r = r.replaceFirst("^0*", ""); + if(r.isEmpty()) r = "0"; + System.out.printf("%s %d\n",r,tcs(r)); + }); + } +} diff --git a/J08010 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java b/J08010 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java new file mode 100644 index 0000000..f5ee1e0 --- /dev/null +++ b/J08010 - TÌM TỪ THUẬN NGHỊCH DÀI NHẤT.java @@ -0,0 +1,61 @@ +import java.util.*; + +public class Main { + + static class word { + String w; + int cnt, stt; + + public word(String w, int i) { + this.w = w; + this.cnt = 1; + this.stt = i; + } + + @Override + public String toString() { + return w + " " + cnt; + } + } + + static boolean tn(String s) { + for (int i = 0; i < s.length() / 2; i++) { + if (s.charAt(i) != s.charAt(s.length() - 1 - i)) + return false; + } + return true; + } + + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + ArrayList a = new ArrayList<>(); + int index = 0; + while (sc.hasNext()) { + String s = sc.next(); + if (!tn(s)) + continue; + boolean oke = true; + for (int i = 0; i < a.size(); i++) { + if (a.get(i).w.compareTo(s) == 0) { + oke = false; + a.get(i).cnt += 1; + } + } + if (oke) { + a.add(new word(s, index)); + index++; + } + } + a.sort((word x, word y) -> { + if (x.w.length() == y.w.length()) { + return x.stt - y.stt; + } + return y.w.length() - x.w.length(); + }); + a.forEach(e -> { + if (e.w.length() == a.get(0).w.length()) + System.out.println(e); + }); + } +} diff --git a/J08011 - LIỆT KÊ VÀ ĐẾM.java b/J08011 - LIỆT KÊ VÀ ĐẾM.java new file mode 100644 index 0000000..ad8d1eb --- /dev/null +++ b/J08011 - LIỆT KÊ VÀ ĐẾM.java @@ -0,0 +1,50 @@ +import java.util.*; + +public class non { + static boolean check(String a) { + for (int i = 1; i < a.length(); i++) { + if (a.charAt(i) < a.charAt(i - 1)) + return false; + } + return true; + } + + static class num { + String num; + int cnt, stt; + + public num(String num, int cnt, int stt) { + this.num = num; + this.cnt = cnt; + this.stt = stt; + } + + @Override + public String toString() { + return num + " " + cnt; + } + } + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + HashMap hm = new HashMap<>(); + ArrayList a = new ArrayList<>(); + int i = 0; + while (sc.hasNext()) { + String s = sc.next(); + if (!check(s)) + continue; + if (hm.get(s) == null) { + num x = new num(s, 1, i); + hm.put(s, x); + a.add(x); + } else + hm.get(s).cnt += 1; + } + a.sort((num x, num y) -> { + if (x.cnt == y.cnt) + return x.stt - y.stt; + return y.cnt - x.cnt; + }); + a.forEach(e -> System.out.println(e)); + } +} diff --git a/J08012 - HÌNH SAO.java b/J08012 - HÌNH SAO.java new file mode 100644 index 0000000..ac5cfa9 --- /dev/null +++ b/J08012 - HÌNH SAO.java @@ -0,0 +1,22 @@ +import java.util.*; +import java.io.*; + +public class Main { + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] ke = new int[n+1]; + for(int i=0;i1) cnt++; + } + if(cnt>1) System.out.println("No"); + else System.out.println("Yes"); + } +} diff --git a/J08015 - CẶP SỐ CÓ TỔNG BẰNG K.java b/J08015 - CẶP SỐ CÓ TỔNG BẰNG K.java new file mode 100644 index 0000000..eb610f9 --- /dev/null +++ b/J08015 - CẶP SỐ CÓ TỔNG BẰNG K.java @@ -0,0 +1,35 @@ +import java.util.*; +public class Main { + + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + Long n = sc.nextLong(); + Long k = sc.nextLong(); + HashMap hm = new HashMap<>(); + for (int i = 0; i < n; i++) { + Long x = sc.nextLong(); + if (hm.get(x) == null) + hm.put(x, (long) 1); + else + hm.put(x, hm.get(x) + 1); + } + long ans = 0; + for (Map.Entry set : hm.entrySet()) { + long x = set.getKey(); + long y = set.getValue(); + if (x < (k + 1) / 2) { + if (hm.get(k - x) != null) + ans += y * hm.get(k - x); + } + } + if (k % 2 == 0 && hm.get(k / 2) != null) { + long x = hm.get(k / 2); + ans += n * (n - 1) / 2; + } + System.out.println(ans); + } + } +} diff --git a/J08020 - KIỂM TRA DÃY NGOẶC ĐÚNG.java b/J08020 - KIỂM TRA DÃY NGOẶC ĐÚNG.java new file mode 100644 index 0000000..0d58df6 --- /dev/null +++ b/J08020 - KIỂM TRA DÃY NGOẶC ĐÚNG.java @@ -0,0 +1,25 @@ +import java.util.*; +import java.io.*; + +public class Main { + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + String s = sc.next(); + Stack a = new Stack<>(); + for(int i=0;i0){ + String s = sc.next(); + int dp[] = new int[s.length()]; + int ans = 0; + Stack a = new Stack<>(); + for(int i=0;i 0 && s.charAt(a.lastElement() - 1) == ')'){ + dp[i] += dp[a.lastElement() - 1]; + } + ans = Math.max(ans, dp[i]); + a.pop(); + }else a.push(i); + } + } + System.out.println(ans); + } + } +} diff --git a/J08022 - PHẦN TỬ BÊN PHẢI ĐẦU TIÊN LỚN HƠN.java b/J08022 - PHẦN TỬ BÊN PHẢI ĐẦU TIÊN LỚN HƠN.java new file mode 100644 index 0000000..997d0b5 --- /dev/null +++ b/J08022 - PHẦN TỬ BÊN PHẢI ĐẦU TIÊN LỚN HƠN.java @@ -0,0 +1,30 @@ +import java.util.*; +import java.io.*; + +public class Main { + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-->0){ + int n = sc.nextInt(); + int[] a = new int[n]; + int[] ans = new int[n]; + for(int i=0;i st = new Stack<>(); + for(int i=n-1;i>=0;i--){ + if(st.empty()){ + ans[i]=-1; + st.push(a[i]); + }else{ + while(!st.empty() && st.lastElement()<=a[i]) st.pop(); + if(st.empty()) ans[i] = -1; + else ans[i] = st.lastElement(); + st.push(a[i]); + } + } + for(int i=0;i st = new Stack<>(); + for(int i=start;i!=end;i+=step){ + while(!st.isEmpty() && a[st.lastElement()] >= a[i]) st.pop(); + if(st.isEmpty()) b[i] = root; + else b[i] = st.lastElement(); + st.push(i); + } + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + while(T-->0){ + int n = sc.nextInt(); + long[] a = new long[n]; + for(int i=0;i dp = new ArrayList<>(); + static void Try(int i, int n, String s){ + dp.add(Integer.parseInt(s)); + if(i==n) return; + Try(i+1,n,s+"0"); + Try(i+1,n,s+"9"); + } + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + Try(0, 8, "9"); + Collections.sort(dp); + while(t-->0){ + int n = sc.nextInt(); + for(int i=0;i0){ + int s[] = new int[6]; + int t[] = new int[6]; + for(int i=0;i<6;i++) s[i]=sc.nextInt(); + for(int i=0;i<6;i++) t[i]=sc.nextInt(); + Queue q = new LinkedList<>(); + q.add(new pair(s, 0)); + while(!q.isEmpty()){ + pair u = q.poll(); + if(check(t, u.a)){ + System.out.println(u.cnt); + break; + } + q.add(new pair(turn(u.a, 0), u.cnt+1)); + q.add(new pair(turn(u.a, 1), u.cnt+1)); + } + } + } +} diff --git a/J08026 - BIẾN ĐỔI S – T.java b/J08026 - BIẾN ĐỔI S – T.java new file mode 100644 index 0000000..f3ce73d --- /dev/null +++ b/J08026 - BIẾN ĐỔI S – T.java @@ -0,0 +1,21 @@ +import java.util.*; + +public class non { + static class pair{ + int x, y; + public pair(int x, int y){ + this.x = x; + this.y = y; + } + } + static int solve(int s, int t){ + if(s>=t) return s - t; + if(t%2==1) return 1 + solve(s, t+1); + return 1 + solve(s, t>>1); + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + while(T-->0) System.out.println(solve(sc.nextInt(), sc.nextInt())); + } +} diff --git a/J08027 - GÕ BÀN PHÍM.java b/J08027 - GÕ BÀN PHÍM.java new file mode 100644 index 0000000..4df22f7 --- /dev/null +++ b/J08027 - GÕ BÀN PHÍM.java @@ -0,0 +1,27 @@ +import java.util.*; + +public class non { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s = sc.next(); + Stack a = new Stack<>(); + Stack b = new Stack<>(); + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '<') { + if (!a.empty()) + b.push(a.pop()); + } else if (s.charAt(i) == '>') { + if (!b.empty()) + a.push(b.pop()); + } else if (s.charAt(i) == '-') { + if (!a.empty()) + a.pop(); + } else + a.push(s.charAt(i)); + } + while (!a.empty()) + b.push(a.pop()); + while (!b.empty()) + System.out.print(b.pop()); + } +} diff --git a/J08028 - HÌNH CHỮ NHẬT ĐƠN SẮC.java b/J08028 - HÌNH CHỮ NHẬT ĐƠN SẮC.java new file mode 100644 index 0000000..1912307 --- /dev/null +++ b/J08028 - HÌNH CHỮ NHẬT ĐƠN SẮC.java @@ -0,0 +1,39 @@ +import java.util.*; + +public class non { + + static void min(long[] a, int[] b, int start, int end, int step, int root){ + Stack st = new Stack<>(); + for(int i=start;i!=end;i+=step){ + while(!st.isEmpty() && a[st.lastElement()] >= a[i]) st.pop(); + if(st.isEmpty()) b[i] = root; + else b[i] = st.lastElement(); + st.push(i); + } + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = 2; + int m = sc.nextInt(), n = sc.nextInt(); + long[] arr = new long[n]; + long res = 0; + for(int i=0;i0){ + long[] a = new long[n]; + for(int i=0;i=0 && x<8 && y>=0 && y<8; + } + + static void solve(String a, String b){ + Pair st = new Pair(a); + Pair en = new Pair(b); + boolean[][] check = new boolean[8][8]; + Queue q = new LinkedList<>(); + q.add(st); + while(!q.isEmpty()){ + Pair u = q.poll(); + if(u.is(en)){ + System.out.println(u.cnt); + return; + } + for(int i=0;i<2;i++){ + for(int j=0;j<2;j++){ + for(int k=0;k<2;k++){ + Pair x = new Pair(u.x+step[k][i], u.y+step[1-k][j]); + if(check(x.x, x.y)){ + x.cnt = u.cnt+1; + q.add(x); + } + } + } + } + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + while(T-->0) solve(sc.next(), sc.next()); + } +} diff --git a/JKT013 - SỐ LỘC PHÁT.java b/JKT013 - SỐ LỘC PHÁT.java new file mode 100644 index 0000000..62fc076 --- /dev/null +++ b/JKT013 - SỐ LỘC PHÁT.java @@ -0,0 +1,38 @@ +import java.util.*; +import java.io.*; + +public class Main { + static ArrayList dp = new ArrayList<>(); + static void Try(int i, int n, String s){ + if(!s.isEmpty()) dp.add(s); + if(i==n) return; + Try(i+1,n,s+"6"); + Try(i+1,n,s+"8"); + } + public static void main(String[] args) throws IOException, ClassNotFoundException { + // Scanner sc = new Scanner(new File("ONLINE.in")); + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + Try(0, 15, ""); + Collections.sort(dp, new Comparator() { + @Override + public int compare(String a, String b){ + if(a.length() == b.length()) return a.compareTo(b); + return a.length() - b.length(); + } + }); + while(t-->0){ + int n=sc.nextInt(); + int cnt=0; + for(int i=0;i=0;i--){ + if(dp.get(i).length()<=n) System.out.printf("%s ",dp.get(i)); + } + System.out.println(); + } + } +} diff --git a/JKT014 - ĐẦU TƯ CHỨNG KHOÁN.java b/JKT014 - ĐẦU TƯ CHỨNG KHOÁN.java new file mode 100644 index 0000000..c3805f3 --- /dev/null +++ b/JKT014 - ĐẦU TƯ CHỨNG KHOÁN.java @@ -0,0 +1,32 @@ +import java.util.*; +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while (t-- > 0) { + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + int[] fb = new int[n]; + Stack st = new Stack<>(); + for (int i = 0; i < n; i++) { + if (st.empty()) { + fb[i] = - 1; + st.push(i); + } else { + while (!st.empty() && a[st.lastElement()] <= a[i]) + st.pop(); + if (st.empty()) + fb[i] = - 1; + else + fb[i] = st.lastElement(); + st.push(i); + } + } + for (int i = 0; i < n; i++) + System.out.printf("%d ", i-fb[i]); + System.out.println(); + } + } +} diff --git a/JKT015 - GÕ BÀN PHÍM.java b/JKT015 - GÕ BÀN PHÍM.java new file mode 100644 index 0000000..f76f3f9 --- /dev/null +++ b/JKT015 - GÕ BÀN PHÍM.java @@ -0,0 +1,25 @@ +import java.util.*; +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String s = sc.next(); + Stack a = new Stack<>(); + Stack b = new Stack<>(); + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == '<') { + if (!a.empty()) + b.push(a.pop()); + } else if (s.charAt(i) == '>') { + if (!b.empty()) + a.push(b.pop()); + } else if (s.charAt(i) == '-') { + if (!a.empty()) + a.pop(); + } else + a.push(s.charAt(i)); + } + while (!a.empty()) + b.push(a.pop()); + while(!b.empty()) System.out.print(b.pop()); + } +} diff --git a/TN02012 - TÍNH LƯƠNG.java b/TN02012 - TÍNH LƯƠNG.java new file mode 100644 index 0000000..7e88038 --- /dev/null +++ b/TN02012 - TÍNH LƯƠNG.java @@ -0,0 +1,81 @@ +import java.util.*; +import java.text.*; + +public class Main { + + static class ob { + String code, name; + + public ob(String code, String name){ + this.code = code; + this.name = name; + } + } + + static long x(String s){ + long y = Long.parseLong(s.substring(1,3)); + if (1<=y && y<=3){ + if(s.charAt(0)=='A') return 10; + if(s.charAt(0)=='B') return 10; + if(s.charAt(0)=='C') return 9; + return 8; + } + if(4<=y && y<=8){ + if(s.charAt(0)=='A') return 12; + if(s.charAt(0)=='B') return 11; + if(s.charAt(0)=='C') return 10; + return 9; + } + if(9<=y && y<=15){ + if(s.charAt(0)=='A') return 14; + if(s.charAt(0)=='B') return 13; + if(s.charAt(0)=='C') return 12; + return 11; + } + if(s.charAt(0)=='A') return 20; + if(s.charAt(0)=='B') return 16; + if(s.charAt(0)=='C') return 14; + return 13; + } + static class ob2 { + ob o; + String code, name; + Long x, sum; + public ob2(ob o, String code, String name, long sday, long days){ + this.o = o; + this.code = code; + this.name = name; + this.x = x(code); + this.sum = sday*days*this.x*1000; + } + + @Override + public String toString(){ + return code + " " + name + " " + o.name + " " + sum; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + ArrayList a = new ArrayList<>(); + for(int i=0;i b = new ArrayList<>(); + for(int j=0;j System.out.println(e)); + } +}