December 2014 8-14th, my goal is to fully understand the principle of repulsion, by the way to organize the template!
The principle of tolerance should be very easy in mathematics, it is no longer described here!
Take one of the following topics: Give 2 digital m,n, and find out how many numbers and N coprime are in 1-m (ensure that all numbers do not exceed int type)!
Array implementations
#include <cstdio>int p[10],k;//p array is used to hold the mass factor of n, the int type n will not exceed 10 void getp (int n) { k=0; for (int i=2;i*i<=n;i++) { if (n%i==0) p[k++]=i; while (n%i==0) n/=i; } if (n>1) p[k++]=n;//prevents a mass factor with a greater than n-Root, K preserves the number of factors}int nop (int m) { int i,j,que[10000],top=0,t,sum; que[top++]=-1;//Queue array Save n the product for (i=0;i<k;i++) {t=top;//t of any combination of the mass factors for the current que length, which facilitates the following loops to use the for (j=0 ; j<t;j++) { que[top++]=que[j]*p[i]* ( -1); } The number of quality factors: odd plus even minus, so multiply the number of i=1,sum=0;i<top;i++} for (//sum) to accumulate all the numbers sum+=m/que[i]; return sum;} int main () { int n,m; while (scanf ("%d%d", &m,&n) ==2) { //to 1-m How many numbers are associated with n coprime getp (n);//n Quality Factor printf ("%d\n", M-nop (m) );//Total minus } return 0;}
The way to learn the principle of tolerance and repulsion theory