BZOJ2659: [Beijing wc2012]算不出的算式

转化成直线下点数

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
char c;
#define ll long long
inline void read(ll &a)
{
   a=0;do c=getchar();while(c<'0'||c>'9');
   while(c<='9'&&c>='0')a=(a<<3)+(a<<1)+c-'0',c=getchar();
}


int main()
{
    ll p,q;
    read(p),read(q);
    printf("%lld",(p^q)?((p-1)*(q-1)>>2):((p-1)*(p+1)>>2));
    return 0;
}  

你可能感兴趣的:(BZOJ2659: [Beijing wc2012]算不出的算式)