The military training of HH (allowance)

Source: Internet
Author: User

1248:HH Military Training time limit: 1 Sec memory limit: MB submitted: 11 [Submit] [status] [discussion] Title Description

University, the most memorable thing is military training, white HH children's shoes are ruthless tanning, saying that during military training, the most feared is to be instructors tease, as the saying goes: Cherish life, away from instructors. Instructors always love to let students stand square, because a lot of classmates, will inevitably have the students in front of the students in the back, in order to stay away from the instructor, we all hope that their position instructor can not see themselves, now if the students stand in a coordinate point of the matrix, the students are standing in each group of integers, and the instructor standing in the coordinates Please tell me how many positions instructors can see directly at this time!

Input

The first line enters a T, which represents the T-group test data.

Next, enter two digital m,n per line, and for any one of the students coordinate position (x, y), there are 1<=x<=m<=10000,1<=y<=n<=10000.

Output

Output How many positions instructors can see.

Sample input
21 42 3
Sample output
45
The puzzle: wa ... No words, the wrong afternoon ... Or WA, put it on first;
Code:
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include < Algorithm> #include <vector>using namespace std; #define MEM (x, y) memset (x,y,sizeof (×)) typedef long Long LL; Vector<int>p;void getp (int x) {for (int i=2;i*i<x;i++) {if (x%i==0) {p.push_back (i), while (x%i==0) x/=i;}} if (x>1) p.push_back (x);} int getn (int x) {int sum=0;/*for (int i=0;i<p.size (); i++) {cur=p[i];sum+=x/cur;for (int j=i+1;j<p.size (); j + +) {cur *=-p[j];sum+=x/cur;}} *///This method does not work if it is 2,3,4, then 2, 4 can not be selected .... for (int i=1;i< (1<<p.size)), ++i) {int num=0,mult=1;for (int k=0;k< (int) p.size (); k++) {if (i& (1< <k)) {mult*=p[k];num++;}} if (num&1) sum+=x/mult;//is missing the equals sign: else Sum-=x/mult;} printf ("%d\n", sum); return sum;} int main () {int t,m,n;scanf ("%d", &t), while (t--) {scanf ("%d%d", &m,&n); int ans=m;for (int i=2;i<=n;i++) { P.clear (); Getp (i); Ans+=m-getn (M);} printf ("%d\n", ans);} return 0;}

  

HH's military training (allowance)

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.