Sieve the Euler function and you can do it.#include
2190: [SDOI2008] Honor guard Time
limit:10 Sec Memory limit:259 MBsubmit:2560 solved:1631[Submit] [Status] [Discuss]
DescriptionAs a sports Commissioner, C June is responsible for the training of the honor guard.
2190: [SDOI2008] Honor guard Time
limit:10 Sec Memory limit:259 MBsubmit:2717 solved:1731[Submit] [Status] [Discuss]
DescriptionAs a sports Commissioner, C June is responsible for the training of the honor guard. Guard of Ho
Reprint please specify source [ametake copyright all]http://blog.csdn.net/ametake Welcome to seeTitle Source: SDOI2008The article is very serious plagiarism, so I'll bring the copyright informationFirst question.Topic description Narrative Description As a sports commissioner. C June is responsible for the training of the Guard of Honor. The Guard of
, and then the original coordinates of the two next to the first, so +2, so the answer is$$1+2\sum_{1#include
DescriptionAs 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
Title Description DescriptionAs 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,
DescriptionAs 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
Suppose the C-June is (0, 0), then the upper right is (n-1, n-1).The premise that a point (x, y) can be seen is gcd (x, y) = 1, so answer =∑phi (i) * 2 + 2-1 =∑phi (i) * 2 + 1 (1 -------------------------------------------------------------------------#include using namespace std;const int MAXN = 40009;int PHI[MAXN], n; void Phis () {for (int i = 1; i for (int i = 2; i For (int j = i; J Phi[j] = phi[j]/I * (i-1);}int main () {int ans = 0;cin >> N;phis ();for (int i = 1; i cout return 0;}--------
I-Honor GuardTime limit:10000MS Memory Limit:265216KB 64bit IO Format:%lld %llu SubmitStatusDescriptionAs 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
Describe 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 Square, in order to ensure that the team in the March uniform, C June will follow the guard of
Title DescriptionDescriptionAs 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,
DescriptionAs 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 application of Euler functionOriginal question: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
;Set ASo we only need to enumerate each prime, each number (here can be used to maintain the prefix of N, recorded as F[n]) to solve the ans=σf[n/prime[i]]*2-1 (consider a>b, and subtract values such as ().#include Const intmaxn=10000010;BOOLPD[MAXN];Long LongPhi[maxn],prime[maxn],top,n,ans;voidES () { for(intI=2; i){ if(!Pd[i]) {prime[++top]=i; Phi[i]=i-1; } for(intj=1; j) {Pd[prime[j]*i]=1; if(i%prime[j]==0) {Phi[prime[j]*i]=phi[i]*Prime[j]; Break; } Phi[prime[j]*i]=phi[i]* (pr
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 opportunitySo... For the last simulation of the T1 so simple law has not found this, today did some number theory (especially to find the law) topichttps://www.luogu.org/problemnew/show/P2158Title DescriptionAs a sports Commissioner, C June is responsible for the training of the
The upper triangle line is exactly the Euler function of [1,n-1]Http://www.luogu.org/problem/show?pid=2158#sub1 //#pragma COMMENT (linker, "/stack:167772160")2#include 3#include 4#include 5#include 6#include 7#include 8#include 9#include Set>Ten#include One#include A#include -#include - //#include the using namespacestd; - #defineCLC (A, B) memset (A,b,sizeof (a)) - #defineLL Long Long - voidfre () { +Freopen ("In.txt","R", stdin); - } + Const intINF =0x3f3f3f3f; A #defineEPS 1e-8 at //cons
"Topic link"http://www.lydsy.com/JudgeOnline/problem.php?id=2190Test instructionsN*n Square, the number of squares that can be seen in the (0,0) lattice.IdeasPreprocessing the Euler function.(x, y) the =1,1Of course, you can use Möbius inversion, too lazy to write (?  ̄  ̄)?Code1#include 2#include 3#include 4 using namespacestd;5 6 Const intN = 5e4+Ten;7 8 intN;9 intPhi[n];Ten One voidGet_phi (intN) A { -phi[1]=1; - for(intI=2; iif(!Phi[i]) the { - for(intj=i;ji) - { -
Title Effect: There is a grid component diagram, assuming that three people in a straight line, then the first person will not see a third person. Now, there is a man standing in the. I asked him if he could see the matrix of the number of n*n.Think: If you want to stand (in the first place) This man sees a position (x, y) of a person. GCD (x, y) = = 1, which is a classic model, only requires a PHI within N and is able to.The method is linear sieve.CODE:#include Copyright notice: This article B
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.