


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、1.短信計(jì)費(fèi)用手機(jī)發(fā)短信,一般一條短信資費(fèi)為0.1 元,但限定每條短信的內(nèi)容在 70 個(gè)字以內(nèi)(包括70個(gè)字)。如果你所發(fā)送的一條短信超過了 70個(gè)字,則大多數(shù)手機(jī)會(huì)按照每 70 個(gè)字一條短 信的限制把它分割成多條短信發(fā)送。 假設(shè)已經(jīng)知道你當(dāng)月所發(fā)送的每條短信的字?jǐn)?shù), 試統(tǒng)計(jì) 一下你當(dāng)月短信的總資費(fèi)。#include <set>#include <map>#include <vector>#include <cstdio>#include <cstring>#include <iostream>#include <a
2、lgorithm>#define ll long long#define inf 2147483647using namespace std;int n;int main()cin >> n;double ans = 0;for(int i = 1; i <= n; i+)int x;cin >> x;ans = ans + (x - 1) / 70 + 1) * 0.1;printf("%.1lfn", ans);return 0;2.集體照醫(yī)學(xué)部口腔 3 班 n 位同學(xué)約定拍集體照, n 大于 1 且不超過 100 。攝影師要求同學(xué)按
3、照身高 站成兩排, 保證第二排的人身高都要大于等于第一排的人, 且第二排的人數(shù)和第一排的人數(shù) 相等或者比第一排多一個(gè)人。輸入 n 位同學(xué)的身高,請(qǐng)問第二排中身高最矮的人的身高是多少?#include <set> #include <map>#include <vector>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define ll long long#define inf 2147483647 usin
4、g namespace std;int n;int a105;int main()while(scanf("%d", &n)if(n = 0)return 0;for(int i = 1; i <= n; i+) cin >> ai;sort(a + 1, a + n + 1);cout << an / 2 + 1 << endl; return 0;3.1020 跳格問題有一種游戲,在紙上畫有很多小方格,第一個(gè)方格為起點(diǎn)(S),最后一個(gè)方格為終點(diǎn)。有一個(gè)棋子,初始位置在起點(diǎn)上,棋子每次可移動(dòng)一次,棋子在起點(diǎn)時(shí),可向前移動(dòng)一
5、個(gè)格子到 第二個(gè)方格內(nèi);棋子在其他方格內(nèi)時(shí),可根據(jù)方格內(nèi)的數(shù)字 Ni 進(jìn)行移動(dòng)。如果 Ni 大于零, 就向前移動(dòng) Ni 個(gè)格子;如果 Ni 小于零,就向后移動(dòng) -Ni 個(gè)格子;如果 Ni 等于零,則此次 原地不動(dòng)一次, 在下一步移動(dòng)時(shí)可向前移動(dòng)一步到下一個(gè)格子。顯然, 如果僅按此方案,會(huì) 出現(xiàn)棋子永遠(yuǎn)移動(dòng)不到終點(diǎn)的情形。 為防止這種情況發(fā)生, 我們規(guī)定, 當(dāng)棋子再次來到它曾 經(jīng)到過的方格時(shí), 它需要原地不動(dòng)一次, 在下一步移動(dòng)時(shí)可向前移動(dòng)一步到下一個(gè)格子。 按 此方案,棋子總能夠走到終點(diǎn)(F)。如果給定一個(gè)方格圖,試求棋子要走多少步才能從起點(diǎn)走到終點(diǎn)。(注:當(dāng)然還可能會(huì)出現(xiàn)向前移動(dòng) Ni 個(gè)格
6、子就跑過終點(diǎn)了, 則把棋子放到終點(diǎn)上。 如果 Ni 太小,使得棋子向后移動(dòng)跑過了起點(diǎn),則把棋子放到起點(diǎn)上。)(如圖所示,其中 S代表起點(diǎn), F 代表終點(diǎn))(只有離開后再次來到一個(gè)方格時(shí),才算來到它曾經(jīng)到過的方格, 包括起點(diǎn) S) #include <set>#include <map>#include <vector> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define ll long lon
7、g #define inf 2147483647 using namespace std; int n, ans; int a105; bool vis105; void dfs(int x) if(x < 1)x = 1;if(x > n + 2)x = n + 2;if(visx)if(ax)ans += 2; else ans += 1; dfs(x + 1);elsevisx = 1;if(x = n + 2)return; ans+;dfs(x + ax);int main()scanf("%d", &n);a1 = 1;for(int i =
8、 2; i <= n + 1; i+) cin >> ai;dfs(1);cout << ans << endl; return 0;4. 配對(duì)堿基鏈脫氧核糖核酸( DNA )由兩條互補(bǔ)的堿基鏈以雙螺旋的方式結(jié)合而成。而構(gòu)成DNA 的堿基共有4種,分別為腺瞟呤(A)、鳥嘌呤(G)、胸腺嘧啶(T)和胞嘧啶(C)。我們知道,在 兩條互補(bǔ)堿基鏈的對(duì)應(yīng)位置上, 腺瞟呤總是和胸腺嘧啶配對(duì), 鳥嘌呤總是和胞嘧啶配對(duì)。 你 的任務(wù)就是根據(jù)一條單鏈上的堿基序列,給出對(duì)應(yīng)的互補(bǔ)鏈上的堿基序列。#include <set>#include <map>
9、;#include <vector>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm> #define ll long long #define inf 2147483647 using namespace std;int n;string x;int main()scanf("%d", &n);for(int i = 1; i <= n; i+)cin >> x;for(int j = 0;
10、 j < x.length(); j+)if(xj = 'T') xj = 'A'else if(xj = 'A')xj = 'T'else if(xj = 'C') xj = 'G'elsexj = 'C'cout << x << endl; return 0;5. 打魚還是曬網(wǎng) 中國有句俗語叫“三天打魚兩天曬網(wǎng)”。某人從 1990 年 1 月 1 日起開始“三天打魚兩 天曬網(wǎng)”,問這個(gè)人在以后的某一天中是“打魚”還是“曬網(wǎng)”。 注意要區(qū)分閏年和不是閏
11、年的兩種情況#include <set>#include <map>#include <vector>#include <cstdio> #include <cstring>#include <iostream> #include <algorithm>#define ll long long#define inf 2147483647 using namespace std;int y, m, d;int mm12 = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 3
12、1; int tot;int main()cin >> y >> m >> d;for(int i = 1990; i < y; i+)if(i % 4 = 0 && i % 100 != 0) | i % 400 = 0) tot += 366;else tot += 365;for(int i = 1; i < m; i+)if(y % 4 = 0 && y % 100 != 0) | y % 400 = 0) && i = 2) tot += 29;elsetot += mmi - 1; to
13、t += (d - 1); if(tot % 5 <= 2) puts("fishing");elseputs("sleeping"); return 0;6. 優(yōu)先隊(duì)列給定一個(gè)初始數(shù)字集合,對(duì)其做如下兩種操作:1. 添加一個(gè)新的數(shù)字只取出其中一個(gè)。2. 將集合中當(dāng)前最小的數(shù)字取出 (輸出并刪除) ,如果最小的數(shù)字有多個(gè),#include <set>#include <map>#include <queue>#include <vector>#include <cstdio>#includ
14、e <cstring>#include <iostream>#include <algorithm>#define ll long long#define inf 2147483647using namespace std;int n, m;struct dataint a200005;int cnt;bool empty()return cnt = 0;void push(int x) a+cnt = x; int p = cnt;while(p > 1 && ap < ap / 2)swap(ap, ap / 2); p =
15、p / 2;int top()return a1;void down(int x)int t = x << 1;if(t > cnt)return;if(t + 1 <= cnt && at + 1 < at) t+;if(at < ax)swap(at, ax);down(t);void pop()a1 = acnt; cnt-; down(1);q;int main()cin >> n;for(int i = 1; i <= n; i+)int x;cin >> x;q.push(x);cin >>
16、; m;char opt15;for(int i = 1; i <= m; i+)scanf("%s", opt);if(opt0 = 'E')if(q.empty()puts("NULL");elsecout << q.top() << endl;q.pop();elseint x;cin >> x;q.push(x);return 0;7. 護(hù)林員蓋房子 在一片保護(hù)林中,護(hù)林員想要蓋一座房子來居住,但他不能砍伐任何樹木。 現(xiàn)在請(qǐng)你幫他計(jì)算:保護(hù)林中所能用來蓋房子的矩形空地的最大面積。#incl
17、ude <set>#include <map>#include <queue>#include <vector>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define ll long long#define inf 2147483647using namespace std;int n, m;int ans;int v2525;bool check(int a, int b, int c, i
18、nt d) for(int i = a; i <= c; i+) for(int j = b; j <= d; j+) if(vij)return 0;return 1;int main()cin >> n >> m;for(int i = 1; i <= n; i+) for(int j = 1; j <= m; j+)cin >> vij;for(int i = 1; i <= n; i+)for(int j = 1; j <= m; j+)for(int k = i; k <= n; k+)for(int l
19、= j; l <= m; l+)if(check(i, j, k, l)ans = max(ans, (k - i + 1) * (l - j + 1); cout << ans << endl;return 0;8. 汽車限行 為了緩解交通壓力、減少空氣污染, B 市市政府決定在工作日(周一至周五)對(duì)機(jī)動(dòng)車進(jìn)行 限行,每輛機(jī)動(dòng)車每周將有一個(gè)工作日不能出行,但周末不限行。假設(shè)該政策從 2000 年 1 月 1 日起開始執(zhí)行。限行安排為:尾號(hào)為 1 和 6:周一限行尾號(hào)為 2 和 7:周二限行尾號(hào)為 3 和 8:周三限行尾號(hào)為 4 和 9:周四限行尾號(hào)為 5、0 和
20、字母:周五限行已知 2000 年 1 月 1 日為周六, 現(xiàn)在給出一些日期和車牌號(hào), 求問該機(jī)動(dòng)車在該天是否限行。#include <set>#include <map>#include <vector>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm> #define ll long long #define inf 2147483647 using namespace std;int T;int y, m, d
21、;int mm12 = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31;int main() cin >> T; while(T-) char ch; cin >> y >> ch >>m >> ch >> d;string s; cin >> s; int day, tot = 0; if(s5 > '9' | s5 < '0')day = 5; else day = (s5 - '0') % 5; if
22、(day = 0)day = 5; for(int i = 2000; i < y; i+) if(i % 4 = 0 && i % 100 != 0) | i % 400 = 0) tot += 366;else tot += 365;for(int i = 1; i < m; i+)if(y % 4 = 0 && y % 100 != 0) | y % 400 = 0) && i = 2) tot += 29;elsetot += mmi - 1;tot += (d - 1);if(tot + 6 - 1) % 7 + 1 = d
23、ay) puts("yes");else puts("no"); return 0;9. 人工智能 人工智能一直是計(jì)算機(jī)學(xué)所追求的一個(gè)很高的境界, 全世界的計(jì)算機(jī)學(xué)家們至今仍在不斷努 力力求達(dá)到這個(gè)境界。這道題也跟“人工智能”有關(guān)。學(xué)過初中物理的同學(xué)都應(yīng)該知道物理學(xué)中的這個(gè)公式P (功率)=U (電壓)* I (電流)。如果給定其中的任意兩個(gè)值,第三個(gè)值都是很容易求的,這個(gè)就是本題的任務(wù)。#include <set>#include <map>#include <vector>#include <cstdio>#include <string>#include <cstring>#include <iostream>#include <algorithm>#define ll long long#define inf 2147483647 using namespace std; int T;string s;map<char, double> mp;double get(int x)double v = 0, t = 1;for(int i = x; i < s.length();
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 現(xiàn)代漢語表達(dá)層次試題及答案
- 現(xiàn)代漢語練習(xí)題庫試題及答案
- 計(jì)算機(jī)一級(jí)WPS考點(diǎn)剖析試題及答案
- 一級(jí)Photoshop考試知識(shí)要點(diǎn)總結(jié)試題及答案
- 計(jì)算機(jī)一級(jí)Photoshop考試細(xì)分領(lǐng)域解析試題及答案
- 未來公司競爭優(yōu)勢與風(fēng)險(xiǎn)規(guī)避策略試題及答案
- Msoffice文獻(xiàn)管理技巧試題及答案
- 尤其關(guān)注的2025年稅法考試試題及答案
- MS Office各模塊總結(jié)試題及答案
- 現(xiàn)代漢語的社會(huì)文化啟示試題及答案
- 醫(yī)院護(hù)工面試題及答案
- 高校學(xué)生資助誠信教育主題活動(dòng)
- 跨國公司海外人力資源外包與派遣管理合同
- LNG 加氣站防雷安全培訓(xùn)與應(yīng)急演練記錄 202505
- 普惠金融專員試題及答案
- 【課件】認(rèn)識(shí)民法典+課件統(tǒng)編版道德與法治七年級(jí)下冊
- 2025年航天知識(shí)競賽題庫及答案
- 2025年人教版小學(xué)小升初科學(xué)模擬試卷(含答案解析)
- 腸易激綜合征中西醫(yī)結(jié)合診療專家共識(shí)(2025)解讀課件
- 《金屬疲勞與斷裂》課件
- 2025年《民法典》應(yīng)知應(yīng)會(huì)知識(shí)競賽題庫(含各題型)
評(píng)論
0/150
提交評(píng)論