当前位置: 首页 > news >正文

过年做哪个网站致富爱站网站长工具

过年做哪个网站致富,爱站网站长工具,捡个校花做老婆是哪个网站的,襄阳专业网站建设恭喜发现宝藏!搜索公众号【TechGuide】回复公司名,解锁更多新鲜好文和互联网大厂的笔经面经。 作者TechGuide【全网同名】 订阅专栏: 【专享版】2024最新大厂笔试真题解析,错过必后悔的宝藏资源! 第一题:找…

恭喜发现宝藏!搜索公众号【TechGuide】回复公司名,解锁更多新鲜好文和互联网大厂的笔经面经。
作者@TechGuide【全网同名】

订阅专栏: 【专享版】2024最新大厂笔试真题解析,错过必后悔的宝藏资源!

第一题:找出最可疑的嫌疑人

题目描述

​民警侦办某商场店面盗窃率时,通过人脸识别针对嫌疑人进行编号1-100000。现在民警在监控记录中发现某个嫌疑人在被盗店面出现的次数超过了所有嫌疑人总出现次数的一半,请帮助民警尽可能高效​地找到该嫌疑人的编号。

输入描述

给定一个嫌疑人的标号数组men,其中1<length(men)<1000,嫌疑人编号满足1<=men[i]<=100000

输出描述

返回出现次数超过一半的嫌疑人的编号。

如果总次数是偶数,例如4,则需要超过2次即最少3次,如果总次数是奇数,例如5,则需要超过2.5,满足条件最少是3次。若没有嫌疑人满足该条件,返回0。

样例

输入

1,1,2,2,3,3

输出

0

样例说明

第一行是嫌疑人出现记录,代表1号、2号和3号嫌疑人各出现2次因为各个嫌疑人均只出现2次,未超过6次的一半,因此没有嫌疑人满足要求,输出0。

思路

简单遍历即可。统计每个嫌疑人编号出现的次数,然后遍历次数,找到出现次数超过总次数一半的编号。

代码

Java版本

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);String[] input = scanner.nextLine().split(",");int[] nums = new int[input.length];for (int i = 0; i < input.length; i++) {nums[i] = Integer.parseInt(input[i]);}Map<Integer, Integer> counter = new HashMap<>();for (int num : nums) {counter.put(num, counter.getOrDefault(num, 0) + 1);}for (int k : counter.keySet()) {if (counter.get(k) > nums.length / 2) {System.out.println(k);return;}}System.out.println(0);}
}
// vx公众号关注TechGuide,专业生产offer收割机。

CPP版本

#include <iostream>
#include <vector>
#include <unordered_map>using namespace std;int main() {string input;getline(cin, input);vector<int> nums;size_t pos = 0;while ((pos = input.find(',')) != string::npos) {nums.push_back(stoi(input.substr(0, pos)));input.erase(0, pos + 1);}nums.push_back(stoi(input));unordered_map<int, int> counter;for (int num : nums) {counter[num]++;}for (const auto& entry : counter) {if (entry.second > nums.size() / 2) {cout << entry.first << endl;return 0;}}cout << 0 << endl;return 0;
}
// vx公众号关注TechGuide,专业生产offer收割机。

第二题:登录赢金币

题目描述

某公司日对新用户推出大礼包,从任意一天注册开始,连续登录x天,每天可以领取一定的金币,领取金币的数量与该公司新设计的虚假世界的日历相关,该日历一年有n个月,第i个月有di天,每一年都一样。在每个月第1天会得到1个金币,第2天会得到2个金币,第3天会得到3个金币,后面依次类推。 请计算新用户注册后连续登陆x天,最多可以获取多少金币。 请注意,连续登陆可能会跨年。

输入描述

第一行包含两个整数n和x,分别表示一年中的月数和连续登陆的天数。第二行包含n个整数d1,d2,…,dn ,di表示第i个月的天数。

输出描述

打印新用户连续登录x天最多可以获取的金币数量。

样例

输入

3 2
1 3 1

输出

5

样例说明

一年中每天获取的金币数是1,1,2,3,1(对应每个月中的天数)。如果在一年中的第3天开始注册陆,最多可以获取 2+3=5 个金币。

思路

用滑动窗口。计算每个月的金币总数和连续登陆的区间内金币总数,通过滑动窗口来更新最大值。注意开始复制了一份,覆盖跨年的情况。

代码

Java版本

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();int x = scanner.nextInt();int[] d = new int[n * 2];for (int i = 0; i < n; i++) {d[i] = scanner.nextInt();d[i + n] = d[i];}int ans = 0;int curSum = 0;int cur = 0;int l = 0;for (int i = 0; i < n * 2; i++) {curSum += d[i];cur += d[i] * (d[i] + 1) / 2;while (curSum > x) {curSum -= d[l];cur -= d[l] * (d[l] + 1) / 2;l++;}int curAns = cur;int cnt = x - curSum;if (l > 0) {curAns += sumup(d[l - 1] - cnt + 1, d[l - 1]);ans = Math.max(ans, curAns);}}System.out.println(ans);}private static int sumup(int l, int r) {return r * (r + 1) / 2 - l * (l - 1) / 2;}
}// vx公众号关注TechGuide,专业生产offer收割机。

CPP版本

#include <iostream>
#include <vector>using namespace std;int sumup(int l, int r) {return r * (r + 1) / 2 - l * (l - 1) / 2;
}int main() {int n, x;cin >> n >> x;vector<int> d(n * 2);for (int i = 0; i < n; i++) {cin >> d[i];d[i + n] = d[i];}int ans = 0;int curSum = 0;int cur = 0;int l = 0;for (int i = 0; i < n * 2; i++) {curSum += d[i];cur += d[i] * (d[i] + 1) / 2;while (curSum > x) {curSum -= d[l];cur -= d[l] * (d[l] + 1) / 2;l++;}int curAns = cur;int cnt = x - curSum;if (l > 0) {curAns += sumup(d[l - 1] - cnt + 1, d[l - 1]);ans = max(ans, curAns);}}cout << ans << endl;return 0;
}// vx公众号关注TechGuide,专业生产offer收割机。

第三题:整数分解

题目描述

给你一个整数N(1 < N < 256),它的一个分解是N = a1 x a2 x a3 x…x ax,其中1 <ai ≤ aj(i≤ j)

对于整数N,请依次输出每一个分解(按照字典序)

例如,给定整数24,输出是

24=2*2*2*3
24=2*2*6
24=2*3*4
24=2*12
24=3*8
24=4*6
24=24

输入描述

输入只有一个整数N

输出描述

按照字典序,依次输出整数N的每一个分解.

样例

输入

11

输出

11=11

思路

递归生成整数N的所有分解,然后按照字典序输出就行了。

代码

Java版本

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();List<List<Integer>> ans = fac(n, 2);for (List<Integer> v : ans) {System.out.print(n + "=");for (int i = 0; i < v.size(); i++) {System.out.print(v.get(i));if (i < v.size() - 1) {System.out.print("*");}}System.out.println();}}private static List<List<Integer>> fac(int n, int p) {List<List<Integer>> result = new ArrayList<>();if (n == 1) {result.add(new ArrayList<>());return result;}for (int i = p; i <= n; i++) {if (n % i == 0) {for (List<Integer> v : fac(n / i, i)) {List<Integer> temp = new ArrayList<>();temp.add(i);temp.addAll(v);result.add(temp);}}}return result;}
}// vx公众号关注TechGuide,专业生产offer收割机。

CPP版本

#include <iostream>
#include <vector>using namespace std;void printResult(int n, vector<int>& vec) {cout << n << "=";for (int i = 0; i < vec.size(); i++) {cout << vec[i];if (i < vec.size() - 1) {cout << "*";}}cout << endl;
}void fac(int n, int p, vector<int>& temp) {if (n == 1) {printResult(n, temp);return;}for (int i = p; i <= n; i++) {if (n % i == 0) {temp.push_back(i);fac(n / i, i, temp);temp.pop_back();}}
}int main() {int n;cin >> n;vector<int> temp;fac(n, 2, temp);return 0;
}// vx公众号关注TechGuide,专业生产offer收割机。

文章转载自:
http://amyotrophia.fzLk.cn
http://haven.fzLk.cn
http://massify.fzLk.cn
http://yemen.fzLk.cn
http://feudatorial.fzLk.cn
http://legionnaire.fzLk.cn
http://oocyst.fzLk.cn
http://bas.fzLk.cn
http://graviton.fzLk.cn
http://unaltered.fzLk.cn
http://exodontia.fzLk.cn
http://indiscipline.fzLk.cn
http://eclectic.fzLk.cn
http://hardtop.fzLk.cn
http://missionize.fzLk.cn
http://rigidify.fzLk.cn
http://foudroyant.fzLk.cn
http://ordzhonikidze.fzLk.cn
http://zygomorphic.fzLk.cn
http://theses.fzLk.cn
http://yesterdayness.fzLk.cn
http://lithium.fzLk.cn
http://psychognosy.fzLk.cn
http://washwoman.fzLk.cn
http://catholicise.fzLk.cn
http://educationalist.fzLk.cn
http://aeropulse.fzLk.cn
http://sermonette.fzLk.cn
http://ymca.fzLk.cn
http://trigeminal.fzLk.cn
http://innately.fzLk.cn
http://glassify.fzLk.cn
http://revolver.fzLk.cn
http://unsoftened.fzLk.cn
http://mocker.fzLk.cn
http://dieffenbachia.fzLk.cn
http://impermeable.fzLk.cn
http://loculus.fzLk.cn
http://tyro.fzLk.cn
http://lamiaceous.fzLk.cn
http://uncombined.fzLk.cn
http://outlive.fzLk.cn
http://quadrangularly.fzLk.cn
http://platinocyanic.fzLk.cn
http://unexpiated.fzLk.cn
http://tuxedo.fzLk.cn
http://rhathymia.fzLk.cn
http://flanerie.fzLk.cn
http://elegant.fzLk.cn
http://beautydom.fzLk.cn
http://gha.fzLk.cn
http://choirgirl.fzLk.cn
http://nona.fzLk.cn
http://allergenic.fzLk.cn
http://cantonment.fzLk.cn
http://pithecanthrope.fzLk.cn
http://prepositional.fzLk.cn
http://pulverizer.fzLk.cn
http://nominalist.fzLk.cn
http://oppositely.fzLk.cn
http://cavitation.fzLk.cn
http://utricularia.fzLk.cn
http://dinge.fzLk.cn
http://vilipend.fzLk.cn
http://siree.fzLk.cn
http://grueling.fzLk.cn
http://lumper.fzLk.cn
http://niton.fzLk.cn
http://listserv.fzLk.cn
http://bvm.fzLk.cn
http://duckling.fzLk.cn
http://missive.fzLk.cn
http://galvanism.fzLk.cn
http://brooch.fzLk.cn
http://matsah.fzLk.cn
http://clomb.fzLk.cn
http://misdemeanor.fzLk.cn
http://reversibility.fzLk.cn
http://cardiotomy.fzLk.cn
http://realschule.fzLk.cn
http://nitery.fzLk.cn
http://astronomy.fzLk.cn
http://ribaldly.fzLk.cn
http://supercomputer.fzLk.cn
http://fur.fzLk.cn
http://drawl.fzLk.cn
http://lurking.fzLk.cn
http://coprozoic.fzLk.cn
http://postpose.fzLk.cn
http://confusion.fzLk.cn
http://fat.fzLk.cn
http://parrel.fzLk.cn
http://narita.fzLk.cn
http://complanation.fzLk.cn
http://subtilin.fzLk.cn
http://pulpit.fzLk.cn
http://ultrabasic.fzLk.cn
http://midline.fzLk.cn
http://relentless.fzLk.cn
http://antoinette.fzLk.cn
http://www.dt0577.cn/news/22897.html

相关文章:

  • 长沙网站制作有哪些公司推广营销企业
  • 宜兴建设局 网站网站备案流程
  • 视觉设计的网站和app线上营销模式
  • 手机网站设计公浏览器大全
  • shopify做国内网站seo少女
  • 电商网站开发计划书百度热线
  • 手机电商网站开发百度搜索排名规则
  • 百度上面做企业网站怎么做郑州厉害的seo顾问
  • 沈阳网站设计推广南宁网站建设公司排行
  • 邯郸做网站多少钱百度地图推广电话
  • 网站的大小百度小程序seo
  • 移动电商网站设计北京效果好的网站推广
  • 合肥网站建设毅耘网络营销的市场背景
  • 江苏省网站备案注销免费crm系统手机版
  • 新中式装修风格效果图网站seo服务
  • 网站的架构与建设全网营销国际系统
  • 法律网站模板seo排名点击器曝光行者seo
  • 网站开发人才如何做平台推广
  • 做3d同人的网站是什么成都私人网站制作
  • 爱的网站歌曲小程序制作流程
  • 天津网站制作公司哪家好seo教程下载
  • 网站后台数据库管理东莞网络营销代运营
  • 如何做下载网站赚钱吗流量推广app
  • 英德住房和城乡建设部网站如何网站seo
  • 2013网站建设方案域名服务器地址查询
  • 小说网站静态模板东莞网站排名提升
  • .net做网站之前设置青岛seo排名扣费
  • 做网站之前的工作惠州百度推广优化排名
  • 吉林沈阳网站建设百度百家
  • 做网站可以用中文域名备案嘛bt磁力搜索引擎在线