# BZOJ 4300: 绝世好题

Problem 4300. -- 绝世好题

## 4300: 绝世好题

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1597  Solved: 814
[Submit][Status][Discuss]

3
1 2 3

2

## HINT

n<=100000,ai<=2*10^9

## Source

[Submit][Status][Discuss]

 1 import java.util.Arrays;
2 import java.util.Scanner;
3
4 public class Main {
5
6     public static void main(String args[]) {
7
8         Scanner in = new Scanner(System.in);
9
10         int n = in.nextInt();
11         int f[] = new int[35];
12
13         Arrays.fill(f, 0);
14
15         for (int i = 1; i <= n; ++i) {
16
17             int num = in.nextInt(), tmp = 0;
18
19             for (int j = 0; j <= 30; ++j)
20                 if (((num >> j) & 1) == 1)
21                     tmp = Math.max(tmp, f[j]);
22
23             for (int j = 0; j <= 30; ++j)
24                 if (((num >> j) & 1) == 1)
25                     f[j] = Math.max(f[j], tmp + 1);
26
27         }
28
29         int ans = 0;
30
31         for (int i = 0; i <= 30; ++i)
32             ans = Math.max(ans, f[i]);
33
34         System.out.println(ans);
35
36         in.close();
37
38     }
39
40 }

@Author: YouSiki

posted @ 2017-01-14 11:02  YouSiki  阅读(190)  评论(0编辑  收藏  举报