中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

做靜態(tài)網(wǎng)站的開(kāi)題報(bào)告百度電話怎么轉(zhuǎn)人工客服

做靜態(tài)網(wǎng)站的開(kāi)題報(bào)告,百度電話怎么轉(zhuǎn)人工客服,全國(guó)裝修公司大概多少家,怎么做 在線電影網(wǎng)站🍭 大家好這里是KK愛(ài)Coding ,一枚熱愛(ài)算法的程序員 ? 本系列打算持續(xù)跟新華為近期的春秋招筆試題匯總~ 💻 ACM銀牌🥈| 多次AK大廠筆試 | 編程一對(duì)一輔導(dǎo) 👏 感謝大家的訂閱? 和 喜歡&#x1f…

🍭 大家好這里是KK愛(ài)Coding ,一枚熱愛(ài)算法的程序員

? 本系列打算持續(xù)跟新華為近期的春秋招筆試題匯總~

💻 ACM銀牌🥈| 多次AK大廠筆試 | 編程一對(duì)一輔導(dǎo)

👏 感謝大家的訂閱? 和 喜歡💗

📧 KK這邊最近正在收集近一年互聯(lián)網(wǎng)各廠的筆試題匯總,如果有需要的小伙伴可以關(guān)注后私信一下 KK領(lǐng)取,會(huì)在飛書(shū)進(jìn)行同步的跟新。

文章目錄

    • 🧷 01.K小姐的生日派對(duì)
      • 問(wèn)題描述
      • 輸入格式
      • 輸出格式
      • 樣例輸入
      • 樣例輸出
      • 數(shù)據(jù)范圍
      • 題解
      • 參考代碼
    • 🔗 02.LYA 的生日派對(duì)邀請(qǐng)函傳遞
      • 問(wèn)題描述
      • 輸入格式
      • 輸出格式
      • 樣例輸入
      • 樣例輸出
      • 數(shù)據(jù)范圍
      • 題解
      • 參考代碼
    • 📎 03.LYA 的生日蛋糕訂購(gòu)
      • 問(wèn)題描述
      • 輸入格式
      • 輸出格式
      • 樣例輸入
      • 樣例輸出
      • 數(shù)據(jù)范圍
      • 題解
      • 參考代碼
    • 寫(xiě)在最后
    • 📧 KK這邊最近正在收集近一年互聯(lián)網(wǎng)各廠的筆試題匯總,如果有需要的小伙伴可以關(guān)注后私信一下 KK領(lǐng)取,會(huì)在飛書(shū)進(jìn)行同步的跟新。

🧷 01.K小姐的生日派對(duì)

問(wèn)題描述

K小姐即將迎來(lái)自己的生日,為了慶祝這一天,她邀請(qǐng)了許多朋友來(lái)參加生日派對(duì)。派對(duì)結(jié)束后,K小姐發(fā)現(xiàn)有一位朋友在派對(duì)上出現(xiàn)的次數(shù)超過(guò)了所有朋友總出現(xiàn)次數(shù)的一半。K小姐很想知道這位朋友是誰(shuí),你能幫助她找出這位神秘朋友嗎?

輸入格式

輸入包含一行,為一個(gè)以逗號(hào)分隔的正整數(shù)列表,表示每位朋友的編號(hào)。編號(hào)范圍為 1 1 1 100000 100000 100000,朋友總數(shù)不超過(guò) 1000 1000 1000。

輸出格式

輸出一個(gè)整數(shù),表示出現(xiàn)次數(shù)超過(guò)總出現(xiàn)次數(shù)一半的朋友編號(hào)。如果不存在這樣的朋友,則輸出 0 0 0

當(dāng)朋友總數(shù)為偶數(shù) n n n 時(shí),超過(guò)總數(shù)一半意味著出現(xiàn)次數(shù)大于 n 2 \frac{n}{2} 2n?;當(dāng)朋友總數(shù)為奇數(shù) n n n 時(shí),超過(guò)總數(shù)一半意味著出現(xiàn)次數(shù)大于 n + 1 2 \frac{n+1}{2} 2n+1?。

樣例輸入

1,2,3,2,2

樣例輸出

2

數(shù)據(jù)范圍

  • 1 ≤ 1 \leq 1 朋友編號(hào) ≤ 100000 \leq 100000 100000
  • 1 < 1 < 1< 朋友總數(shù) < 1000 < 1000 <1000

題解

本題可以使用模擬的方法求解。我們可以用一個(gè)數(shù)組 c n t cnt cnt 來(lái)記錄每個(gè)朋友出現(xiàn)的次數(shù),然后遍歷這個(gè)數(shù)組,判斷是否存在出現(xiàn)次數(shù)超過(guò)總出現(xiàn)次數(shù)一半的朋友。

具體步驟如下:

  1. 初始化一個(gè)長(zhǎng)度為 100001 100001 100001 的數(shù)組 c n t cnt cnt,用于記錄每個(gè)朋友出現(xiàn)的次數(shù)。
  2. 讀入朋友編號(hào)序列,對(duì)于每個(gè)編號(hào) x x x,將 c n t [ x ] cnt[x] cnt[x] 的值加 1 1 1,同時(shí)累加朋友總數(shù) t o t a l total total。
  3. 計(jì)算出現(xiàn)次數(shù)的臨界值 h a l f half half,即 ? t o t a l 2 ? \lfloor \frac{total}{2} \rfloor ?2total??
  4. 遍歷數(shù)組 c n t cnt cnt,判斷是否存在某個(gè)元素的值大于 h a l f half half,如果存在則輸出對(duì)應(yīng)的朋友編號(hào),否則輸出 0 0 0。

時(shí)間復(fù)雜度為 O ( n ) O(n) O(n),其中 n n n 為朋友總數(shù)。空間復(fù)雜度為 O ( m ) O(m) O(m),其中 m m m 為朋友編號(hào)的范圍。

參考代碼

  • Python
friends = list(map(int, input().split(',')))
cnt = [0] * 100001
total = 0for x in friends:cnt[x] += 1total += 1half = total // 2for i in range(1, 100001):if cnt[i] > half:print(i)exit(0)print(0)
  • Java
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String[] input = sc.nextLine().split(",");int[] cnt = new int[100001];int total = 0;for (String x : input) {int num = Integer.parseInt(x);cnt[num]++;total++;}int half = total / 2;for (int i = 1; i <= 100000; i++) {if (cnt[i] > half) {System.out.println(i);return;}}System.out.println(0);}
}
  • Cpp
#include <iostream>
using namespace std;const int MAXN = 100001;int main() {int cnt[MAXN] = {0};int total = 0;string input;getline(cin, input);int pos = 0;while (pos < input.size()) {int num = 0;while (pos < input.size() && input[pos] != ',') {num = num * 10 + (input[pos] - '0');pos++;}cnt[num]++;total++;pos++;}int half = total / 2;for (int i = 1; i < MAXN; i++) {if (cnt[i] > half) {cout << i << endl;return 0;}}cout << 0 << endl;return 0;
}

🔗 02.LYA 的生日派對(duì)邀請(qǐng)函傳遞

問(wèn)題描述

LYA 正在籌備自己的生日派對(duì),她邀請(qǐng)了公司里的許多同事。為了方便傳遞邀請(qǐng)函,LYA 決定采用一種特殊的方式:當(dāng)一位同事收到邀請(qǐng)函后,如果 TA 所在的部門(mén)在允許傳遞的部門(mén)列表中,就將邀請(qǐng)函傳遞給周?chē)?上、下、左、右)的同事;否則,就不再傳遞。

公司的辦公室可以看作一個(gè) n × m n \times m n×m 的網(wǎng)格,每個(gè)格子代表一個(gè)工位。LYA 的工位位于 ( x , y ) (x, y) (x,y),她會(huì)在這里開(kāi)始傳遞邀請(qǐng)函。

給定辦公室的布局、LYA 的工位坐標(biāo)以及允許傳遞邀請(qǐng)函的部門(mén)列表,請(qǐng)問(wèn)最終會(huì)有多少人收到邀請(qǐng)函?

輸入格式

第一行包含兩個(gè)整數(shù) n n n m m m,表示辦公室的行數(shù)和列數(shù)。

接下來(lái) n n n 行,每行包含 m m m 個(gè)整數(shù),表示辦公室的布局。每個(gè)整數(shù)代表該位置上同事所在的部門(mén)編號(hào)。

再接下來(lái)一行包含兩個(gè)整數(shù) x x x y y y,表示 LYA 的工位坐標(biāo)。

最后一行包含若干個(gè)整數(shù),表示允許傳遞邀請(qǐng)函的部門(mén)列表,整數(shù)之間用空格隔開(kāi)。

輸出格式

輸出一個(gè)整數(shù),表示最終收到邀請(qǐng)函的人數(shù)。

樣例輸入

5 5
1 3 5 2 3
2 2 1 3 5
2 2 1 3 3
4 4 1 1 1
1 1 5 1 2
2 2
1

樣例輸出

5

數(shù)據(jù)范圍

  • 1 ≤ n , m ≤ 1000 1 \leq n, m \leq 1000 1n,m1000
  • 1 ≤ 1 \leq 1 部門(mén)編號(hào) ≤ 50 \leq 50 50
  • 0 ≤ x < n 0 \leq x < n 0x<n
  • 0 ≤ y < m 0 \leq y < m 0y<m
  • 1 ≤ 1 \leq 1 允許傳遞的部門(mén)數(shù)量 ≤ 50 \leq 50 50

題解

本題可以使用 BFS 算法求解。從 LYA 的工位開(kāi)始,將邀請(qǐng)函傳遞給周?chē)耐?如果這些同事所在的部門(mén)允許傳遞邀請(qǐng)函,就將他們加入隊(duì)列中,并標(biāo)記為已訪問(wèn)。不斷從隊(duì)列中取出同事,重復(fù)上述過(guò)程,直到隊(duì)列為空。最終訪問(wèn)過(guò)的同事數(shù)量就是收到邀請(qǐng)函的人數(shù)。

具體步驟如下:

  1. 使用二維數(shù)組 g r i d grid grid 存儲(chǔ)辦公室的布局, g r i d [ i ] [ j ] grid[i][j] grid[i][j] 表示位置 ( i , j ) (i, j) (i,j) 上同事所在的部門(mén)編號(hào)。
  2. 使用集合 a l l o w e d allowed allowed 存儲(chǔ)允許傳遞邀請(qǐng)函的部門(mén)列表。
  3. 使用二維數(shù)組 v i s vis vis 標(biāo)記每個(gè)位置是否被訪問(wèn)過(guò),初始時(shí)除了 LYA 的工位外,其余位置都未被訪問(wèn)。
  4. 創(chuàng)建一個(gè)隊(duì)列 q q q,將 LYA 的工位坐標(biāo) ( x , y ) (x, y) (x,y) 加入隊(duì)列,并標(biāo)記為已訪問(wèn)。
  5. 初始化答案 a n s = 0 ans = 0 ans=0,表示收到邀請(qǐng)函的人數(shù)。
  6. 當(dāng)隊(duì)列不為空時(shí),重復(fù)以下步驟:
    • 從隊(duì)列中取出一個(gè)位置 ( i , j ) (i, j) (i,j)。
    • 枚舉 ( i , j ) (i, j) (i,j) 的四個(gè)相鄰位置 ( n i , n j ) (ni, nj) (ni,nj):
      • 如果 ( n i , n j ) (ni, nj) (ni,nj) 在網(wǎng)格范圍內(nèi),且未被訪問(wèn)過(guò),且 g r i d [ n i ] [ n j ] grid[ni][nj] grid[ni][nj] a l l o w e d allowed allowed 中,則將 ( n i , n j ) (ni, nj) (ni,nj) 加入隊(duì)列,標(biāo)記為已訪問(wèn),并將 a n s ans ans 1 1 1
  7. 返回答案 a n s ans ans

時(shí)間復(fù)雜度 O ( n m ) O(nm) O(nm),空間復(fù)雜度 O ( n m ) O(nm) O(nm)。其中 n n n m m m 分別為辦公室的行數(shù)和列數(shù)。

參考代碼

  • Python
from collections import dequen = int(input())
m = int(input())
grid = [list(map(int, input().split())) for _ in range(n)]
x, y = map(int, input().split())
allowed = set(map(int, input().split()))vis = [[False] * m for _ in range(n)]
vis[x][y] = Trueq = deque([(x, y)])
ans = 0while q:i, j = q.popleft()for ni, nj in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:if 0 <= ni < n and 0 <= nj < m and not vis[ni][nj] and grid[ni][nj] in allowed:vis[ni][nj] = Trueq.append((ni, nj))ans += 1print(ans)
  • Java
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt(), m = sc.nextInt();int[][] grid = new int[n][m];for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {grid[i][j] = sc.nextInt();}}int x = sc.nextInt(), y = sc.nextInt();Set<Integer> allowed = new HashSet<>();while (sc.hasNextInt()) {allowed.add(sc.nextInt());}boolean[][] vis = new boolean[n][m];vis[x][y] = true;Queue<int[]> q = new LinkedList<>();q.offer(new int[]{x, y});int ans = 0;int[][] dirs = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};while (!q.isEmpty()) {int[] pos = q.poll();int i = pos[0], j = pos[1];for (int[] dir : dirs) {int ni = i + dir[0], nj = j + dir[1];if (ni >= 0 && ni < n && nj >= 0 && nj < m && !vis[ni][nj] && allowed.contains(grid[ni][nj])) {vis[ni][nj] = true;q.offer(new int[]{ni, nj});ans++;}}}System.out.println(ans);}
}
  • Cpp
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
using namespace std;int main() {int n, m;cin >> n >> m;vector<vector<int>> grid(n, vector<int>(m));for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {cin >> grid[i][j];}}int x, y;cin >> x >> y;unordered_set<int> allowed;int dept;while (cin >> dept) {allowed.insert(dept);}vector<vector<bool>> vis(n, vector<bool>(m, false));vis[x][y] = true;queue<pair<int, int>> q;q.push({x, y});int ans = 0;int dx[4] = {1, -1, 0, 0};int dy[4] = {0, 0, 1, -1};while (!q.empty()) {auto [i, j] = q.front();q.pop();for (int k = 0; k < 4; k++) {int ni = i + dx[k], nj = j + dy[k];if (ni >= 0 && ni < n && nj >= 0 && nj < m && !vis[ni][nj] && allowed.count(grid[ni][nj])) {vis[ni][nj] = true;q.push({ni, nj});ans++;}}}cout << ans << endl;return 0;
}

📎 03.LYA 的生日蛋糕訂購(gòu)

問(wèn)題描述

LYA 的生日快到了,她打算訂購(gòu)一個(gè)特別的生日蛋糕。蛋糕店提供了若干種口味的蛋糕,每種口味的蛋糕都有對(duì)應(yīng)的卡路里。為了保持身材,LYA 希望蛋糕的總卡路里在一定范圍內(nèi)。

現(xiàn)在給定蛋糕店提供的各種口味蛋糕的卡路里,以及 LYA 希望的總卡路里范圍,請(qǐng)問(wèn) LYA 有多少種選擇方案?

注意:

  1. 每種口味的蛋糕可以選擇任意多個(gè)。
  2. 不同口味的蛋糕卡路里各不相同。

輸入格式

第一行包含兩個(gè)整數(shù) l o w low low h i g h high high,表示 LYA 希望的蛋糕總卡路里的下限和上限。

第二行包含若干個(gè)整數(shù),表示蛋糕店提供的各種口味蛋糕的卡路里,整數(shù)之間用空格隔開(kāi)。

輸出格式

輸出一個(gè)整數(shù),表示 LYA 的選擇方案數(shù)。

樣例輸入

350 500
100 200 500

樣例輸出

7

數(shù)據(jù)范圍

  • 1 ≤ l o w ≤ 1000 1 \leq low \leq 1000 1low1000
  • 1 ≤ h i g h ≤ 1000 1 \leq high \leq 1000 1high1000
  • 1 ≤ 1 \leq 1 蛋糕種類數(shù) ≤ 100 \leq 100 100
  • 100 ≤ 100 \leq 100 每種蛋糕的卡路里 ≤ 1000 \leq 1000 1000

題解

本題可以轉(zhuǎn)化為一個(gè)完全背包問(wèn)題。我們可以將蛋糕店提供的各種口味蛋糕看作物品,每種蛋糕的卡路里看作物品的重量,LYA 希望的總卡路里范圍看作背包的容量范圍。

定義 d p [ i ] dp[i] dp[i] 表示總卡路里恰好為 i i i 的方案數(shù)。初始時(shí) d p = 1 dp = 1 dp=1,表示不選任何蛋糕的方案數(shù)為 1 1 1。

對(duì)于每種蛋糕,我們可以選擇任意多個(gè)。因此,對(duì)于第 j j j 種蛋糕,我們可以從 i = c a l [ j ] i=cal[j] i=cal[j] 開(kāi)始更新 d p dp dp 數(shù)組:

d p [ i ] = d p [ i ] + d p [ i ? c a l [ j ] ] dp[i] = dp[i] + dp[i-cal[j]] dp[i]=dp[i]+dp[i?cal[j]]

其中 c a l [ j ] cal[j] cal[j] 表示第 j j j 種蛋糕的卡路里。

最后,將 d p [ l o w ] dp[low] dp[low] d p [ h i g h ] dp[high] dp[high] 的值累加起來(lái),就得到了 LYA 的選擇方案數(shù)。

時(shí)間復(fù)雜度 O ( n × h i g h ) O(n \times high) O(n×high),空間復(fù)雜度 O ( h i g h ) O(high) O(high)。其中 n n n 為蛋糕種類數(shù), h i g h high high 為總卡路里上限。

參考代碼

  • Python
low, high = map(int, input().split())
cal = list(map(int, input().split()))dp = [0] * (high + 1)
dp[0] = 1for c in cal:for i in range(c, high + 1):dp[i] += dp[i - c]print(sum(dp[low:high+1]))
  • Java
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int low = sc.nextInt();int high = sc.nextInt();int n = 0;while (sc.hasNextInt()) {n++;sc.nextInt();}int[] cal = new int[n];for (int i = 0; i < n; i++) {cal[i] = sc.nextInt();}long[] dp = new long[high + 1];dp[0] = 1;for (int c : cal) {for (int i = c; i <= high; i++) {dp[i] += dp[i - c];}}long ans = 0;for (int i = low; i <= high; i++) {ans += dp[i];}System.out.println(ans);}
}
  • Cpp
#include <iostream>
#include <vector>
using namespace std;int main() {int low, high;cin >> low >> high;vector<int> cal;int c;while (cin >> c) {cal.push_back(c);}vector<long long> dp(high + 1, 0);dp[0] = 1;for (int c : cal) {for (int i = c; i <= high; i++) {dp[i] += dp[i - c];}}long long ans = 0;for (int i = low; i <= high; i++) {ans += dp[i];}cout << ans << endl;return 0;
}

寫(xiě)在最后

📧 KK這邊最近正在收集近一年互聯(lián)網(wǎng)各廠的筆試題匯總,如果有需要的小伙伴可以關(guān)注后私信一下 KK領(lǐng)取,會(huì)在飛書(shū)進(jìn)行同步的跟新。

在這里插入圖片描述

http://www.risenshineclean.com/news/33895.html

相關(guān)文章:

  • 貴港網(wǎng)站建設(shè)公司seo外包公司興田德潤(rùn)
  • 黔江網(wǎng)站建設(shè)推廣軟件賺錢(qián)的平臺(tái)
  • 自貢做網(wǎng)站的公司深圳在線制作網(wǎng)站
  • 橋頭仿做網(wǎng)站搜索引擎營(yíng)銷方案例子
  • 廣州市手機(jī)網(wǎng)站建設(shè)企業(yè)專業(yè)搜索引擎優(yōu)化
  • html5 個(gè)人網(wǎng)站模板世界足球排名
  • 深圳做響應(yīng)式網(wǎng)站公司優(yōu)優(yōu)群排名優(yōu)化軟件
  • 做網(wǎng)站一天賺多少錢(qián)seo崗位有哪些
  • 北京建網(wǎng)站實(shí)力公司app線上推廣是什么工作
  • 網(wǎng)站運(yùn)營(yíng)經(jīng)驗(yàn)百度指數(shù)的使用方法
  • 簡(jiǎn)易企業(yè)網(wǎng)站抖音廣告投放代理商
  • 本網(wǎng)站只做信息展示網(wǎng)站制作平臺(tái)
  • 營(yíng)銷型網(wǎng)站設(shè)計(jì)模板同仁seo排名優(yōu)化培訓(xùn)
  • 中國(guó)城鄉(xiāng)建設(shè)協(xié)會(huì)網(wǎng)站湖南seo推廣多少錢(qián)
  • 公司起名字大全免費(fèi)取名隨州seo
  • wordpress導(dǎo)航添加廣州各區(qū)正在進(jìn)一步優(yōu)化以下措施
  • 陜西省建設(shè)廳三類人員報(bào)名網(wǎng)站哪里可以免費(fèi)推廣廣告
  • 找人做網(wǎng)站服務(wù)器不是自己的怎么辦十大微商推廣平臺(tái)
  • 外貿(mào)網(wǎng)站案例成都百度業(yè)務(wù)員電話
  • 網(wǎng)站建設(shè)在哪個(gè)軟件下做百度灰色關(guān)鍵詞排名技術(shù)
  • 做網(wǎng)站的心得調(diào)價(jià)智能關(guān)鍵詞軟件
  • 網(wǎng)站建設(shè)評(píng)價(jià)標(biāo)準(zhǔn)百度快速查詢
  • 電影網(wǎng)站盜鏈怎么做seo是搜索引擎營(yíng)銷嗎
  • 重慶二級(jí)建造師證書(shū)查詢廣西seo經(jīng)理
  • 成都的網(wǎng)站建設(shè)公司哪家好百度網(wǎng)站禁止訪問(wèn)怎么解除
  • 深圳建設(shè)網(wǎng)站排名剛剛濟(jì)南發(fā)通知
  • 深圳網(wǎng)站快速備案淄博百度推廣
  • led燈外貿(mào)網(wǎng)站建設(shè)百度關(guān)鍵詞刷排名軟件
  • 做網(wǎng)站外國(guó)的服務(wù)器怎么做網(wǎng)絡(luò)廣告推廣
  • 網(wǎng)站策劃模板怎樣做網(wǎng)站推廣