Cod sursa(job #1038712)

Utilizator dan.ghitaDan Ghita dan.ghita Data 21 noiembrie 2013 21:48:28
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <iostream>
#include <fstream>
#include <string.h>
#include <unordered_map>
using namespace std;
int n=276997, x, k;
char s[20];
ifstream f("dtcsu.in");
ofstream g("dtcsu.out");
unordered_map<long long, int> m;

void citire(){
//f>>n; f.get();

while(n--){
    f.getline(s, 20); x=0;
    long long len=strlen(s);
    int u=s[len-1]-'0'; //cout<<u<<' ';
    if(!u&1) continue;

    for(int i=0; i<len; ++i)
        x=10*x+(s[i]-'0');
    if(x&1) m[x]=1;// cout<<x<<'\n';// cout<<x<<'\n';
  }
}


int main()
{
//    n=5;
    citire();
    f>>n;f.get();

while(n--){
    f.getline(s, 20); x=0;
    long long len=strlen(s);
    for(int i=0; i<len; ++i)
        x=10*x+(s[i]-'0');
    while(!(x&1)){
        x>>=1;//cout<<x;
    }
//    cout<<x<<' ';


    if(m.find(x)!=m.end()) ++k;//, cout<<"\nam gasit "<<x<<'\n';
}
g<<k;
//cout<<(1234567890123456789>>1);

    return 0;
}