客似云来_抄送列表 _年会抽奖

客似云来

客似云来

image-20220511104809286

import java.util.*;
import java.math.*;

public class Main{
    public static void main(String[] args){
        long[] fib = new long[80];//long类型,保存每天的值!
        fib[0] = 1;
        fib[1] = 1;
        for(int i = 2;i<fib.length;i++){
            fib[i] = fib[i-1]+fib[i-2];
        }
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int from = sc.nextInt();
            int to = sc.nextInt();
            long result = 0;
            //注意下标!
            for(int i = from-1;i<=to-1;i++){
                result+=fib[i];
            }
            System.out.println(result);
        }
    }
}

抄送列表

抄送列表

image-20220511203738891

image-20220512143303781

// write your code here
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str = sc.nextLine();
            String name = sc.nextLine();
            String[] result = null;
            if(str.contains("\"")){
                //包含了 " 需要#分隔人名!
                StringBuilder sb = new StringBuilder();
                int flag = 1; 
                for(int i = 0;i<str.length();i++){
                    if(str.charAt(i)=='\"'){// "标记!
                        flag^=1;  //如果进入一整个人名,就为 0 需要将 , 添加到sb中!
                    }else if(flag==0&&str.charAt(i)==','){//人名中的空格需要添加进来!
                        sb.append(",");
                    }else if(str.charAt(i)==','){//非人名中的空格!
                        sb.append("#"); //分割人名!
                    }else{
                        sb.append(str.charAt(i));
                    }
                }
                //通过#划分!
                result = (new String(sb)).split("#");
            }else{
                //直接通过 , 划分人名!
                result = str.split(",");
            }
            int i = 0;
            for(i = 0;i< result.length;i++){
                if(result[i].equals(name)){
                    System.out.println("Ignore");
                    break;
                }
            }
            if(i==result.length){
                 System.out.println("Important!");
            }
        }
    }
}

年会抽奖

年会抽奖

image-202205130****7451

一、什么是错排问题

举例:

  1. 十本不同的书放在书架,现重新摆放,使得每本书都不在原来的位置上,有几种摆法?
  2. 一个人给十个同学写信,但他把所有的信都装错了信封,问共有多少种错误的方式?

以上问题推广,就是错排问题。

一个n个元素的排列,若一个排列中所有的元素都不在自己原来的位置上,那么这样的一个排列就称为原排列的一个错排。而研究一个排列的错排个数的问题,就称为错排问题(或称为更列问题)。

二、错排公式

n个元素的错排数记为D(n)

D(1)=0; D(2)=1; D(n)=D(n-1)(n-1)+D(n-2)(n-1)

import java.util.*;
public class Main{
    public static void main(String[] args){
         long[] array = new long[21];
         long[] array1 = new long[21];
        array[0] = 0;
        array[1] = 0;
        array[2] = 1;
        array1[0] = 1;
        array1[1] = 1;
        array1[2] = 2;

        for(int i = 3;i<array.length;i++){
                array[i] = (i-1)*(array[i-1]+array[i-2]);
                array1[i] = array1[i-1]*i;
        }
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            double result = 100.0*(array[n]/(double)array1[n]);
            System.out.printf("%5.2f%%\n",result);
        }
    }
}
全部评论
公司年会不知道会不会有这些呢
点赞 回复 分享
发布于 2022-08-27 13:14 河南

相关推荐

07-25 11:12
重庆大学 C++
既然这么缺人,为什么挂我呢
飞花断音:华为需要学历不高,但是很能干事儿,能吃苦也没怨言,愿意无偿加班,最好上有老下有小,不是独生子女,家庭条件不好,家在外地租房住,生活成本高,不会轻易跳槽,并且愿意接受低工资的奴仆任劳任怨地给任总的女儿买大别墅住
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务