美团校招 关灯问题&&7的倍数
来源:互联网 发布:淘宝客服是干嘛的 编辑:程序博客网 时间:2024/05/01 18:46
package interview;import java.util.*;public class meituan {//关灯问题,看谁赢public static void main(String[] args) {Scanner sc = new Scanner(System.in);while (sc.hasNext()){ int n = sc.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++) arr[i] = sc.nextInt(); int res = 0; for (int i = 0; i < n; i++){ if (arr[i] == 1 && res == 0){ res++; }else if (arr[i] == 1 && (res%2 == 0)){ res++; }else if (arr[i] == 0 && (res%2 != 0)){ res++; } } if (res%2 != 0){ System.out.println("Alice"); }else{ System.out.println("Bob"); }}}}
public class meituan {//7的倍数public static void main(String[] args) {Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); long[] nums = new long[n]; for(int i = 0; i < n; i++){ nums[i] = (long)sc.nextInt(); } int num = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(j == i) { continue; } long temp1 = Long.parseLong(nums[i]+""+nums[j]); if(temp1 % 7 == 0){ num++; } } } System.out.println(num); }}}
阅读全文
0 0
- 美团校招 关灯问题&&7的倍数
- K的倍数----2018美团校招内推
- 美团校招 拜访
- 美团校招笔试题
- 美团校招,百度校招经历
- 美团校招,百度校招经历
- 2015美团校招部分笔试题
- 2015美团校招部分笔试题
- 2015美团校招部分笔试题
- 2016美团校招笔试题
- 2015美团校招面试总结
- 2016年美团校招笔试题
- 2018美团校招前端笔试
- 2014美团校招笔试题之糖果不拆包组合数问题
- 2018年美团校招前端WEB笔试编程题-最小的排列
- 2018美团点评校招-K的倍数
- 2014年美团校招之——求An
- 2014年美团校招之——服务器调度
- configparser
- python note_0914
- Java-多态
- nodejs 基础
- python cookies
- 美团校招 关灯问题&&7的倍数
- JComponent
- Java-引用数据类型转换
- Linux进阶之 mv 命令
- 1004. Counting Leaves (30)
- 51nod 1717 好数
- linux下配置java开发环境
- JAVA并发入门与多线程介绍
- (CodeForces