2659: [Beijing wc2012] computing formula time limit: 3 sec memory limit: 128 MB
Submit: 668 solved: 366
[Submit] [Status] Description
Uncomputation Formula
Background:
I once had an old game in front of me, and I did not cherish it. It was not until this game was stopped that it had no regrets. This is the most painful thing in the world. If God gives me another chance to play, I must pass the Customs!
Description:
If you really want to play this game, let's take a look at my questions first. If you don't know this, you won't be able to perform customs clearance. The first step is actually very simple. There is only one door closed with a password lock. There is a strange formula written on this door. It is estimated that you should use it to calculate the password to open the door (it is really an old story ).
In legend, p and q in this formula are two odd numbers. The right side of the equal sign should be the password. Are you sure you cannot calculate it?
Input
There is only one row, and there are two odd numbers, p and q respectively.
Output
A number indicates the formula result.
Sample input 5 7
Sample output 6
Hint
Hint: p and q are within the 32-bit integer range.
Source
Question:
I was planning to write a cute question, and I found myself wa...
Randdorf:
If P <> q, there is no grid point online, you can directly combine the two blocks, convert them into a rectangle, and then calculate them directly.
If P = Q, no need to mention it.
..............
Actually, they can work together... Feeling not strict...
Digging and solving
Code:
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<iostream> 7 #include<vector> 8 #include<map> 9 #include<set>10 #include<queue>11 #include<string>12 #define inf 100000000013 #define maxn 500+10014 #define maxm 500+10015 #define eps 1e-1016 #define ll long long17 #define pa pair<int,int>18 #define for0(i,n) for(int i=0;i<=(n);i++)19 #define for1(i,n) for(int i=1;i<=(n);i++)20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)22 #define mod 100000000723 using namespace std;24 inline ll read()25 {26 ll x=0,f=1;char ch=getchar();27 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}28 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}29 return x*f;30 }31 ll p,q;32 int main()33 {34 freopen("input.txt","r",stdin);35 freopen("output.txt","w",stdout);36 p=read();q=read();37 if(p==q)printf("%lld\n",(p-1)*(q+1)>>2);38 else printf("%lld\n",(p-1)*(q-1)>>2);39 return 0;40 }
View code
Bzoj2659: [Beijing wc2012] uncomputation Formula