Dương Hoàng
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Lời giải đề thi thử Tuyển sinh 10 trường THPT chuyên Khoa học Tự nhiên - Lần 2 - Môn Tin học Chấm bài tại đây: [ClueOJ](https://oj.clue.edu.vn/contest/khtn_thithuts10_2_25). ## Bài 1 - RECT ### Tóm tắt đề bài Cho $n$ điểm $(x_i, y_i)$ trên mặt phẳng tọa độ. Hãy tìm hình chữ nhật diện tích nhỏ nhất chứa cả $n$ điểm này. ### Lời giải Hình chữ nhật tối ưu sẽ luôn có một (vài) điểm nằm trên cạnh. Nếu không có điểm nào nằm trên cạnh, ta hoàn toàn có thể hạ độ dài cạnh mà không làm ảnh hưởng kết quả. Vì vậy, ta gọi $min_x$ là $min (x_i)$ với $1 \le i \le n$. Tương tự ta có $max_x$, $min_y$ và $max_y$. Đây là các tọa độ tối thiểu và tối đa của các cạnh hình chữ nhật. Vì vậy, diện tích tối thiểu của hình chữ nhật là $(max_x - min_x) \times (max_y - min_y)$. Độ phức tạp: $O$ ($n$). ## Bài 2 - ONES ### Tóm tắt đề bài Cho số gồm $n$ chữ số $1$. Ví dụ, với $n = 4$ ta có số $1111$. Hãy tính $n$ $\%$ $998244353$. ### Subtask 1: $n \le 18$ Ta có thể tính hẳn giá trị $n$ ra, sau đó tìm ra kết quả. Ta có thể xây dựng từng chữ số như sau: ```cpp= int res = 0; for (int i = 1; i <= n; i++){ res *= 10; // Lúc này, số đã có thêm một chữ số 0. res += 1; // Ta thay chữ số 0 thành chữ số 1. } ``` Cuối cùng, ta in ra kết quả. Độ phức tạp: $O$ ($n$). ### Subtask 2: $n \le 10^5$ Nhìn vào công thức truy hồi trên, thay vì nhân hết rồi mới mod, ta có thể mod ngay khi nhân, do tính chất của phép cộng và nhân đều có thể modulo được. Độ phức tạp: $O$ ($n$). ## Bài 3 - RAND ### Tóm tắt đề bài Cho $F(x) = ax + b$ và dãy số $S = {S_1, S_2, ..., S_n}$ được xác định như sau: - $S_1 = c$ - $S_i = F(S_{i-1}) \mod 100$ với $2 \le i \le n$ Tìm số lớn thứ $k$ trong dãy $S$. Giới hạn: ($a, b \le 10^9, c < 100, n \le 10^7$) ### Subtask 1: $n \le 2 \times 10^5$ Ở subtask này, ta hoàn toàn có thể mô phỏng dãy $S$ từ $S_1$ đến $S_n$ do giới hạn $n$ không quá to. Sau đó, ta sẽ sắp xếp dãy $S$ để từ đó tìm được số lớn thứ $k$. Độ phức tạp: $O$ ($n log n$) ### Subtask 2: $n \le 10^7$ Ta có thể để ý rằng, do giá trị $mod$ tương đối nhỏ (tối đa $100$), cũng đồng nghĩa giá trị của $S$ không vượt quá $99$. Từ đó, ta nhận ra rằng, hoàn toàn có thể sử dụng mảng đánh dấu để có thể đánh dấu số lần xuất hiện của từng phần tử $S_i$ trong mảng $S$. Gọi $cnt_i$ là số lần giá trị $i$ xuất hiện trong mảng $S$. Ta sẽ tiến hành duyệt từ cuối mảng $cnt$ về đầu, và cộng số lần xuất hiện của giá trị $i$ vào biến $res$. Đáp số đề bài chính là giá trị $i$ đầu tiên mà $res \ge k$. Độ phức tạp: $O$ ($n$) ## Bài 4 - SHOP ### Tóm tắt đề bài Cho $n$ món đồ, món đồ thứ $i$ có giá mua là $c_i$ và giá trị là $v_i$. Tuy vậy, có $k$ điều kiện dạng $(a_i, b_i)$ có nghĩa: nếu bạn mua món đồ $a_i$, bạn phải mua món đồ $b_i$. Với số tiền $m$ đồng, hãy mua các món đồ sao cho tổng giá trị là lớn nhất. Giới hạn: $n \le 1000$, $k \le 10^4$, $m, c_i, v_i \le 10^9$ ### Subtask 1: $c_i, m \le 1000$, $k \le 2$ Với một điều kiện $(a_i, b_i)$ có bốn cách chọn: - Không mua cả hai: hợp lệ. - Mua cả hai: hợp lệ. - Mua $a_i$, không mua $b_i$: Không hợp lệ. - Không mua $a_i$, mua $b_i$: Hợp lệ. Vì vậy, với mỗi điều kiện, ta có ba cách chọn. Ta sẽ duyệt $3^k$ cách chọn này. Ta cần kiểm tra các lựa chọn có mâu thuẫn nhau không. Nói cách khác, chẳng hạn nếu ở điều kiện $1$ ta phải mua vật $x$, nhưng ở điều kiện $2$ ta lại không mua vật $x$, thì đây là mâu thuẫn. Sau khi có danh sách các vật phải mua, và các vật không được mua, ta có thể quy hoạch động cái túi như bình thường, do giới hạn $n \times m \le 10^6$ khá nhỏ. Độ phức tạp: $O$ ($3^k \times n \times m$). ### Subtask 2: $n \le 20$. Với subtask này, ta hoàn toàn có thể duyệt mọi tập con của $n$ phần tử. Sau đó, ta cần kiểm tra tập con này có thỏa mãn không. Trước hết, ta cần kiểm tra tập con này có thỏa mãn $k$ điều kiện nói trên không. Có thể duyệt đủ $k$ điều kiện, tuy nhiên điều này là khá chậm. Ta có thể làm cách khác: - Với mỗi điều kiện $i$, ta sẽ lưu các **vật phẩm phải mua** nếu mua vật phẩm thứ $i$ **dưới dạng bitmask.** - Sau đó, ta có thể dễ dàng kiểm tra bằng phép toán AND hai tập hợp. Gọi $mask$ là tập con của $n$ phần tử ta đang thử, $must$ là tập các vật phẩm phải mua khi mua vật phẩm $i$ (mà vật phẩm $i$ cũng phải nằm trong $mask$), thì tập này thỏa mãn nếu $mask$ $\&$ $must = must$. Sau đó, ta cần tính tổng số tiền phải trả cho tập con này, nếu $\le m$ thì ta cập nhật vào kết quả. Độ phức tạp: $O$ $(2^n \times n)$.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully