计蒜客----Benelux Algorithm Programming Contest 2016 Preliminary

释放无限光明的是人心,制造无边黑暗的也是人心,光明和黑暗交织着,厮杀着,这就是我们为之眷恋又万般无奈的人世间。

                                                   A. Block Game

Description

You are attending the International Construction by Preschoolers Contest. Unfortunately,you are too old to participate, but you still enjoy watching the competition.In between rounds, you are walking around the contest area when you see a toddler, one ofthe contestants, playing with her blocks. Annoyed that she is having all the fun, you decideto challenge her to a game.You set up two stacks of blocks of a certain height. Then, you and the toddler take turnsremoving some number of blocks from the stack which contains the largest number of blocks(if both stacks have the same number of blocks, the current player can choose either stackto remove blocks from). The number of blocks removed must be a positive multiple of thenumber of blocks in the smaller stack. For instance, if there is a stack with 5 blocks, and onewith 23 blocks, then the current player can remove 5, 10, 15 or 20 blocks from the stack of23 blocks. The player who empties one of the stacks wins the game.You have graciously decided to take the first move, but then a worry strikes you – might thisdevious preschooler still be able to beat you?

Input

One line with two integers N and M, satisfying 1 <= N,M <= 10^{18}1018, the initial sizes of the twostacks of blocks.

Output

Output a single line containing a single word: the word “win” if you are guaranteed to winif you play correctly, and the word “lose” if your opponent can force you to lose.

输出时每行末尾的多余空格,不影响答案正确性

样例输入1复制

3 2

样例输出1复制

lose

样例输入2复制

3 3

样例输出2复制

win

样例输入3复制

5 2

样例输出3复制

win
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
typedef long long ll;
using namespace std;
int const mod=1e9+7;
const int maxn=3e5+10;
ll M,N,ct;
int main(){
	cin>>N>>M;
	ll fg=0,mx=max(N,M),mi=min(M,N);
	if(mx%mi==0)
		cout<<"win"<<endl;
	else{
//		cout<<mx<<' '<<mi<<endl;
		while(mx%mi!=0){
			if(mx/mi>1){
				fg=1;
				break;
			}
			ct+=1;
			ll ls=mx%mi;
			mx=mi;
			mi=ls;
		}
//		cout<<fg<<endl;
		if(fg==0&&ct%2==1)
			cout<<"lose"<<endl;
		else
			cout<<"win"<<endl;
	}
	return 0;
}

                                        C. Completing the Square

In the heart of your home city, there is an old square, close to the train station, appropriately called _Station Square_. It used to look like a perfect square: four sides of equal length joined by right angles. However, it hasn’t looked like this for decades, as one of the four corners was destroyed by bombings in the Second World War. After the war, the square was rebuilt as a quarter circle, and it has looked like that ever since. (In other words, it looks like an isosceles right triangle, except that the hypothenuse is not a straight line but a circular arc.) This is illustrated in the figure below, which corresponds with Sample Input 1. 

Image

Figure 1: Illustration of the first example input.

Recently, the city council voted to completely remodel the train station and its surroundings, which includes restoring Station Square to its original state. Therefore they need to determine the exact location of the fourth corner. This task is too complicated for ordinary aldermen, so the city decided to hire a top scientist. That would be you! Please help the city complete the square, and you will be greatly rewarded!

Input

There are three lines of input. Each line contains two integers denoting the xx and yy coordinates of one of the corners of the current square (-10^4 \leq x,y\leq 10^4−104≤x,y≤104). 

Output

Output one line with two space-separated integers denoting the xx and yy coordinates of the long-lost fourth corner.

输出时每行末尾的多余空格,不影响答案正确性

样例输入1复制

2 -5
-8 -1
-5 -8

样例输出1复制

-1 2

样例输入2复制

0 0
1 0
1 1

样例输出2复制

0 1

样例输入3复制

2 -1
-2 3
2 7

样例输出3复制

6 3
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
typedef long long ll;
using namespace std;
int const mod=1e9+7;
const int maxn=3e5+10;
int x[5],y[5],X,Y;
int main(){
	int q1,q2,q3,p1,p2,p3;
	for(int i=1;i<=3;i++)
		cin>>x[i]>>y[i];
	q1=x[1]-x[2];
	p1=y[1]-y[2];
	q2=x[1]-x[3];
	p2=y[1]-y[3];
	q3=x[2]-x[3];
	p3=y[2]-y[3];
//	cout<<k1<<' '<<k2<<' '<<k3<<endl;
	if(q1*q2+p1*p2==0){
		X=x[3]-q1;
		Y=y[3]-p1;
		cout<<X<<' '<<Y<<endl;
	}
	else if(q1*q3+p1*p3==0){
		X=x[3]+q1;
		Y=y[3]+p1;
		cout<<X<<' '<<Y<<endl;
	}
	else if(q2*q3+p2*p3==0){
		X=x[2]+q2;
		Y=y[2]+p2;
		cout<<X<<' '<<Y<<endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44170305/article/details/108415294
今日推荐