Last active
August 29, 2015 14:19
-
-
Save na-o-ys/b96a9a6569c1f3880c90 to your computer and use it in GitHub Desktop.
TCO 2015 Round 1A Easy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define loop(n, i) for(int i=0;i<n;i++) | |
#define all(v) v.begin(),v.end() | |
using namespace std; | |
class Similars | |
{ | |
public: | |
int maxsim(int L, int R) { | |
int cnt[1030] = {}; | |
for (int i = L; i <= R; i++) { | |
int v = i, flg = 0; | |
while (v) { | |
flg |= 1 << (v % 10); | |
v /= 10; | |
} | |
cnt[flg]++; | |
} | |
int ans = 0; | |
loop (1030, i) loop (1030, j) { | |
if (!cnt[i] || !cnt[j]) continue; | |
if (i == j && cnt[i] <= 1) continue; | |
ans = max(ans, __builtin_popcount(i & j)); | |
} | |
return ans; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment