Codeforces 546D Soldier and number game table (count of quality factors)

Source: Internet
Author: User

Title: Poke Me

Test instructions: Test instructions read the above a large string of English is actually very simple, is to give you a positive integer n, ask you n how many qualitative factors, but here n is given by a!/b!, that is, n= (a!/b!);

Analysis: Because here 1≤ ba ≤5 000 000, the data is very large, so simple violence must time out, specific look at the code.

1#include <iostream>2#include <cstdio>3 using namespacestd;4 Const intM = 5e6+5;5 6 intT; Number of test groups7 intNum[m] = {0}; Table, the number of the quality factor of n is stored in num[n]8 intSum[m] = {0}; Sum[i] (from num[1] to Num[i] and9 voidgetsum () {Tennum[1] =1; Onenum[2] =1; A      for(intI=2; i<m; i++ )    { -         if(Num[i] >1)//Determine if I is a prime number -             Continue; theNum[i] =1; -          for(intj=2; j*i<m; J + + )  { -Num[j*i] = Num[j] +1; -         } +     } -      for(intI=1; i<m; i++ ) +Sum[i] = sum[i-1] +Num[i]; A } at  - intMain () - { - getsum (); -scanf"%d", &t); -      while(t-- )    { in         intA, B; -scanf"%d%d", &a, &b); toprintf"%d\n", Sum[a]-sum[b]); +     } -}

Codeforces 546D Soldier and number game table (count of quality factors)

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.