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

      This note has no invitees

    • 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
    • Note Insights
    • 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 Note Insights 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

    This note has no invitees

  • 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 Đại học Sư phạm Hà Nội - Môn Tin học Chấm bài tại đây: [ClueOJ](https://oj.clue.edu.vn/contest/csp_thithuts10_25). ## Bài 1: Số đặc biệt Tóm tắt đề bài: Cho số nguyên dương $n$, hãy in ra các ước $x$ của $n$ mà thỏa mãn $x - 1$ hoặc $x + 1$ cũng là ước của $n$. ### Subtask 1: $n \le 10^6$ Duyệt $i$ từ $1$ đến $n$ và kiểm tra xem $i$, $i - 1$, $i + 1$ có phải ước của $n$ hay không. Độ phức tạp: $O$ ($n$). ### Subtask 2: $n \le 10^{12}$ Ta duyệt đến $\sqrt n$ để có một danh sách các ước của $n$. Ta sắp xếp danh sách này lại. Với mỗi phần tử của danh sách, ta chỉ cần xem phần tử ngay trước nó, và phần tử ngay sau nó có chênh lệch đúng một đơn vị hay không. Nếu có, đây là một phần tử thỏa mãn. Độ phức tạp: $O$ ($\sqrt n$). ### Subtask 3: $n \le 10^{18}$. Ta cần một cách để lấy ra mọi ước của $n \le 10^{18}$. Bản chất, nếu ta có thể phân tích $n$ ra thừa số nguyên tố: $n = p_1^{d_1} \times p_2^{d_2} \times ... \times p_k^{d_k}$ thì ta có thể gọi đệ quy: với mỗi thừa số ta chọn ra một số mũ. Từ đó ta sinh ra được mọi ước của $n$. Vấn đề đặt ra là phân tích $n$ ra thừa số nguyên tố. Ta có thể sử dụng [thuật toán Pollard-Rho](https://wiki.vnoi.info/vi/algo/math/integer-factorization) để làm điều này. Một cách khác (credit: [Phước Vũ](https://www.facebook.com/Not.Miku.8909)) là: Một số nguyên dương $n$ có ước đặc biệt là $x$ sẽ có dạng $x \times (x + 1) \times k$, với $k$ cũng nguyên dương. Bằng phản chứng, ta có thể chứng minh được $min (x, k) \le 10^6$. Ta có thể duyệt $x$, hoặc duyệt $k$ để tính kết quả. Cần cẩn thận để tránh tính trùng. Độ phức tạp $O$ ($\sqrt {\sqrt n}$) hoặc $O$ ($t \times 10^6$). ## Bài 2: Đường tròn Tóm tắt đề bài: Cho $n$ điểm đen và $n$ điểm trắng trên mặt phẳng tọa độ. Tìm hình tròn có bán kính nhỏ nhất mà có số lượng điểm đen trong nó, bằng số lượng điểm trắng trong nó. **Nhận xét:** Bán kính tối ưu luôn có một điểm nằm trên viền của đường tròn. Điều này có thể dễ dàng quan sát thấy. Nếu không có điểm nào nằm trên viền của đường tròn, ta có thể giảm bán kính và được kết quả tối ưu hơn. Vì vậy, ta sẽ duyệt $dist$ là khoảng cách từ tâm đến một điểm trên đường tròn. Sau đó, sử dụng **tìm kiếm nhị phân** để xem có bao nhiêu điểm nằm trong đường tròn. Nếu số lượng điểm đen bằng số lượng điểm trắng, ta in ra kết quả. Độ phức tạp: $O$ ($n \times log n$) ## Bài 3: Cộng dãy Tóm tắt đề bài: Cho mảng $a$ gồm $n$ phần tử. Có $q$ truy vấn, mỗi truy vấn là cộng cả mảng lên $x$ đơn vị ($x$ có thể âm). Sau mỗi truy vấn, hãy in ra $\sum |a_i|$. ### Subtask 1: $n, q \le 5000$ Thực hiện y như những gì đề bài bảo. Độ phức tạp: $O$ ($n \times q$). ### Subtask 2: $n, q \le 5 \times 10^5$ Ta hoàn toàn có thể sắp xếp lại mảng $a$. Gọi $add$ là tổng giá trị ta phải cộng thêm vào mảng $a$ cho tới bây giờ. Dễ thấy, kết quả là |tổng các số trong mảng $a$ < $0$| + (tổng các số trong mảng $a \ge 0$). Do mảng $a$ đã được sắp xếp, ta sẽ **tìm kiếm nhị phân** để tìm ra chỉ số $i$ lớn nhất mà $a_i + add < 0$. Từ phần tử $i$ trở về trước, kết quả sẽ phải đảo dấu; từ phần tử thứ $i + 1$ trở về sau, kết quả không cần đảo dấu. Để tính toán nhanh tổng này, có thể sử dụng **tổng tiền tố**. Độ phức tạp: $O$ ($q \times log n$). ## Bài 4: Lắp đặt trạm thu phát sóng Tóm tắt đề bài: Chọn ra một vài trạm phát sóng sao cho: - Khoảng cách giữa hai trạm phát sóng bất kỳ $\ge k$. - Tổng lợi nhuận của các trạm phát sóng đó là lớn nhất. ### Subtask 1: $n \le 1000$ Gọi $dp_i$ là lợi nhuận lớn nhất khi xét đến trạm phát sóng thứ $i$, bắt buộc chọn trạm phát sóng thứ $i$. Ta thấy, $dp_i = max (a_i, dp_j + a_i)$ với điều kiện $1 \le j \le i - 1$ và $p_i - p_j \ge k$. Độ phức tạp: $O$ ($n^2$). ### Subtask 2, 3: $n \le 10^6$ Ta có thể duy trì $x$, là vị trí lớn nhất thỏa mãn $p_i - p_x \ge k$ bằng **hai con trỏ.** Lúc này, ta có công thức truy hồi mới: $dp_i = max (a_i, max (dp_1, dp_2, ..., dp_x) + a_i)$. Để xử lý nhanh phần này, ta gọi $f_i = max (dp_1, dp_2, ..., dp_i)$. Lúc này, công thức truy hồi là: $dp_i = max (a_i, f_x + a_i)$. Độ phức tạp: $O$ ($n$). **Lưu ý: Dữ liệu vào rất lớn, mình đã chỉnh giới hạn thời gian ở 5 giây. Nếu muốn cải tiến hơn nữa, có thể sử dụng [fast input](https://codeforces.com/blog/entry/120183), sẽ AC trong 1 giây.**

    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