美团灯盘问题70%答案,保证没有比我最简单的

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int m = 0;

        while(sc.hasNext()) {
             m = sc.nextInt();
         
            for(int i=0;i<m;i++){
              int temp  = sc.nextInt();
            }
            if(m%7==3||m%7==6) {
                System.out.println("Alice");
            }else{
                System.out.println("Bob");
            }
        }
    }
}

#美团#
全部评论
#include <bits/stdc++.h> using namespace std; int main() { cout<<"Bob"<<endl; }
点赞 回复 分享
发布于 2017-09-14 21:23
最后一个灯是1,Alice赢,反之Bob赢
点赞 回复 分享
发布于 2017-09-14 21:24
if l[-1]: print('Alice') else: print('Bob') 知道真相的我眼泪掉下来
点赞 回复 分享
发布于 2017-09-14 21:32
比你更短,ac
点赞 回复 分享
发布于 2017-09-14 21:22
#include <iostream> using namespace std; int main(int argc, char* argv[]) { int n; while(cin >> n) { int nums[n]; for(int i = 0;i < n;++i) { cin >> nums[i]; } if(nums[n - 1] == 1) { cout << "Alice" << endl; } else { cout << "Bob" << endl; } } return 0; }
点赞 回复 分享
发布于 2017-09-14 21:23
//判断最后一位是不是1 int n = arr.length; if (arr[n-1] == 1) System.out.println("Alice"); if (arr[n-1] == 0) System.out.println("Bob");
点赞 回复 分享
发布于 2017-09-14 21:24
int main() {     int n, nn = 0;     cin >> n;     int a[100001], b[100001];     for (int i = 0; i < n; ++i)     {         cin >> b[i];         if (i == 0 || b[i] != b[i - 1])             a[nn++] = b[i];     }     int ans = 0;     if (a[0] == 1)         ans = nn;     else         ans = nn - 1;          if (ans % 2)         cout << "Alice" << endl;     else         cout << "Bob" << endl;     return 0; }
点赞 回复 分享
发布于 2017-09-14 21:24
n=int(raw_input()) ary=raw_input().split() last='0' cnt=0 for a in ary: if a!=last:   cnt+=1   last=a if cnt%2==1: print 'Alice' else: print 'Bob'
点赞 回复 分享
发布于 2017-09-14 21:26
package com.meituan.online; import java.util.*; /** * Created by bruceguo on 2017/9/14. */ public class Problem1 { private static Set<Long> resultSets = new HashSet<>(); public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] nums = new int[n]; for (int i = 0; i < n; i++) { nums[i] = scanner.nextInt(); } int sum = 0; for (int i = 0; i < nums.length; i++) { for (int j = i + 1; j < nums.length; j++) { process(nums[i], nums[j]); } } System.out.println(resultSets.size()); } private static void process(int n1, int n2) { long result = 0; //n1前,n2后 result = n2 + n1 * (int) Math.pow(10, (String.valueOf(n2).length())); if (result % 7 == 0) { resultSets.add(result); } //n1后,n2前 result = n1 + n2 * (int) Math.pow(10, (String.valueOf(n1).length())); if (result % 7 == 0) { resultSets.add(result); } } } 就想问为什么AC总是10%!!!输入没有用while循环的原因???
点赞 回复 分享
发布于 2017-09-14 21:27
这波打脸哈哈哈
点赞 回复 分享
发布于 2017-09-14 21:34
5行代码 AC 两分钟搞定~
点赞 回复 分享
发布于 2017-09-14 21:34
。。。原来是智商题
点赞 回复 分享
发布于 2017-09-14 21:37
比你更简练
点赞 回复 分享
发布于 2017-09-14 22:57

相关推荐

EEbond:给北邮✌️跪了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务