CSES Missing Number 題解
題目 我覺得把題目複製過來是最累的一件事 Time limit: 1.00 s Memory limit: 512 MB You are given all numbers between 1,2,…,n1,2,\ldots,n1,2,…,n except one. Your task is to find the missing number. Input Output The first input line contains an integer nnn.The second line contains n−1n-1n−1 numbers. Each number is distinct and between 111 and nnn (inclusive). Print the missing number. Constraints 2≤n≤2⋅1052 \le n \le 2 \cdot 10^52≤n≤2⋅105 Example: Input Output 52 3 1 5 4 解法 解法一 分析 這一個是我的做法 ...
CSES Dice Combinations 題解
DP? 想成高中數學的遞迴就好啦 題目 Time limit: 1.00 s Memory limit: 512 MB Your task is to count the number of ways to construct sum n by throwing a dice one or more times. Each throw produces an outcome between 1 and 6. For example, if n=3, there are 4 ways: 1+1+1 1+2 2+1 3 Input Output The only input line has an integer nnn. Print the number of ways modulo 109+710^9+7109+7. Constraints 1≤n≤1061 \le n \le 10^61≤n≤106 Example: Input Output 3 4 解法 分析 這是DP入門題 給定n∈Nn\in\Nn∈N,令dp[n]...
[Note] Writing a simple Program in C - LiveOverflow
看了這部影片 Writing a simple Program in C - YouTube 做的筆記 PATH env | grep "PATH" # or echo $PATH #this one # add to PATH(for one time) export PATH=$PATH:directory vim 基礎 :syntax on #上色 :set number #標號 C 語言 #include <stdio.h> int main(int argc, char *argv[]){ if(argc==2){ printf("Knock, Knock, %s\n", argv[1]); } else { fprintf(stderr, "Usage: %s <name>\n", argv[0]); return 1; } } 解析: argc: 參數數量(從檔案名稱算起) argv: 參數矩陣(包含檔案名稱) 範...
CSES Bracket Sequences I 題解
題目 Time limit: 1.00 s Memory limit: 512 MB Your task is to calculate the number of valid bracket sequences of length nnn. For example, when n=6n=6n=6, there are 555 sequences: ()()() ()(()) (())() ((())) (()()) Input Output The only input line has an integer nnn. Print the number of sequences modulo 109+710^9+7109+7. Constraints 1≤n≤1061 \le n \le 10^61≤n≤106 Example: Input Output 6 5 解法 這題很顯然是在考卡特蘭數 卡特蘭數 定義 卡特蘭數CnC_nCn表示有A, B各nnn個,A永不落後B的排列方法數。組合學上有很多問題都跟卡特蘭數有關。 公式...
CSES Trailing Zeros 題解
題目 Time limit: 1.00 s Memory limit: 512 MB Your task is to calculate the number of trailing zeros in the factorial n!. For example, 20!=243290200817664000020!=243290200817664000020!=2432902008176640000 and it has 444 trailing zeros. Input Output The only input line has an integer nnn. Print the number of trailing zeros in n!n!n!. Constraints 1≤n≤1091 \le n \le 10^91≤n≤109 Example: Input Output 20 4 解法 分析 這題十分經典,是要求n!n!n!尾部有幾個000。 注意到n!n!n!尾部000的個數===滿足10k∣n!10^k | n!10...
CSES Exponentiation II 題解
本題會用到上次在CSES Exponentiation 題解 | R3X’s Blog講到的東西,並假設讀者都已看過。 題目 Time limit: 1.00 s Memory limit: 512 MB Your task is to efficiently calculate values abca^{b^c}abc modulo 109+710^9+7109+7. Note that in this task we assume that 00=10^0=100=1. Input Output The first input line contains an integer nnn: the number of calculations.After this, there are nnn lines, each containing three integers a,ba, ba,b and ccc. Print each value abca^{b^c}abc modulo 109+710^9+7109+7. Constraints 1≤n≤...
CSES Exponentiation 題解
題目 Time limit: 1.00 s Memory limit: 512 MB Your task is to efficiently calculate values aba^bab modulo 109+710^9+7109+7. Note that in this task we assume that 00=10^0=100=1. Input Output The first input line contains an integer nnn: the number of calculations.After this, there are nnn lines, each containing two integers aaa and bbb. Print each value aba^bab modulo 109+710^9+7109+7. Constraints 1≤n≤2⋅1051 \le n \le 2 \cdot 10^51≤n≤2⋅105 0≤a,b≤1090 \le a,b \le 10^90≤a,b≤109 Exampl...
CTFLearn Leak me Writeup
這份是我2025年3月試用obsidian時寫的,如今把它搬過來這裡。 排版有點亂還請見諒。 題目 題目:https://ctflearn.com/challenge/1221 原始碼解壓縮: tar zxvf task.tar.gz 參數解釋: -z, --gzip, --gunzip, --ungzip filter the archive through gzip -x, --extract, --get extract files from an archive -v, --verbose verbosely list files processed -f, --file=ARCHIVE use archive file or device ARCHIVE 解題 task.c #include <stdlib.h> #include <stdio.h> int main() { setvbuf(stdout, NULL, _IONBF, 0); setvbu...
Eisenstein's RSA Official Writeup (簡要版)
題目資訊 Challenge Repo: r3xdj/Eisenstein-s-RSA-chal Writeup Eisenstein’s RSA 難度:Medium 類別:Crypto 請直接執行 cipher ,針對其輸出進行破解。 我們先來看題目給的cipher.py #!/usr/bin/python3 import gmpy2 from Cryptodome.Util import number from FLAG import flag class eint: def __init__(self, a, b): self.a = gmpy2.mpz(a) self.b = gmpy2.mpz(b) def __add__(self, other): return eint(self.a + other.a, self.b + other.b) def __sub__(self, other): return eint(self.a - other.a, self.b ...
Find My Size Official Writeup
題目資訊 Challenge Repo: r3xdj/FindMySize-chall Writeup FIND MY SIZE 分類:Forensics 難度:Medium 我收到一個奇怪的檔案,你可以幫我看看這是怎麼回事嗎? 題目給了一個png圖片檔案。 很顯然的這張圖片的長、寬被改掉了。因此我們首要之務是找回原本正確的長、寬,並將檔案修復。 IHDR數據塊 每一個png檔案,都以89 50 4E 47 0D 0A 1A 0A開始,隨後由若干個數據塊所組成。數據塊分為以下幾種:(取自參考資料1.PNG - CTF Wiki) 數據塊符號 數據塊名稱 多數據塊 可選否 位置限制 IHDR 文件頭數據塊 否 否 第一塊 cHRM 基色和白色點數據塊 否 是 在 PLTE 和 IDAT 之前 gAMA 圖像γ數據塊 否 是 在 PLTE 和 IDAT 之前 sBIT 樣本有效位數據塊 否 是 在 PLTE 和 IDAT 之前 PLTE 調色板數據塊 否 是 在 IDAT 之前 bKGD 背景顏色數據塊 否 是 在 PLTE 之後 IDAT...


![[Note] Writing a simple Program in C - LiveOverflow](/2026/06/03/Note-Writing-a-simple-Program-in-C-LiveOverflow/output.png)


