-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day_29.cs
37 lines (31 loc) · 903 Bytes
/
Day_29.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
static void Main(String[] args)
{
int t = Convert.ToInt32(Console.ReadLine());
for (int a0 = 0; a0 < t; a0++)
{
string[] tokens_n = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(tokens_n[0]);
int k = Convert.ToInt32(tokens_n[1]);
int maxAnd = -1;
for (int i = 1; i < n; i++)
{
for (int j = i + 1; j <= n; j++)
{
//Console.WriteLine(i & j);
if (((i & j) > maxAnd) && ((i & j) < k))
{
maxAnd = i & j;
}
}
}
Console.WriteLine(maxAnd);
Console.ReadKey();
}
}
}