Yesterday 18 Preliminaries today (⊙o⊙)
I've decided to do a good job of documenting the issues.
Although not much of a relationship, always feel that this can be regarded as a node, can be a slight change of opportunity
So... For the last simulation of the T1 so simple law has not found this, today did some number theory (especially to find the law) topic
https://www.luogu.org/problemnew/show/P2158
Title Description
As a sports Commissioner, C June is responsible for the training of the honor guard. Guard of Honor is composed of students of N * N of the square, in order to ensure that the procession uniform, c June will follow the guard of Honor's left rear, according to the number of students in the line of sight to determine whether the team is neat (such as). Now, C-June wants you to tell him the number of students you can see when the team is neat.
Input/output format
Input format:
A total of a number n
Output format:
A total of a number, that is, c June should see the number of students.
Input and Output Sample input example # #:
4
Sample # # of output:
9
Description
"Data size and conventions"
For 100% of data, 1≤n≤40000
First think of the playing table to find the regular O (n^2)
From the (0,0) point oblique to the right to do a ray, if there are two points slope the same, it must only see the nearest one
= = If there are two points (x1,y1) and (x2,y2) make x1/y1=x2/y2 (X1<x2,y1<y2) that (x2,y2) is bound to be blocked, and because the coordinates of the point are integers, then x2, y2 is x1, y1 the integer times
= = The point that is not blocked must be numerator to the simplest, that is, the X and Y greatest common divisor of the (x, y) point are 1
=>gcd
/* $*/#include<iostream>#include<cstring>#include<cstdio>using namespacestd;intN;intAns;inlineintFINDGCD (intAintb) { return!B?A:FINDGCD (b,a%b);}intMain () {scanf ("%d",&N); if(n==1) {printf ("0\n"); return 0; } for(intI=2; i<n;i++){ for(intj=1; j<i;j++) {//J<i intGcd=FINDGCD (I,J); if(gcd>1)Continue; Ans++; }} ans= (ans<<1)+3; printf ("%d", ans); return 0;}
Then, then, it's tle.
Then set a while (n<=100) crazy to find the law ...
But in vain.
Wait a minute
Could there be forgot something.
"X and Y greatest common divisor are 1"
"Let X, y coprime"
"How many pairs of x, y coprime are in the N range?"
Euler function eh
#include <iostream>#include<cstring>#include<cstdio>#defineN 400005using namespacestd;intN,ans;intA[n];intMain () {scanf ("%d",&N); if(n==1) {printf ("0\n"); return 0; } for(intI=1; i<=n;i++) a[i]=i; for(intI=2; i<=n;i++){ if(a[i]==i) { for(intj=i;j<=n;j+=i) {A[j]=a[j]/i* (I-1); } } } for(intI=2; i<n;i++) ans+=A[i]; Ans= (ans<<1)+3; printf ("%d", ans); return 0;}
Euler functions
[SDOI2008] honor guard