Math +DP codeforces Round #304 (Div. 2) D. Soldier and number Game

Source: Internet
Author: User

Topic Portal

1 /*2 Test Instructions: The problem is to find the number of factors b+1 to a and. 3 Mathematical +dp:a[i] Save the minimum factor of I, dp[i] = dp[i/a[i]] +1; another prefix and4 */5 /************************************************6 Author:running_time7 Created time:2015-8-1 14:08:348 File name:b.cpp9  *************************************************/Ten  One#include <cstdio> A#include <algorithm> -#include <iostream> -#include <sstream> the#include <cstring> -#include <cmath> -#include <string> -#include <vector> +#include <queue> -#include <deque> +#include <stack> A#include <list> at#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> - using namespacestd; in  -typedefLong Longll; to Const intMAXN = 5e6 +Ten; + Const intINF =0x3f3f3f3f; - Const intMOD = 1e9 +7; the intCNT[MAXN]; * intA[MAXN]; $ BOOLIS_PRIME[MAXN];Panax Notoginseng intprime[maxn/Ten]; - ll DP[MAXN]; the ll SUM[MAXN]; +  A voidSolvevoid)    { thememset (Is_prime,true,sizeof(Is_prime)); +      for(intI=2; i<=5000000; ++i) A[i] =i; -     inttot =0; $      for(intI=2; i<=5000000; ++i) { $         if(Is_prime[i]) Prime[++tot] =i; -          for(intj=1; J<=tot && i*prime[j]<=5000000; ++j) { -             intTMP = i *Prime[j]; theIS_PRIME[TMP] =false; -             if(A[tmp] > Prime[j]) a[tmp] =Prime[j];Wuyi             if(i% prime[j] = =0) Break; the         } -     } Wudp[2] =1; -      for(intI=3; i<=5000000; ++i) { AboutDp[i] = Dp[i/a[i]] +1; $     } -      for(intI=2; i<=5000000; ++i) { -Sum[i] = sum[i-1] +Dp[i]; -     } A } +  the intMainvoid)    {//codeforces Round #304 (Div. 2) D. Soldier and number Game - solve (); $     intT scanf ("%d", &T); the      while(t--) { the         intL, R; scanf ("%d%d", &r, &l); the         if(L = =r) { thePuts ("0");Continue; -         } inprintf ("%i64d\n", Sum[r]-sum[l]); the     } the  About     return 0; the}

Math +DP codeforces Round #304 (Div. 2) D. Soldier and number Game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.