windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Multipliers (codeforces)

Asked By: Anonymous

This is the link to this algorithm topic:

my code time limit exceeded on test40, I thought for a long time but no good way, is there a good optimization method, may be ?


typedef long long ll;
ll mod = 1e9 + 7;

ll fast_mod(ll a, ll n, ll Mod)
    ll ans=1;
        if(n&1) ans=(ans*a)%Mod;
    return ans;

int main()
    std::cin.tie(0);     // IO

    ll m;
    cin >> m;
    ll num = 1ll;
    map<ll, ll> count;
    for(int i = 0; i < m; i++)
        ll p;
        cin >> p;
   ll res = 1ll;
   vector<ll> a;
   vector<ll> b;
   for(auto it = count.begin(); it != count.end(); it++)
       a.push_back(it -> first);
       b.push_back(it -> second); 
   for(int i = 0; i < a.size(); i++)
       ll x = a[i];  // a kind of prime
       ll y = b[i];  //  the count of the prime
       ll tmp = fast_mod(x, y * (y + 1) / 2, mod);  // x^1 * x^2 * x^3 *...*x^y
       for(int j = 0; j < b.size(); j++)  // calculate  ( tmp)^((b[0] + 1)*(b[1] + 1)*...*(b[b.size() - 1] + 1)), here b.size() is the number of different primes
           tmp = fast_mod(tmp, i != j ? (b[j] + 1) : 1, mod) % mod; 
       res = (res * tmp % mod);

    cout << res << endl;

    return 0;

Find the number of each different prime number, suppose x is one of the different prime number, then calculate x^1x^2x^y, y is the count of x, the result as tmp.Then the product of count of
other prime plus one as the exponent: (b[0] + 1)
(b[1] +1)(b[b.size() – 1] + 1), tmp as base.
The for loop divide the calculation into several steps.
Last, res * (tmp^ ((b[0] + 1)(b[1] +1)…*(b[b.size() – 1] + 1)))


Answered By: Anonymous

An other formula for the product of the divisors of N is N ** (D/ 2), where D is the number of divisors and may be found from your map count by taking the product of entry->second + 1 for every entry.

This does raise the question of what to do when D is odd, which it would be if N is a perfect square. In that case it is easy to compute sqrt(N) (the exponents would all be even, so you can halve them all and take the product of the primes to half of their original exponents), and then raise sqrt(N) to the power of D. Essentially this changes N ** (D / 2) into (N ** (1 / 2)) ** D.

For example if N = 2 * 3 * 2 = 12 (one of the examples), then D will be (2 + 1) * (1 + 1) = 6 and the product of divisors will be 12 ** (6 / 2) = 1728.

Computing N (or its square root) should done modulo mod. Computing D should be done modulo mod - 1 (the totient of mod, mod is a prime so its totient is just one less). mod - 1 is even, so we could not have computed the modular multiplicative inverse of 2 to "divide" D by 2 that way. When N is a square then AFAIK we’re really stuck with computing its square root (that’s not so bad, but multiplying by a half would have been easier).

techinplanet staff

Porno Gratuit Porno Français Adulte XXX Brazzers Porn College Girls Film érotique Hard Porn Inceste Famille Porno Japonais Asiatique Jeunes Filles Porno Latin Brown Femmes Porn Mobile Porn Russe Porn Stars Porno Arabe Turc Porno caché Porno de qualité HD Porno Gratuit Porno Mature de Milf Porno Noir Regarder Porn Relations Lesbiennes Secrétaire de Bureau Porn Sexe en Groupe Sexe Gay Sexe Oral Vidéo Amateur Vidéo Anal

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno

adana escort adapazarı escort adıyaman escort afşin escort afyon escort ağrı escort ahlat escort akçaabat escort akçakale escort akçakoca escort akdeniz escort akhisar escort aksaray escort akşehir escort aksu escort akyazı escort alanya escort alaşehir escort aliağa escort altıeylül escort altınordu escort amasya escort anamur escort ankara escort antakya escort antalya escort araklı escort ardahan escort ardeşen escort arnavutköy escort atakum escort avanos escort avcılar escort aydın escort ayvacık escort ayvalık escort aziziye escort babaeski escort bafra escort bağcılar escort bağlar escort balıkesir escort bandırma escort bartın escort batıkent escort batman escort battalgazi escort bayburt escort belek escort besni escort beylikdüzü escort beyşehir escort biga escort bilecik escort bingöl escort birecik escort bismil escort bitlis escort bodrum escort bolu escort bor escort bornova escort boyabat escort bozüyük escort buca escort bucak escort bulancak escort bulanık escort bünyan escort burdur escort bursa escort çan escort çanakkale escort canik escort çankaya escort çankırı escort çarşamba escort çayeli escort çekmeköy escort çerkeş escort çerkezköy escort çeşme escort ceyhan escort çivril escort çorlu escort çorum escort çubuk escort çukurova escort çumra escort dalaman escort darıca escort datça escort davutlar escort defne escort denizli escort derince escort develi escort didim escort digor escort dinar escort diyadin escort diyarbakır escort doğanşehir escort doğubayazıt escort dörtyol escort dulkadiroğlu escort düzce escort edirne escort edremit escort efeler escort elazığ escort elbistan escort emirdağ escort erbaa escort erdemli escort ereğli escort erenler escort ergani escort ergene escort erzincan escort erzurum escort escort esenler escort eskil escort eskişehir escort espiye escort eyyübiye escort fatih escort fatsa escort fethiye escort finike escort fındıklı escort gaziantep escort gaziemir escort gebze escort gediz escort gelibolu escort gemerek escort gemlik escort gerede escort giresun escort gölbaşı escort gölcük escort görele escort görükle escort göynük escort gümbet escort gümüşhane escort güngören escort güroymak escort gürsu escort hakkari escort haliliye escort hatay escort haymana escort horasan escort iğdır escort ilgaz escort i̇lkadım escort i̇negöl escort i̇skenderun escort isparta escort i̇stanbul escort i̇zmir escort i̇zmit escort i̇znik escort kadirli escort kadıköy escort kağıthane escort kağızman escort kahta escort kaman escort kangal escort kapaklı escort karabük escort karacabey escort karahayıt escort karaköprü escort karaman escort karatay escort karesi escort kars escort karşıyaka escort kartal escort kaş escort kastamonu escort kaynaşlı escort kayseri escort keçiören escort kemer escort kepez escort keşan escort keskin escort kestel escort kilis escort kırıkhan escort kırıkkale escort kırkağaç escort kırklareli escort kırşehir escort kızıltepe escort kocaeli escort kocasinan escort konak escort konya escort konyaaltı escort körfez escort korkuteli escort köyceğiz escort kozan escort kumluca escort kumru escort kuşadası escort kütahya escort lara escort lüleburgaz escort malatya escort malazgirt escort malkara escort maltepe escort mamak escort manavgat escort manisa escort maraş escort mardin escort marmaris escort melikgazi escort menemen escort menteşe escort meram escort mersin escort merzifon escort mezitli escort milas escort mucur escort mudanya escort mudurnu escort muğla escort muratpaşa escort muş escort mut escort nazilli escort nevşehir escort niğde escort niksar escort nilüfer escort nizip escort nurdağı escort ödemiş escort of escort oltu escort onikişubat escort ordu escort orhangazi escort ortahisar escort ortaköy escort osmancık escort osmangazi escort osmaniye escort palandöken escort pamukkale escort pamukova escort patnos escort payas escort pazar escort pazarcık escort pendik escort polatlı escort rize escort safranbolu escort şahinbey escort sakarya escort salihli escort samandağ escort samsun escort sandıklı escort şanlıurfa escort sapanca escort sarıçam escort sarıkamış escort sarıyer escort şarkışla escort şehitkamil escort selçuklu escort selim escort serdivan escort serik escort seyhan escort siirt escort silifke escort simav escort sincan escort sinop escort şişli escort sivas escort siverek escort şırnak escort söğüt escort söke escort soma escort sultangazi escort suluova escort sungurlu escort sur escort suruç escort suşehri escort susurluk escort talas escort tarsus escort taşova escort tavşanlı escort tekirdağ escort terme escort tire escort tirebolu escort tokat escort torbalı escort toroslar escort trabzon escort turgutlu escort turhal escort türkoğlu escort tuzla escort ulus escort ümraniye escort ünye escort ürgüp escort urla escort uşak escort üsküdar escort üzümlü escort van escort varto escort viranşehir escort yahşihan escort yahyalı escort yakutiye escort yalova escort yatağan escort yenişehir escort yeşilyurt escort yıldırım escort yıldızeli escort yomra escort yozgat escort yunusemre escort yüreğir escort zara escort zeytinburnu escort zile escort zonguldak escort mersin escort aydın escort manisa escort muğla escort tekirdağ escort urfa escort yalova escort fethiye escort