Gym 100512F Funny Game (博弈+数论)
题意:给两个数 n,m,让你把它们分成 全是1,每次操作只能分成几份相等的,求哪一个分的次数最多。
析:很明显,每次都除以最小的约数是最优的。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e4 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[3205];
vector<int> prime; int main(){
freopen("funny.in", "r", stdin);
freopen("funny.out", "w", stdout);
m = sqrt(3200+0.5);
memset(a, 0, sizeof a);
for(int i = 2; i <= m; ++i) if(!a[i]){
for(int j = i*i; j <= 3200; j += i) a[j] = 1;
}
for(int i = 2; i <= 3200; ++i) if(!a[i]) prime.push_back(i); while(scanf("%d %d", &n, &m) == 2 && m+n){
if(m == n){ printf("%d %d - Harry\n", n, m); continue; }
printf("%d %d - ", n, m);
int ans1 = 0, ans2 = 0;
for(int i = 0; i < prime.size(); ++i){
while(n % prime[i] == 0) n /= prime[i], ++ans1;
while(m % prime[i] == 0) m /= prime[i], ++ans2;
if(1 == n && 1 == m) break;
} if(n != 1) ++ans1;
if(m != 1) ++ans2;
if(ans1 <= ans2) puts("Harry");
else puts("Vera");
}
return 0;
}
Gym 100512F Funny Game (博弈+数论)的更多相关文章
- 2017 ACM-ICPC EC-Final ShangHai 东亚洲大陆-上海
比赛链接:传送门 Gym 101775A Chat Group(签到:待补) Gym 101775B Scapegoat(待补) Gym 101775C Traffic Light(贪心+思维) 思路 ...
- Gym 100952G&&2015 HIAST Collegiate Programming Contest G. The jar of divisors【简单博弈】
G. The jar of divisors time limit per test:2 seconds memory limit per test:64 megabytes input:standa ...
- Gym - 101350E Competitive Seagulls (博弈)
There are two seagulls playing a very peculiar game. First they line up N unit squares in a line, al ...
- Zoj 3529 A Game Between Alice and Bob 数论+博弈Nim 快速求数中有多少个素数因子
本题涉及博弈论中的Nim游戏博弈. Nim游戏博弈详解链接: http://www.cnblogs.com/exponent/articles/2141477.html 本题解题报告详解链接: htt ...
- Gym - 101246D 博弈
题意:一个无向有环的图,从 1 号结点起火,开始蔓延,两个绝顶聪明的人轮流走,谁不能走谁输,输出输的人: 分析: 当时知道是博弈,但是想当然的以为 1 号结点有一个奇数层,就必胜:其实不是这样的,当一 ...
- Gym - 101775L SOS 博弈 找规律
题目:https://cn.vjudge.net/problem/Gym-101775L PS:训练赛中被这道题折磨的不轻,和队友反复推必胜态与必败态试图推导出公式或者规律,然后推的心态逐渐失控,,, ...
- Gym 100827G Number Game (博弈)
Number Game Alice and Bob are playing a game on a line of N squares. The line is initially populated ...
- Gym 100917C Constant Ratio 数论+暴力
题目: Description standard input/outputStatements Given an integer n, find out number of ways to repre ...
- L - SOS Gym - 101775L 博弈
题目链接:https://cn.vjudge.net/contest/274151#problem/L 题目大意:给你一个1*n的方格,两个人轮流放字母,每一次可以放"S"或者&q ...
随机推荐
- myql导入导出命令
1.导出整个数据库 mysqldump -u 用户名 -p --default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1) mysqld ...
- SQL SERVER 2012 第五章 创建和修改数据表 の SQL SERVER中的对象名
[ServerName.[DataBaseName.[SchemeName.]]]ObjectName 服务器名,数据库名,模式名,对象名 其中模式是一个新出的坑爹的东西.
- webstorm初始化
1.皮肤设置,重启后Terminal皮肤生效 2.排除目录 2.1全局排除 2.2局部排除 选中文件夹 右击Make Directroy As 选择 Excluded 3.代码自定义 3.1 cons ...
- 洛谷——P1547 Out of Hay
P1547 Out of Hay 题目背景 奶牛爱干草 题目描述 Bessie 计划调查N (2 <= N <= 2,000)个农场的干草情况,它从1号农场出发.农场之间总共有M (1 & ...
- navicat 无法连接到腾讯云Mysql
远程连接进入服务器 远程连接进入服务器之后,输入命令mysql -u root -p 之后输入mysql密码,进入mysql 命令环境 设置开启远程登录 GRANT ALL PRIVILEGES ON ...
- Jmeter的几个关键配置文件
1.配置文件位于bin目录下: 2.配置文件可能存在优先级关系,好像user.properties会覆盖jmeter.properties,一般修改配置都是修改或者添加user.properties, ...
- linux字符驱动之poll机制按键驱动
在上一节中,我们讲解了如何自动创建设备节点,实现一个中断方式的按键驱动.虽然中断式的驱动,效率是蛮高的,但是大家有没有发现,应用程序的死循环里的读函数是一直在读的:在实际的应用场所里,有没有那么一种情 ...
- 鼠标放上去Div旋转特效代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- C#趣味程序---百鸡百钱
问题:公鸡一仅仅5元,母鸡一仅仅3元,小鸡三仅仅1元.问100元能够买多少仅仅鸡? using System; namespace ConsoleApplication1 { class Progra ...
- Android 怎样在java/native层改动一个文件的权限(mode)与用户(owner)?
前言 欢迎大家我分享和推荐好用的代码段~~ 声明 欢迎转载.但请保留文章原始出处: CSDN:http://www.csdn.net ...