BZOJ2659_算不出的算式_KEY
其实打表找一找规律可以得出:
/************************************************************** Problem: 2659 User: yekehe Language: C++ Result: Accepted Time:0 ms Memory:820 kb ****************************************************************/ #include <cstdio> using namespace std; long long x,y; int main() { scanf("%lld%lld",&x,&y); if(x==y)y++; printf("%lld",(x>>1)*(y>>1)); return 0; }
证明则是设q/p为一条直线的斜率。
p=q时则是求直线上的整点的横纵坐标和,p≠q时则是求直线上下整点的和。
code:
/************************************************************** Problem: 2659 User: yekehe Language: C++ Result: Accepted Time:0 ms Memory:820 kb ****************************************************************/ #include <cstdio> using namespace std; long long x,y; int main() { scanf("%lld%lld",&x,&y); if(x==y)printf("%lld",(x-1)*(y+1)/4); else printf("%lld",(x-1)*(y-1)/4); return 0; }