日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2018第九届蓝桥省赛题目

發布時間:2025/4/16 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2018第九届蓝桥省赛题目 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


標題:第幾天

2000年的1月1日,是那一年的第1天。
那么,2000年的5月4日,是那一年的第幾天? ?


注意:需要提交的是一個整數,不要填寫任何多余內容。



該題很簡單:125

?


標題:明碼

漢字的字形存在于字庫中,即便在今天,16點陣的字庫也仍然使用廣泛。
16點陣的字庫把每個漢字看成是16x16個像素信息。并把這些信息記錄在字節中。

一個字節可以存儲8位信息,用32個字節就可以存一個漢字的字形了。
把每個字節轉為2進制表示,1表示墨跡,0表示底色。每行2個字節,
一共16行,布局是:

? ? 第1字節,第2字節
? ? 第3字節,第4字節
? ? ....
? ? 第31字節, 第32字節

這道題目是給你一段多個漢字組成的信息,每個漢字用32個字節表示,這里給出了字節作為有符號整數的值。

題目的要求隱藏在這些信息中。你的任務是復原這些漢字的字形,從中看出題目的要求,并根據要求填寫答案。

這段信息是(一共10個漢字):
4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0?
16 64 16 64 34 68 127 126 66 -124 67 4 66 4 66 -124 126 100 66 36 66 4 66 4 66 4 126 4 66 40 0 16?
4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0?
0 -128 64 -128 48 -128 17 8 1 -4 2 8 8 80 16 64 32 64 -32 64 32 -96 32 -96 33 16 34 8 36 14 40 4?
4 0 3 0 1 0 0 4 -1 -2 4 0 4 16 7 -8 4 16 4 16 4 16 8 16 8 16 16 16 32 -96 64 64?
16 64 20 72 62 -4 73 32 5 16 1 0 63 -8 1 0 -1 -2 0 64 0 80 63 -8 8 64 4 64 1 64 0 -128?
0 16 63 -8 1 0 1 0 1 0 1 4 -1 -2 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 0 2 0?
2 0 2 0 7 -16 8 32 24 64 37 -128 2 -128 12 -128 113 -4 2 8 12 16 18 32 33 -64 1 0 14 0 112 0?
1 0 1 0 1 0 9 32 9 16 17 12 17 4 33 16 65 16 1 32 1 64 0 -128 1 0 2 0 12 0 112 0?
0 0 0 0 7 -16 24 24 48 12 56 12 0 56 0 -32 0 -64 0 -128 0 0 0 0 1 -128 3 -64 1 -128 0 0?


注意:需要提交的是一個整數,不要填寫任何多余內容。
?

題解:使用STL中的bitset()比較容易求解

得到一句話:九的九次方是多少?

答案:387420489

#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<bitset>using namespace std;int main() {int a, b;while(cin >> a >> b){bitset<8> bt(a);string s1 = bt.to_string();for(int i = 0; i < s1.length(); i++){if(s1[i] == '0') printf(" ");else printf("*");}bitset<8> bt2(b);string s2 = bt2.to_string();for(int i = 0; i < s2.length(); i++){if(s2[i] == '0') printf(" ");else printf("*");}printf("\n");}return 0; }

?


標題:乘積尾零

如下的10行數據,每行有10個整數,請你求出它們的乘積的末尾有多少個零?

5650 4542 3554 473 946 4114 3871 9073 90 4329?
2758 7949 6113 5659 5245 7432 3051 4434 6704 3594?
9937 1173 6866 3397 4759 7557 3070 2287 1453 9899?
1486 5722 3135 1170 4014 5510 5120 729 2880 9019?
2049 698 4582 4346 4427 646 9742 7340 1230 7683?
5693 7015 6887 7381 4172 4341 2909 2027 7355 5649?
6701 6645 1671 5978 2704 9926 295 3125 3878 6785?
2066 4247 4800 1578 6652 4616 1113 6205 3264 2915?
3966 5291 2904 1285 2193 1428 2265 8730 9436 7074?
689 5510 8243 6114 337 4096 8199 7313 3685 211?

注意:需要提交的是一個整數,表示末尾零的個數。不要填寫任何多余內容。
?

答案:31

JAVA大數:

package text; import java.math.*; public class sum {public static void main(String[] args) {int num[] = {5650 ,4542 ,3554, 473 ,946, 4114 ,3871, 9073 ,90, 4329 ,2758 ,7949 ,6113, 5659 ,5245, 7432, 3051, 4434, 6704 ,3594, 9937 ,1173 ,6866 ,3397, 4759, 7557 ,3070 ,2287 ,1453, 9899 ,1486 ,5722 ,3135 ,1170, 4014 ,5510, 5120, 729,2880, 9019 ,2049 ,698, 4582, 4346, 4427, 646 ,9742 ,7340 ,1230, 7683 ,5693, 7015, 6887, 7381, 4172, 4341, 2909, 2027, 7355, 5649 ,6701, 6645, 1671, 5978 ,2704, 9926, 295, 3125, 3878, 6785 ,2066 ,4247, 4800 ,1578, 6652, 4616, 1113 ,6205, 3264, 2915 ,3966, 5291, 2904, 1285, 2193, 1428 ,2265 ,8730, 9436, 7074 ,689 ,5510 ,8243, 6114, 337, 4096, 8199, 7313 ,3685, 211};BigInteger sum, tmp;sum = BigInteger.valueOf(1);for(int i = 0;i < num.length;i ++){tmp = BigInteger.valueOf(num[i]);sum = sum.multiply(tmp);}System.out.println(sum);}}

c++實現:只需要找出2和5的最小組合

#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<map> #include<cmath>using namespace std;int a[] = {5650, 4542, 3554, 473, 946, 4114, 3871, 9073, 90, 4329, 2758, 7949, 6113, 5659, 5245, 7432, 3051, 4434, 6704, 3594, 9937, 1173, 6866, 3397, 4759, 7557, 3070, 2287, 1453, 9899, 1486, 5722, 3135, 1170, 4014, 5510, 5120, 729, 2880, 9019, 2049, 698, 4582, 4346, 4427, 646, 9742, 7340, 1230, 7683, 5693, 7015, 6887, 7381, 4172, 4341, 2909, 2027, 7355, 5649, 6701, 6645, 1671, 5978, 2704, 9926, 295, 3125, 3878, 6785, 2066, 4247, 4800, 1578, 6652, 4616, 1113, 6205, 3264, 2915, 3966, 5291, 2904, 1285, 2193, 1428, 2265, 8730, 9436, 7074, 689, 5510, 8243, 6114, 337, 4096, 8199, 7313, 3685 ,211};int main() {int ans1 = 0, ans2 = 0;int sum1 = 0, sum2 = 0;for(int i = 0; i < 100; i++){int t = a[i];for(int j = 2; j*j < t; j++){int cnt = 0;while(t % j == 0){t /= j;cnt++;}if(j == 2) ans1 = cnt;if(j == 5) ans2 = cnt;}if(t != 1){if(t == 2) ans1 = 1;if(t == 5) ans2 = 1;}sum1 += ans1; sum2 += ans2;}printf("%d %d\n", sum1, sum2);return 0; }

?


標題:測試次數

x星球的居民脾氣不太好,但好在他們生氣的時候唯一的異常舉動是:摔手機。
各大廠商也就紛紛推出各種耐摔型手機。x星球的質監局規定了手機必須經過耐摔測試,并且評定出一個耐摔指數來,之后才允許上市流通。

x星球有很多高聳入云的高塔,剛好可以用來做耐摔測試。塔的每一層高度都是一樣的,與地球上稍有不同的是,他們的第一層不是地面,而是相當于我們的2樓。

如果手機從第7層扔下去沒摔壞,但第8層摔壞了,則手機耐摔指數=7。
特別地,如果手機從第1層扔下去就壞了,則耐摔指數=0。
如果到了塔的最高層第n層扔沒摔壞,則耐摔指數=n

為了減少測試次數,從每個廠家抽樣3部手機參加測試。

某次測試的塔高為1000層,如果我們總是采用最佳策略,在最壞的運氣下最多需要測試多少次才能確定手機的耐摔指數呢?

請填寫這個最多測試次數。

注意:需要填寫的是一個整數,不要填寫任何多余內容。


?

?


標題:快速排序。?

以下代碼可以從數組a[]中找出第k小的元素。


它使用了類似快速排序中的分治算法,期望時間復雜度是O(N)的。


請仔細閱讀分析源碼,填寫劃線部分缺失的內容。

#include <stdio.h>

int quick_select(int a[], int l, int r, int k) {
?? ?int p = rand() % (r - l + 1) + l;
?? ?int x = a[p];
?? ?{int t = a[p]; a[p] = a[r]; a[r] = t;}
?? ?int i = l, j = r;
?? ?while(i < j) {
?? ??? ?while(i < j && a[i] < x) i++;
?? ??? ?if(i < j) {
?? ??? ??? ?a[j] = a[i];
?? ??? ??? ?j--;
?? ??? ?}
?? ??? ?while(i < j && a[j] > x) j--;
?? ??? ?if(i < j) {
?? ??? ??? ?a[i] = a[j];
?? ??? ??? ?i++;
?? ??? ?}
?? ?}
?? ?a[i] = x;
?? ?p = i;
?? ?if(i - l + 1 == k) return a[i];
?? ?if(i - l + 1 < k) return quick_select( _____________________________ ); //填空
?? ?else return quick_select(a, l, i - 1, k);
}
?? ?
int main()
{
?? ?int a[] = {1, 4, 2, 8, 5, 7, 23, 58, 16, 27, 55, 13, 26, 24, 12};
?? ?printf("%d\n", quick_select(a, 0, 14, 5));
?? ?return 0;
}


注意:只填寫劃線部分缺少的代碼,不要抄寫已經存在的代碼或符號。

快排填空,很容易:quick_select(a, i+1, r, k - (i-l+1));

?


標題:遞增三元組

給定三個整數數組
A = [A1, A2, ... AN],?
B = [B1, B2, ... BN],?
C = [C1, C2, ... CN],
請你統計有多少個三元組(i, j, k) 滿足:
1. 1 <= i, j, k <= N ?
2. Ai < Bj < Ck ?

【輸入格式】?
第一行包含一個整數N。
第二行包含N個整數A1, A2, ... AN。
第三行包含N個整數B1, B2, ... BN。
第四行包含N個整數C1, C2, ... CN。

對于30%的數據,1 <= N <= 100 ?
對于60%的數據,1 <= N <= 1000?
對于100%的數據,1 <= N <= 100000 0 <= Ai, Bi, Ci <= 100000?

【輸出格式】
一個整數表示答案

【樣例輸入】
3
1 1 1
2 2 2
3 3 3

【樣例輸出】
27?


資源約定:
峰值內存消耗(含虛擬機) < 256M
CPU消耗 ?< 1000ms


請嚴格按要求輸出,不要畫蛇添足地打印類似:“請您輸入...” 的多余內容。

注意:
main函數需要返回0;
只使用ANSI C/ANSI C++ 標準;
不要調用依賴于編譯環境或操作系統的特殊函數。
所有依賴的函數必須明確地在源文件中 #include <xxx>
不能通過工程設置而省略常用頭文件。

提交程序時,注意選擇所期望的語言類型和編譯器類型。
?

#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<vector>using namespace std;const int maxn = 1e5+5;int n; int a[maxn]; int b[maxn]; int c[maxn];int main() {cin >> n;for(int i = 0; i < n; i++) scanf("%d", &a[i]);for(int i = 0; i < n; i++) scanf("%d", &b[i]);for(int i = 0; i < n; i++) scanf("%d", &c[i]);sort(a, a+n);sort(b, b+n);sort(c, c+n);int ans = 0;for(int i = 0; i < n; i++){int x = (lower_bound(a,a+n,b[i]) - a);int y = (n - (upper_bound(c,c+n,b[i]) - c));ans += x*y;}printf("%d\n", ans);return 0; }

?

?

標題:螺旋折線

?

如圖p1.png所示的螺旋折線經過平面上所有整點恰好一次。 ?

對于整點(X, Y),我們定義它到原點的距離dis(X, Y)是從原點到(X, Y)的螺旋折線段的長度。 ?

?

例如dis(0, 1)=3, dis(-2, -1)=9 ?

?

給出整點坐標(X, Y),你能計算出dis(X, Y)嗎?

?

【輸入格式】

X和Y ?

?

對于40%的數據,-1000 <= X, Y <= 1000 ?

對于70%的數據,-100000 <= X, Y <= 100000 ?

對于100%的數據, -1000000000 <= X, Y <= 1000000000 ?

?

【輸出格式】

輸出dis(X, Y) ?

?

?

【樣例輸入】

0 1

?

【樣例輸出】

3

?

?

資源約定:

峰值內存消耗(含虛擬機) < 256M

CPU消耗 ?< 1000ms

?

?

請嚴格按要求輸出,不要畫蛇添足地打印類似:“請您輸入...” 的多余內容。

?

注意:

main函數需要返回0;

只使用ANSI C/ANSI C++ 標準;

不要調用依賴于編譯環境或操作系統的特殊函數。

所有依賴的函數必須明確地在源文件中 #include <xxx>

不能通過工程設置而省略常用頭文件。

?

提交程序時,注意選擇所期望的語言類型和編譯器類型。

#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<cmath>using namespace std;typedef long long LL; LL x, y;int main() {LL sum = 0;scanf("%lld%lld", &x, &y);if(x == 0 && y == 0) sum = 0;else if(x == -1 && y == 0) sum = 1;else if(x > 0 && y > 0){ //第一象限 LL col1, col2, row1, row2;if(x >= y){col1 = x;row1 = x;col2 = x;row2 = x-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += x-y;}else{col1 = y;row1 = y;col2 = y-1;row2 = y-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += y;sum += x;}}else if(x > 0 && y < 0){ //第二象限 LL col1, col2, row1, row2; if(x >= abs(y)){col1 = x;row1 = x;row2 = x;col2 = x-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += x;sum += abs(y); }else{col1 = abs(y);row1 = abs(y);col2 = abs(y);row2 = abs(y);sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += abs(y)-x;}}else if(x < 0 && y < 0){ //第三象限 LL col1, col2, row1, row2;if(abs(x) <= abs(y)+1){col1 = abs(y);row1 = abs(y);col2 = abs(y);row2 = abs(y);sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += abs(y);sum += abs(x); }else{col1 = abs(x);row1 = abs(x)-1;col2 = abs(x)-1;row2 = abs(x)-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += abs(x) - abs(y);}}else if(x < 0 && y > 0){ //第四象限 LL col1, col2, row1, row2;if(abs(x) >= y){col1 = abs(x);row1 = abs(x)-1;col2 = abs(x)-1;row2 = abs(x)-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += abs(x)-1;sum += y;}else{col1 = y;row1 = y;col2 = y-1;row2 = y-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += y-abs(x);}}//坐標軸 else if(y == 0 && x > 0){LL col1, col2, row1, row2;col1 = x;row1 = x;row2 = x;col2 = x-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += y;}else if(x == 0 && y < 0){LL col1, col2, row1, row2;col1 = abs(y);row1 = abs(y);col2 = abs(y);row2 = abs(y);sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += abs(y);}else if(y == 0 && x < 0){LL col1, row1, col2, row2;col1 = abs(x);row1 = abs(x)-1;col2 = abs(x)-1;row2 = abs(x)-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += abs(x)-1;}else if(x == 0 && y > 0){LL col1, col2, row1, row2;col1 = y;row1 = y;col2 = y-1;row2 = y-1;sum += col1 + col1*(col1-1) * 2 / 2;sum += row1 + row1*(row1-1) * 2 / 2;sum += 2*col2 + col2*(col2-1) * 2 / 2;sum += 2*row2 + row2*(row2-1) * 2 / 2;sum += y;}printf("%lld\n", sum);return 0; }

?

?

?

?

?

總結

以上是生活随笔為你收集整理的2018第九届蓝桥省赛题目的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。