Portal
Previous questions
During the training, the teacher told jokes together.
This question first look for a regular table on the guess is P-1) * (q-1)/4
Without a set of Sigma, the formula is first divided into two (in fact, the same)
Then consider each item before the subsummation.
For each K, the result is an integer in Y = Q/P * X.
Then the other side is the complementary side.
(The two parts of this formula are the integral points of the two parts divided by the main diagonal line of a square chart ([p/2], [q/2]) [], indicating the rounded down
The figure is about long.
Since p and q are prime numbers, only when they are equal will there be less P points (Boundary)
Code:
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<queue> 5 #define ms(a,b) memset(a,b,sizeof a) 6 #define rep(i,a,n) for(int i = a;i <= n;i++) 7 #define per(i,n,a) for(int i = n;i >= a;i--) 8 #define inf 1000000007 9 using namespace std;10 typedef long long ll;11 typedef double D;12 #define eps 1e-813 ll read() {14 ll as = 0,fu = 1;15 char c = getchar();16 while(c < ‘0‘ || c > ‘9‘) {17 if(c == ‘-‘) fu = -1;18 c = getchar();19 }20 while(c >= ‘0‘ && c <= ‘9‘) {21 as = as * 10 + c - ‘0‘;22 c = getchar();23 }24 return as * fu;25 }26 //head27 ll p,q,ans;28 int main() {29 p = read(),q = read();30 ans = (p>>1)*(q>>1);31 if(p == q) ans += p>>1;32 printf("%lld\n",ans);33 return 0;34 }
View code
Luogup4132 [bjoi2012] cannot calculate the equality Number Theory