Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.in");
- int x[10000];
- bool frate(int a,int b) {
- //cout << a << " " << b << endl;
- if (a == b) return false;
- else {
- int fra[10] = { 0 }, frb[10] = { 0 };
- while (a) {
- fra[a % 10]++;
- a /= 10;
- }
- while (b) {
- frb[b % 10]++;
- b /= 10;
- }
- int k = 0;
- for (int i = 0; i <= 9; i++)
- {
- if (fra[i] != 0 and frb[i] != 0)
- k++;
- if (k == 2) return true;
- }
- return false;
- }
- }
- int smax, lgmax;
- int main() {
- int n;
- f >> n;
- for (int i = 1; i <= n; i++) {
- f >> x[i];
- }
- int start = -1,k=0;
- for (int i = 1; i <= n; i++) {
- bool ok = false;
- for (int j = 1; j <= n; j++) {
- if (i != j) {
- if (frate(x[i], x[j])) {
- ok = true; break;
- }
- }
- }
- if (ok == false) {
- if (start == -1)
- start = i, k = 1;
- else
- k++;
- }
- else {
- if (start != -1)
- {
- if (k > lgmax)
- lgmax = k, smax = start;
- k = 0,start =-1;
- }
- }
- }
- cout << smax << " " << lgmax;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement