## E. 披薩超人(Pizza) :::info - [x] 出題完畢 - [x] 標題 - [x] 構題想法 - [x] 題目敘述 - [x] 輸入說明 + 測資範圍 + 測資配分 - [x] 輸出說明 - [x] Sample Input & Output *3 - [x] 提示 + 範例測資說明 - [x] 標籤 - [x] 參考解法 - [x] 生測資上傳(已生好 20 筆測資) - [x] 配分與時間 - [x] 審題 - [x] 前測(測試完畢 int 60%, long long 100%AC) - [x] 驗題 ::: ### 題目敘述 今天是資訊研究社的社內練習賽,大家都比到好餓啊!而總務 $Pb.$ 就是為了吃披薩才加入資研社的,所以他在今天練習賽之前就已經準備好了零錢等待練習賽結束的披薩到來。 為了考驗總務 $Pb.$ 的會計能力,於是 $ShiYu$ 和 $YuDong$ 請他自己想辦法使用那些零錢湊出訂披薩的錢,因為總務 $Pb.$ 快要餓扁了,所以他決定接受挑戰,成為披薩超人。 已知披薩金額總共 $m$ 元,且桌上有無限個面額分別為 $50$、$10$、$5$、$1$ 元的零錢可以用 總務 $Pb.$ 想使用各種方法湊出 $m$ 元,請設計一份程式碼,幫忙計算總務 $Pb.$ 能使用零錢湊齊 $m$ 元的最大方法數。 出題者:$ShiYu.$ ### 輸入說明 第一行有 $1$ 個正整數 $n$ 表示披薩金額 > $m$ | 子任務 | 額外輸入限制 | 分數 | |:------:|:-----------------------------:|:-------:| | 1 | 範例測資 | $10\%$ | | 2 | $1 \le m \le 100$ | $20\%$ | | 3 | $1 \le m \le 3.5\times10^{5}$ | $60\%$ | | 4 | 無額外限制 | $100\%$ | ### 輸出說明 輸出一個正整數 $n$ 表示能使用零錢湊齊 $m$ 元的最大方法數 > $n$ | Sample Input#1 | Sample Output#1 | | -------------- | --------------- | | 2 | 1 | | Sample Input#2 | Sample Output#2 | | -------------- | --------------- | | 6 | 2 | | Sample Input#3 | Sample Output#3 | | -------------- | --------------- | | 13 | 4 | ### 提示 範例測資說明 範測 1: 因為金額 $m = 2$ 能使用面額分別為 $50$、$10$、$5$、$1$ 元的零錢組成 2 元的方法: 1. 2 個 1 元 只有 1 種方法 所以輸出 1 範測 2: 因為金額 $m = 6$ 能使用面額分別為 $50$、$10$、$5$、$1$ 元的零錢組成 6 元的方法: 6 個 1 元 1 個 5 元 + 1 個 1 元 有 2 種方法 所以輸出 2 範測 3: 因為金額 $m = 13$ 能使用面額分別為 $50$、$10$、$5$、$1$ 元的零錢組成 13 元的方法: 13 個 1 元 1 個 5 元 + 8 個 1 元 2 個 5 元 + 3 個 1 元 1 個 10 元 + 3 個 1 元 有 4 種方法 所以輸出 4 如果分數只拿到 NA60% 請看一下輸入說明並回想一下第三節社課教的變數型態 > 這題測資有卡 int 範圍 所以要開 long long ### 標籤 迴圈,枚舉,變數 ### 出處 南大附中, 第一屆, 社內練習賽 ### 參考解法 ```cpp= #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long ans = 0; for(int i=0; i <= n / 50; i++) { for(int j=0; j <= (n - i*50) / 10; j++) { ans += (n - i*50 - j*10) / 5 + 1; } } cout << ans << "\n"; return 0; } ``` --- ### 測資生成 子任務 2 ```cpp= void make() { int n = randint() % 100 + 1; cout << n << endl; } ``` 子任務 3 ```cpp= void make() { int n = randint() % (int)3.5e5 + 1; cout << n << endl; } ``` 子任務 4 ```cpp= void make() { int n = randint() % (int)5e5 + 1; cout << n << endl; } ```
×
Sign in
Email
Password
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