Codeforces 451A Game With Sticks

Description

After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of nhorizontal and m vertical sticks.

An intersection point is any point on the grid which is formed by the intersection of one horizontal stick and one vertical stick.

In the grid shown below, n = 3 and m = 3. There are n + m = 6 sticks in total (horizontal sticks are shown in red and vertical sticks are shown in green). There are n·m = 9 intersection points, numbered from 1 to 9.

The rules of the game are very simple. The players move in turns. Akshat won gold, so he makes the first move. During his/her move, a player must choose any remaining intersection point and remove from the grid all sticks which pass through this point. A player will lose the game if he/she cannot make a move (i.e. there are no intersection points remaining on the grid at his/her move).

Assume that both players play optimally. Who will win the game?

Input

The first line of input contains two space-separated integers, n and m (1 ≤ n, m ≤ 100).

Output

Print a single line containing "Akshat" or "Malvika" (without the quotes), depending on the winner of the game.

Sample test(s)

input

2 2

output

Malvika

input

2 3

output

Malvika

input

3 3

output

Akshat

Note

Explanation of the first sample:

The grid has four intersection points, numbered from 1 to 4.

If Akshat chooses intersection point 1, then he will remove two sticks (1 - 2 and 1 - 3). The resulting grid will look like this.

Now there is only one remaining intersection point (i.e. 4). Malvika must choose it and remove both remaining sticks. After her move the grid will be empty.

In the empty grid, Akshat cannot make any move, hence he will lose.

Since all 4 intersection points of the grid are equivalent, Akshat will lose no matter which one he picks.

•题意:给你n+m根筷子,将他们分别水平、垂直放置,形成n*m个节点。两个人轮流选择一个点,将穿过这个点的两根筷子拿走,谁可以逼迫对方率先无法继续操作,谁就获胜,问获胜的是先手还是后手。

•找规律即可。n,m中较小的那个数是奇数,先手胜,否则后手胜。

 1 #include<stdio.h>
 2
 3 int main()
 4 {
 5
 6     int n, m, a;
 7     while(scanf("%d%d", &n, &m) != EOF){
 8         if(n < m)
 9             a = n;
10         else
11             a = m;
12         if(a %2 == 1)
13             printf("Akshat\n");
14         else
15             printf("Malvika\n");
16     }
17     return 0;
18 }

Codeforces 451A Game With Sticks

时间: 2024-08-06 11:54:38

Codeforces 451A Game With Sticks的相关文章

CodeForces 451A

签到题,今天就水了这么一道题,不好意思说了... #include<iostream> using namespace std; int main() { int a,b; cin >> a>> b; int c = a<b?a:b; if(c%2 == 0) cout<< "Malvika"<< endl; else cout<<"Akshat" << endl; retur

【模拟】【codeforces】451A Game With Sticks

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=52106 现在有n根横着的木棍,m根竖着的木棍,交叉出n*m个交点 两个玩家轮流从现有交点中选择一个,并去掉和这个交点相连的木棍 当一个玩家没有木棍可以去掉时,另外一位玩家获胜 获胜的关键就是使对方没有木棍,或对方的木棍只有横的或竖的木棍,以致没有交点可以选择. 在最开始,每人选择一个点,都是去掉一横一竖,当去掉一个方向全部的木棍时,就赢了. 1 #include<bits/

Codeforces 525C Ilya and Sticks

题意:给你n条线段,问你这些线段可以组成的矩形和最大是多少.每条线段可以-1,. 解题思路:贪心. 解题代码: 1 // File Name: d.cpp 2 // Author: darkdream 3 // Created Time: 2015年03月27日 星期五 16时05分31秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<d

CSU-ACM暑假集训基础组训练赛(2) 解题报告

Problem A Codeforces 451A •题意:给你n+m根筷子,将他们分别水平.垂直放置,形成n*m个节点.两个人轮流选择一个点,将穿过这个点的两根筷子拿走,谁可以逼迫对方率先无法继续操作,谁就获胜,问获胜的是先手还是后手. •找规律即可.n,m中较小的那个数是奇数,先手胜,否则后手胜. 1 #include <cstdio> 2 int main(){ 3 int a,b; 4 scanf("%d%d",&a,&b); 5 a = a <

Codeforces Round #258 (Div. 2) A. Game With Sticks(数学题)

题目链接:http://codeforces.com/contest/451/problem/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma

贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

题目传送门 1 /* 2 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 3 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 using namespace std; 10 11 typedef long long ll; 12 13 co

Codeforces Round #425 (Div. 2) Problem A Sasha and Sticks

It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The rules

Codeforces Round #258 (Div. 2/A)/Codeforces451A_Game With Sticks

解题报告 http://blog.csdn.net/juncoder/article/details/38102263 n和m跟木棍相交,问一人取一交点(必须是交点,且取完后去掉交点的两根木棍),最后谁赢 思路: 取最大正方形,以对角线上的交点个数判断输赢. #include <iostream> #include <cstdio> using namespace std; int main() { int m,n; while(cin>>n>>m) { i

【Codeforces 258A】 Game With Sticks

[题目链接] http://codeforces.com/contest/451/problem/A [算法] 若n和m中的最小值是奇数,则先手胜,否则后手胜 [代码] #include<bits/stdc++.h> using namespace std; int n,m; int main() { scanf("%d%d",&n,&m); if (min(n,m) % 2 == 0) printf("Malvika\n"); else