700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 春招回忆录---雷火笔试

春招回忆录---雷火笔试

时间:2020-05-01 04:52:34

相关推荐

春招回忆录---雷火笔试

第一题

斐波那契数列(Fibonacci sequence)大家应该都知道吧。本题中斐波拉契字符串的定义是:给定前两个字符串F(1)和F(2)从第三个开始,每个字符串都等于前两个字符串拼接而成,即当i > 2时,f(i)=f(i-2)+f(i-1)。

当(1)=abc,f(2)=af时,后面几个字符串为:

f(3)=abcaf

f(4)=afabcaf

f(5)=abcafafabcaf

f(6)=afabcafabcafafabcaf

在给定N的时候,需要求出F(N)这个里包含的每个英文字母的数量。

输入

6

abc af

输出

a:8

b:3

c:3

f:5

#include "pch.h"#include<stdlib.h>#include <iostream>#include<string.h>using namespace std;int main(){char str[30], str1[30];int k;int a[26], b[26], t;cin >> k;cin >> str >> str1;memset(a, 0, sizeof(a));memset(b, 0, sizeof(a));int len, len1;len = strlen(str);len1 = strlen(str1);for (int i = 0; i < len; i++) {a[str[i] - 'a']++;}for (int i = 0; i < len1; i++) {b[str1[i] - 'a']++;}for (int i = 2; i < k; i++) {for (int j = 0; j < 26; j++) {t = a[j] + b[j];a[j] = b[j];b[j] = t;}for (int i = 0; i < 26; i++) {if(b[i])printf("%c:%d\n",'a'+i,b[i]);}}

第二题

钱老板在副本中物升级,这个副本总共有N个怪物,编号从0到N-1,每击杀一只怪物需要T秒的时间,编号为的怪物在Li秒之后就会逃跑被击杀后将获得Ei的经验值。

钱板可以选择和任意一个还没逃跑的怪物战斗,选择怪物不需要花费时间旦进入战斗后怪物就无法逃跑,当所有怪物都逃跑或者被杀死后,副本结束。

请问钱老板最多能获得多少经验值。

输入描述:

N[1,100000]表示有N个怪物,T[1,10000]表示每次击杀需要的时间,接下来会有N行数据,每行有2个整数,分别表示0号到N-1号怪物的Li[1,10000000],Ei[1,1000]

输入

3 2

1 2

2 5

3 4

输出

9

import java.util.ArrayList;import parator;import java.util.List;import java.util.Scanner;public class Main6 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);List<Monst> list = new ArrayList<>();int n = sc.nextInt();int t = sc.nextInt();for (int i = 0; i < n; i++) {Monst monst = new Monst(sc.nextInt(),sc.nextInt());list.add(monst);}int time =0;// List<Monst> toSort = new ArrayList<>();// for(Monst o1 :list){//toSort.add(o1);// }int ans = 0;list.sort(paring(Monst::getE1).reversed().thenComparing(Monst::getL1));for(Monst o1 :list){if(o1.getL1() >= time){ans +=o1.getE1();time +=t;}}list.sort(paring(Monst::getL1).reversed().thenComparing(Monst::getE1));int ans2 =0;time = 0;for(Monst o1 :list){if(o1.getL1() >= time){ans2 +=o1.getE1();time +=t;}}System.out.println(ans >ans2 ? ans : ans2);}static class Monst{public int L1;public int E1;public Monst(int L1,int E1){this.L1 = L1;this.E1 = E1;}public int getL1(){return L1;}public int getE1(){return E1;}}}

本公众号分享自己从程序员小白到经历春招秋招斩获10几个offer的面试笔试经验,其中包括【Java】、【操作系统】、【计算机网络】、【设计模式】、【数据结构与算法】、【大厂面经】、【数据库】期待你加入!!!

1.计算机网络----三次握手四次挥手

2.梦想成真-----项目自我介绍

3.你们要的设计模式来了

4.震惊!来看《这份程序员面试手册》!!!

5.一字一句教你面试“个人简介”

6.接近30场面试分享

7.你们要的免费书来了

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。