int main(){
	int A1, A2, w0, w1;
	int R;

	time_t t;
	srand((unsigned) time(&t));

	// A1 = rand() % lim + 1;
	// A2 = rand() % lim + 1;
	// w0 = rand() % lim2 + 1;
	// w1 = rand() % lim2 + 1;
	A1 = 150;
	A2 = 250;
	w0 = 25;
	w1 = 50;
	R = 250;

	writeSample("./data/sig1.dat", A1, w0, R);
	plot("./data/sig1.dat",1,"Signal 1");

	writeSample("./data/sig2.dat", A2, w1, R);
	plot("./data/sig2.dat",1, "Signal 2");

	printf("Actual f for Signal 1: %lf\n",w0/6.283);
	printf("Observed f for Signal 1: %lf\n", freq("./data/sig1.dat",R));

	printf("\nActual f for Signal 2: %lf\n",w1/6.283);
	printf("Observed f for Signal 2: %lf\n", freq("./data/sig2.dat",R));
	
	rFile(A1,w0,1000,3000);
	return 0;
}
示例#2
0
int main( int argc, char** argv ) {
    using plist_type = surf::postings_list<surf::compression_codec::optpfor,128>;

    // test small uncompressed lists 
    for(size_t i=0;i<500;i++) {
        size_t n = 1 + rand()%20;
        std::vector< std::pair<uint64_t,uint64_t> > A;
        uint64_t cur_id = rand()%5000;
        for(size_t j=0;j<n;j++) {
            cur_id += rand()%5000;
            uint64_t cur_freq = 1 + rand() % 50;
            A.emplace_back(cur_id,cur_freq);
        }
        plist_type pl(A);

        auto itr = pl.begin();
        auto end = pl.end();
        size_t j=0;
        while( itr != end) {
            auto id = itr.docid();
            auto freq = itr.freq();
            if(id != A[j].first && freq != A[j].second) {
                std::cerr << "ERROR: uncompressed list";
            }
            j++;
            ++itr;
        }
    }

    // test larger compressed lists 
    for(size_t i=0;i<500;i++) {
        size_t n = 1 + rand()%20000;
        std::vector< std::pair<uint64_t,uint64_t> > A;
        uint64_t cur_id = rand()%500;
        for(size_t j=0;j<n;j++) {
            cur_id += rand()%500;
            uint64_t cur_freq = 1 + rand() % 50;
            A.emplace_back(cur_id,cur_freq);
        }
        plist_type pl(A);

        auto itr = pl.begin();
        auto end = pl.end();
        size_t j=0;
        while( itr != end) {
            auto id = itr.docid();
            auto freq = itr.freq();
            if(id != A[j].first && freq != A[j].second) {
                std::cerr << "ERROR: uncompressed list";
            }
            j++;
            ++itr;
        }
    }

}
bool S60RadioTunerControl::initRadio()
{
	m_available = false;

	TRAPD(tunerError, m_tunerUtility = CMMTunerUtility::NewL(*this, CMMTunerUtility::ETunerBandFm, 1, 
	  										                 CMMTunerUtility::ETunerAccessPriorityNormal));
	if (tunerError != KErrNone) {
        m_radioError = QRadioTuner::OpenError;
        return m_available;
    }
	
	TRAPD(playerError, m_audioPlayerUtility = m_tunerUtility->TunerPlayerUtilityL(*this));
	if (playerError != KErrNone) {
		m_radioError = QRadioTuner::OpenError;
		return m_available;
	}
	
	TRAPD(initializeError, m_audioPlayerUtility->InitializeL(KAudioPriorityFMRadio, 
												             TMdaPriorityPreference(KAudioPrefRadioAudioEvent)));
	if (initializeError != KErrNone) {
		m_radioError = QRadioTuner::OpenError;
		return m_available;
	}
		
	m_tunerUtility->NotifyChange(*this);
	m_tunerUtility->NotifyStereoChange(*this);
	m_tunerUtility->NotifySignalStrength(*this);
	
	TFrequency freq(m_currentFreq);
	m_tunerUtility->Tune(freq);
		
	m_available = true;

    return m_available;
}
示例#4
0
void TextureBuilder::createModules() {
    QSharedPointer<ModuleDescriptor> mod;
    foreach (mod,_modDesc) {
        auto modPtr = mod.data();
        if (this->useRandomFactors() &&  modPtr->enableRandom() ) {
            modPtr->setBias(this->applyRandomFactor(modPtr->bias()) );
            modPtr->setDispl(this->applyRandomFactor(modPtr->displ()) );
            modPtr->setExp(this->applyRandomFactor(modPtr->exp()) );
            modPtr->setFreq(this->applyRandomFactor(modPtr->freq()) );
            modPtr->setLac(this->applyRandomFactor(modPtr->lac()) );
            modPtr->setLbound(this->applyRandomFactor(modPtr->lBound()) );
            modPtr->setPers(this->applyRandomFactor(modPtr->pers()) );
            modPtr->setPow(this->applyRandomFactor(modPtr->pow()) );
            modPtr->setRough(this->applyRandomFactor(modPtr->rough()) );
            modPtr->setScale(this->applyRandomFactor(modPtr->scale()) );
            modPtr->setValue(this->applyRandomFactor(modPtr->value()) );
            modPtr->setX(this->applyRandomFactor(modPtr->x()) );
            modPtr->setY(this->applyRandomFactor(modPtr->y()) );
            modPtr->setZ(this->applyRandomFactor(modPtr->z()) );
        }
        mod.data()->setModules(_modules);
        auto ptr = mod.data()->makeModule();
        qDebug() << "Module " << modPtr->name() << " After module creation...";
        modPtr->dumpModule();
        _modules.insert(mod.data()->name(), ptr);
    }
    string frequencySort(string s) {
        int n = s.length();
        const int MAX_CHAR = 256;
        vector<int> freq(MAX_CHAR, 0);
        for(int i = 0 ; i < n; ++i) {
            freq[s[i]]++;
        }
#if 0
        // bucket sort
        vector<vector<int>> bucket(n + 1);
        for (int i = 0; i < MAX_CHAR; i++) {
            bucket[freq[i]].push_back(i);    
        }
        string result = "";
        for (int i = bucket.size() - 1; i > 0; i--) {
            for (auto ch : bucket[i]) {
                result += string(i, ch);    
            }
        }
#endif
        // auto compare = [] (pair<int, int> const& lhs, pair<int, int> const& rhs) -> bool const { return lhs.first < rhs.first; };
        // priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(compare)> Q(compare);
        priority_queue<pair<int, int>> Q;
        for(int i = 0 ; i < MAX_CHAR; ++i) {
            if(freq[i] > 0) {
                Q.push({freq[i], i});
            }
        }
        string result = "";
        while(!Q.empty()) {
            result += string(Q.top().first, Q.top().second);
            Q.pop();
        }
        return result;
    }
示例#6
0
void actualPhaseFlip(MultidimArray<double> &I, CTFDescription ctf)
{
    // Perform the Fourier transform
    FourierTransformer transformer;
    MultidimArray< std::complex<double> > M_inFourier;
    transformer.FourierTransform(I,M_inFourier,false);

    Matrix1D<double> freq(2); // Frequencies for Fourier plane
    int yDim=YSIZE(I);
    int xDim=XSIZE(I);
    double iTm=1.0/ctf.Tm;
    for (size_t i=0; i<YSIZE(M_inFourier); ++i)
    {
    	FFT_IDX2DIGFREQ(i, yDim, YY(freq));
    	YY(freq) *= iTm;
        for (size_t j=0; j<XSIZE(M_inFourier); ++j)
        {
        	FFT_IDX2DIGFREQ(j, xDim, XX(freq));
        	XX(freq) *= iTm;
            ctf.precomputeValues(XX(freq),YY(freq));
            if (ctf.getValuePureWithoutDampingAt()<0)
                DIRECT_A2D_ELEM(M_inFourier,i,j)*=-1;
        }
    }

    // Perform inverse Fourier transform and finish
    transformer.inverseFourierTransform();
}
示例#7
0
Shouter::Shouter()
    : Entry() {

    /*
    int vermaj,vermin,verpat;
    shout_version(&vermaj,&vermin,&verpat);
    func("Shouter::Shouter() using libshout version %i.%i.%i",vermaj,vermin,verpat);
    */

    ice = shout_new();

    //  to do this, more of the code must be changed
    //  shout_set_nonblocking(ice,1);

    running = false;
    retry = 0;
    errors = 0;

    /* setup defaults */
    host("localhost");
    ip("127.0.0.1");
    port(8000);
    pass("hackme");
    mount("live");
    login(SHOUT_PROTOCOL_HTTP); // defaults to icecast 2 login now
    name("Streaming with MuSE");
    url("http://muse.dyne.org");
    desc("Free Software Multiple Streaming Engine");
    bps("24000");
    freq("22050");
    channels("1");

    profile_changed = true;
}
double error(int A, int w, int R){
	writeSample("temp", A,w,R);
	double f = freq("temp", R);
	remove("temp");

	return (w/6.283)-f;
}
示例#9
0
// Remove wedge ------------------------------------------------------------
void MissingWedge::removeWedge(MultidimArray<double> &V) const
{
    Matrix2D<double> Epos, Eneg;
    Euler_angles2matrix(rotPos,tiltPos,0,Epos);
    Euler_angles2matrix(rotNeg,tiltNeg,0,Eneg);
    
    Matrix1D<double> freq(3), freqPos, freqNeg;
    Matrix1D<int> idx(3);

    FourierTransformer transformer;
    MultidimArray< std::complex<double> > Vfft;
    transformer.FourierTransform(V,Vfft,false);

    FOR_ALL_ELEMENTS_IN_ARRAY3D(Vfft)
    {
        // Frequency in the coordinate system of the volume
        VECTOR_R3(idx,j,i,k);
        FFT_idx2digfreq(V,idx,freq);

        // Frequency in the coordinate system of the plane
        freqPos=Epos*freq;
        freqNeg=Eneg*freq;
        if (ZZ(freqPos)<0 || ZZ(freqNeg)>0)
            Vfft(k,i,j)=0;
    }
    transformer.inverseFourierTransform();
}
示例#10
0
int main()
{
    std::string line;

    // find out number of terms
    std::getline(std::cin, line);
    size_t N = std::atoi(&line[0]);

    evernote::Frequency<std::string> freq(N);

    // read terms from stdin
    while (N--) {
        if (!std::getline(std::cin, line))
            return 1;

        freq.add(line);
    }

    // show top k terms
    if (!std::getline(std::cin, line))
        return 2;

    size_t k = std::atoi(&line[0]);
    Visitor v;
    freq.top(v, k);

    return 0;
}
void S60RadioTunerControl::setFrequency(int frequency)
{
    TRACE("S60RadioTunerControl::setFrequency" << qtThisPtr() << "frequency" << frequency);
    m_currentFreq = frequency;
    TFrequency freq(m_currentFreq);
    m_tunerUtility->Tune(freq);
}
示例#12
0
std::vector<int> crypto::get_freq(const std::string& str)
{
	std::vector<int> freq(26, 0);
	for (int i = 0; i < str.size(); ++i)
		++freq[str[i] - 'a'];
	return freq;
}
示例#13
0
void DutyUnit::saveState(SaveState::SPU::Duty &dstate, unsigned long const cc) {
	updatePos(cc);
	setCounter();
	dstate.nextPosUpdate = nextPosUpdate_;
	dstate.nr3 = freq() & 0xFF;
	dstate.pos = pos_;
	dstate.high = high_;
}
示例#14
0
void DutyUnit::nr4Change(unsigned const newNr4, unsigned long const cc) {
	setFreq((newNr4 << 8 & 0x700) | (freq() & 0xFF), cc);

	if (newNr4 & 0x80) {
		nextPosUpdate_ = (cc & ~1ul) + period_ + 4;
		setCounter();
	}
}
void CmpConvolutionLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
      const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
 //LOG(INFO) << "conv backward" << endl;
  const Dtype* weight = this->blobs_[0]->cpu_data();
  Dtype* weight_diff = this->blobs_[0]->mutable_cpu_diff();
  int count = this->blobs_[0]->count();
  for (int i = 0; i < top.size(); ++i) {
    const Dtype* top_diff = top[i]->cpu_diff();
    const Dtype* bottom_data = bottom[i]->cpu_data();
    Dtype* bottom_diff = bottom[i]->mutable_cpu_diff();
    // Bias gradient, if necessary.
    if (this->bias_term_ && this->param_propagate_down_[1]) {
      Dtype* bias_diff = this->blobs_[1]->mutable_cpu_diff();
      for (int n = 0; n < this->num_; ++n) {
        this->backward_cpu_bias(bias_diff, top_diff + n * this->top_dim_);
      }
    }
    if (this->param_propagate_down_[0] || propagate_down[i]) {
      for (int n = 0; n < this->num_; ++n) {
        // gradient w.r.t. weight. Note that we will accumulate diffs.
        if (this->param_propagate_down_[0]) {
          this->weight_cpu_gemm(bottom_data + n * this->bottom_dim_,
              top_diff + n * this->top_dim_, weight_diff);
        }
        Dtype* weight_diff = this->blobs_[0]->mutable_cpu_diff();
        const int *mask_data = this->masks_.cpu_data();
        for (int j = 0; j < count; ++j)
          weight_diff[j] *=  mask_data[j];

        if(this->quantize_term_)
        {
	  vector<Dtype> tmpDiff(this->class_num_);
          vector<int> freq(this->class_num_);
          const int *indice_data = this->indices_.cpu_data();

          for (int j = 0; j < count; ++j)
          {
            if (mask_data[j])
            {
              tmpDiff[indice_data[j]] += weight_diff[j];
              freq[indice_data[j]]++;
            }
          }
          for (int j = 0; j < count; ++j)
          {
            if (mask_data[j])
              weight_diff[j] = tmpDiff[indice_data[j]] / freq[indice_data[j]];
          }
        }
        // gradient w.r.t. bottom data, if necessary.
        if (propagate_down[i]) {
          this->backward_cpu_gemm(top_diff + n * this->top_dim_, weight,
              bottom_diff + n * this->bottom_dim_);
        }
      }
    }
  }
}
示例#16
0
vector_t HaploWindow::rightStubFrequency()
{
  vector_t freq(haplo->nsh, 0);
	
  for (int h=0; h< nh; h++)
    freq[ rightStub[h] ] += f[h];
	
  return freq;
}
示例#17
0
	/**
	 * Plays a pure note (given in scientific pitch notation) for a
	 * specified duration.
	 */
	void    play (string note, float duration) {
		ofstream outfile;
		outfile.open("sound.raw", ios::app);
		float frequency = freq(note);
		float time;
		for (time=0; time<=duration*sample_rate; time++) {
			outfile << wave(frequency, time);
		}
	}
示例#18
0
文件: freq.c 项目: kisom/site-tools
void
main(int argc, char *argv[])
{
	int f, i;

	flag = 0;
	Binit(&bout, 1, OWRITE);
	ARGBEGIN{
	default:
		fprint(2, "freq: unknown option %c\n", ARGC());
		exits("usage");
	case 'd':
		flag |= Fdec;
		break;
	case 'x':
		flag |= Fhex;
		break;
	case 'o':
		flag |= Foct;
		break;
	case 'c':
		flag |= Fchar;
		break;
	case 'r':
		flag |= Frune;
		break;
	}ARGEND
	if((flag&(Fdec|Fhex|Foct|Fchar)) == 0)
		flag |= Fdec | Fhex | Foct | Fchar;
	if(argc < 1) {
		freq(0, "-");
		exits(0);
	}
	for(i=0; i<argc; i++) {
		f = open(argv[i], 0);
		if(f < 0) {
			fprint(2, "cannot open %s\n", argv[i]);
			continue;
		}
		freq(f, argv[i]);
		close(f);
	}
	exits(0);
}
示例#19
0
VecDoub Actions_Isochrone::Hessian(const VecDoub& x){
    VecDoub Om = freq(x);
    double D_rr,D_rp,D_pp;
    double LL = L(x);
    D_rr=-Om[0]*3.*sqrt(-2*H(x))/GM;
    D_rp=D_rr*Om[1]/Om[0];
    D_pp=Om[0]*2*GM*b*pow(LL*LL+4*GM*b,-1.5)
            +0.5*(1+LL/sqrt(LL*LL+4*GM*b))*D_rp;
    return {D_rr,D_rp,D_pp};
}
 bool canPermutePalindrome(string s) {
     int n = s.length();
     vector<int> freq(256, 0);
     for(char c : s){
         freq[(int) c]++;
     }
     int count_of_odd_occur =0;
     for(int num : freq){
         if(num%2==1) count_of_odd_occur++;
     }
     return count_of_odd_occur > 1 ? false : true;
 }
void S60RadioTunerControl::start()
{
    TRACE("S60RadioTunerControl::start" << qtThisPtr());
	if (!m_audioInitializationComplete) {
		TFrequency freq(m_currentFreq);
		m_tunerUtility->Tune(freq);
	} else {
		m_audioPlayerUtility->Play();
	}
	m_apiTunerState = QRadioTuner::ActiveState;
	emit stateChanged(m_apiTunerState);
}
pair<double,double> Chi2LibHighDensity::gaussianFit(vector<MyPeak> *peaks, MyMatrix<double> *img, unsigned int ss){
	unsigned int slots = 21;

	MyLogger::log()->debug("[Chi2LibHighDensity][gassianFit] Calculating MU and SIGMA ");
	vector<double> X(slots);
	vector<int> freq(slots);
	double dx = 0.01;
	for(unsigned int i=0; i < slots; ++i){
		freq[i]=0;
		X[i]=0.8+i*dx;
	}

	vector<MyPeak> new_peaks;
	new_peaks.reserve(peaks->size());
	MyPeak tmp;
	for(unsigned int i=0; i < peaks->size(); ++i){
			tmp.x = peaks->at(i).x - ss;
			tmp.y = peaks->at(i).y - ss;
			tmp.intensity = img->getValue(tmp.x, tmp.y);
			new_peaks.push_back(tmp);
	}

	sort(new_peaks.begin(), new_peaks.end(), MyPeak::compareMe);

	unsigned int current = 0;
	for(unsigned int i=0; i < new_peaks.size(); ++i){
		for(unsigned int s=current; s < slots; ++s){
			if(new_peaks.at(i).intensity <= X[s] + dx){
				++freq[s];
				break;
			}
			++current;
		}
	}

	int check = 0;
	double mu = 0.0, sigma = 0.0;
	for(unsigned int i=0; i < slots; ++i){
		mu += X[i]*freq[i];
		check += freq[i];
	}
	mu = mu/check;

	for(unsigned int i=0; i < slots; ++i){
		sigma += freq[i]*(mu-X[i])*(mu-X[i]);
	}
	sigma = sqrt(sigma/check);

	MyLogger::log()->debug("[Chi2LibHighDensity][gassianFit] Total Checks=%i; Returning MU=%f; SIGMA=%f", check, mu, sigma);
	pair<double, double> ret; ret.first = mu; ret.second = sigma;
	return ret;
}
示例#23
0
	void countingSort(int H) {
		auto vrank = [&](int i) { return SA[i]+H<N ? RA[SA[i]+H]+1 : 0; };
		int maxRank = *max_element(RA.begin(), RA.end());
		VI nSA(N);
		VI freq(maxRank + 2);
		for (int i = 0; i < N; ++i)
			freq[vrank(i)]++;
		for (int i = 1; i < freq.size(); ++i)
			freq[i] += freq[i-1];
		for (int i = N-1, p, m; i >= 0; --i)
			nSA[--freq[vrank(i)]] = SA[i];
		copy(nSA.begin(), nSA.end(), SA.begin());
	}
示例#24
0
QJsonObject Blink1Input::toJson()
{
    QJsonObject obj;
    obj.insert("name", name());
    obj.insert("type",type());
    obj.insert("arg1",arg1());
    obj.insert("arg2",arg2());
    obj.insert("date",date());
    obj.insert("patternName",patternName());
    obj.insert("freq",freq());
    obj.insert("freqCounter",freqCounter());
    return obj;
}
示例#25
0
int main()
{
	int n, k, i;
	scanf("%d", &n);
	scanf("%d", &k);
	char **A = (char **)malloc(n * sizeof(char *));
	for (i = 0; i < n; i++)
	{
		A[i] = (char *)malloc(101 * sizeof(char));
		scanf("%s", A[i]);
	}
	freq(A, n, k);
	return 0;
}
 vector<int> topKFrequent(vector<int>& nums, int k) {
     std::vector<int> ans;
     std::unordered_map<int, int> counter;
     for (auto v : nums) counter[v]++;
     auto cmp = [](const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) {
         return lhs.second > rhs.second;  
     };
     std::multiset<std::pair<int, int>, decltype(cmp)>
         freq(std::begin(counter), std::end(counter), cmp);
     for (auto it = std::begin(freq); k--; ++it) {
         ans.emplace_back(it->first);
     }
     return ans;
 }
    void recordResults( boost::property_tree::ptree & log ) {

        typedef ac::accumulator_set< size_type, ac::stats< ac::tag::min, ac::tag::mean, ac::tag::max, ac::tag::variance, ac::tag::median, ac::tag::count > > accumulator_t;

        accumulator_t   col_accum, row_accum;

        boost::property_tree::ptree dist, lfreq;

        // maximum frequency for an allele is bounded by the number of sequences (rows) in the population
        std::vector< size_type > freq( m_indices.size(), 0 );

        // evaluate allele (column) statistics
        size_type i = 0;
        while( i < m_column_margin_size ) {
            size_type v = m_column_margin[i++];
            clotho::utility::add_value_array( dist, v );
            col_accum( v );
            freq[v]++;
        }


        clotho::utility::add_value_array(lfreq, freq.begin(), freq.end() );

        log.put_child( "distribution", dist );
        log.put_child( "frequency_distribution", lfreq );

        log.put( "stats.sequences_per_allele.min", ac::min( col_accum ) );
        log.put( "stats.sequences_per_allele.max", ac::max( col_accum ) );
        log.put( "stats.sequences_per_allele.mean", ac::mean( col_accum ) );
        log.put( "stats.sequences_per_allele.median", ac::median( col_accum ) );
        log.put( "stats.sequences_per_allele.variance", ac::variance( col_accum ) );
        log.put( "stats.sequences_per_allele.total", ac::count(col_accum) );

        // evaluate sequence (row) statistics
        i = 0;
        while( i < m_row_margin_size ) {
            if( m_indices.test(i) ) {
                row_accum( m_row_margin[ i ] );
            }
            ++i;
        }

        log.put( "stats.alleles_per_sequence.min", ac::min( row_accum ) );
        log.put( "stats.alleles_per_sequence.max", ac::max( row_accum ) );
        log.put( "stats.alleles_per_sequence.mean", ac::mean( row_accum ) );
        log.put( "stats.alleles_per_sequence.median", ac::median( row_accum ) );
        log.put( "stats.alleles_per_sequence.variance", ac::variance( row_accum ) );
        log.put( "stats.alleles_per_sequence.total", ac::count(row_accum) );
    }
示例#28
0
int main(int argc, char **argv) 
{
    Eigen::initParallel();
    ros::init(argc, argv, "footstep_planner");
//     yarp::os::Network yarp;
//     if(!yarp.checkNetwork()){
//         std::cout<<"yarpserver not running, pls run yarpserver"<<std::endl;
//         return 0;
//     }
//     yarp.init();
    
    //walkman::yarp_switch_interface switch_interface("footstep_planner");
    std::string sCommand, robot_name;
    
    if(argc==2) robot_name=argv[1];
    else robot_name="bigman";
    param_manager pm;
    ros::NodeHandle nh;
    
    quit=false;
    fs_planner_module node(&nh,200,robot_name);
    
    ros::ServiceServer srv_exit;
    
    srv_exit = nh.advertiseService(nh.resolveName("exit"),&endcycle);
    
    ros::Rate freq ( 1 );
    freq.sleep();
    std::cout<<"Starting thread"<<std::endl;
    
    bool ok=node.my_configure();
    if(ok) std::cout<<"Footstep Planner is started"<<std::endl;
    else   std::cout<<"Error starting Footstep Planner Module"<<std::endl;
    while(!quit)
    {
	ros::spinOnce();
	freq.sleep();
   }
   
   std::cout<<"QUIT"<<std::endl;
   if(node.isAlive())
   {
      std::cout<<"Stopping thread"<<std::endl;
      node.close();
   }
    
//    yarp.fini();
   return 0;
}
示例#29
0
int main(int argc, const char *argv[]){
  IloEnv env;
  try {
    IloModel model(env);
    IloInt nbTransmitters = GetTransmitterIndex(nbCell, 0);
    IloIntVarArray freq(env, nbTransmitters, 0, nbAvailFreq - 1);
    freq.setNames("freq");
    for (IloInt cell = 0; cell < nbCell; cell++)
      for (IloInt channel1 = 0; channel1 < nbChannel[cell]; channel1++)
        for (IloInt channel2= channel1+1; channel2 < nbChannel[cell]; channel2++)
          model.add(IloAbs(  freq[GetTransmitterIndex(cell, channel1)]
                             - freq[GetTransmitterIndex(cell, channel2)] )
                    >= 16);
    for (IloInt cell1 = 0; cell1 < nbCell; cell1++)
      for (IloInt cell2 = cell1+1; cell2 < nbCell; cell2++)
        if (dist[cell1][cell2] > 0)
          for (IloInt channel1 = 0; channel1 < nbChannel[cell1]; channel1++)
            for (IloInt channel2 = 0; channel2 < nbChannel[cell2]; channel2++)
              model.add(IloAbs(  freq[GetTransmitterIndex(cell1, channel1)]
                                 - freq[GetTransmitterIndex(cell2, channel2)] )
                        >= dist[cell1][cell2]);
    
    // Minimizing the total number of frequencies
    IloIntExpr nbFreq = IloCountDifferent(freq); 
    model.add(IloMinimize(env, nbFreq));
    
    IloCP cp(model);
    cp.setParameter(IloCP::CountDifferentInferenceLevel, IloCP::Extended);
    cp.setParameter(IloCP::FailLimit, 40000);
    cp.setParameter(IloCP::LogPeriod, 100000);

    if (cp.solve()) {
      for (IloInt cell = 0; cell < nbCell; cell++) {
        for (IloInt channel = 0; channel < nbChannel[cell]; channel++)
          cp.out() << cp.getValue(freq[GetTransmitterIndex(cell, channel)])
                   << "  " ;
        cp.out() << std::endl;
      }
      cp.out() << "Total # of sites       " << nbTransmitters << std::endl;
      cp.out() << "Total # of frequencies " << cp.getValue(nbFreq) << std::endl;
    } else
      cp.out() << "No solution found."  << std::endl;
    cp.end();
  } catch (IloException & ex) {
    env.out() << "Caught: " << ex << std::endl;
  }
  env.end();
  return 0;
}
int main(){

    const int N = 4;
    std::vector<long> a(N,0); 
    std::vector<long> freq(N, 0);
    for(int k = 0; k < N; k++){scanf("%ld ", &a[k]);}; scanf("\n");
    std::string input; getline(std::cin, input);
    for(int k = 0; k < input.size(); k++){++freq[input[k] - '1'];}

    long total(0);
    for(int k = 0; k < N; k++){total += a[k] * freq[k];}
    std::cout << total << std::endl;

    return 0;
}