Forever Young

HDU1846 Brave Game

题目分析

经典的巴什博奕题,具体讲解可以看这里

代码

/*
Author: Loceaner
知识点: 巴什博奕 
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm> 
using namespace std;

inline int read() {
  char c = getchar(); int x = 0, f = 1;
  for ( ; !isdigit(c); c = getchar()) if (c == '-') f = -1;
  for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  return x * f;
}

inline void solve() {
  int n = read(), m = read();
  if (n % (m + 1) == 0) puts("second");
  else puts("first");
}

int main() {
  int T = read();
  while (T--) solve();  
}
posted @ 2020-09-09 19:34  Loceaner  阅读(76)  评论(0)    收藏  举报