• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
dwtfukgv
博客园    首页    新随笔    联系   管理    订阅  订阅
HDU 6775 Poker (简单数学)

Poker

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 452    Accepted Submission(s): 175


Problem Description
小沃沃在玩一个有趣的游戏。

初始他有 n 块钱,每一轮他需要投入至少 m 块钱,系统会拿走其中 p% 的钱,并把剩下的钱还给他。

请问在最优情况下,小沃沃最多可以玩多少轮?

假设当前一轮小沃沃投入了 x 块钱,那么他可以收回 ⌊x×(1−p%)⌋ 块钱,其中 ⌊a⌋ 表示 a 取下整。
小沃沃每一轮投入的钱不能超过他现在拥有的钱。

每一轮投入的钱必须为整数。
 

 

Input
第一行一个正整数 test(1≤test≤100000) 表示数据组数。

对于每组数据,一行三个整数 n,m,p(1≤n≤100000,1≤m≤1000,1≤p≤100)。
 

 

Output
对每组数据输出一行一个整数表示答案。
 

 

Sample Input
2 10 2 50 10 2 100
 

 

Sample Output
9 5
 

 

Source
2020 年百度之星·程序设计大赛 - 初赛二
 

 

Recommend
heyang
 

 

Statistic | Submit | Discuss | Note

析:只要算出每一轮亏了多少钱,然后就可以计算出最多能玩多少轮,注意一下一轮都玩不了的情况和每轮都全部亏掉的情况就行了。

#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 <sstream>
#include <list>
#include <assert.h>
#include <bitset>
#include <numeric>
#define debug() puts("++++")
#define print(x) cout<<(x)<<endl
// #define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a, b, sizeof a)
#define sz size()
#define be begin()
#define ed end()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
#define all 1,n,1
#define FOR(i,n,x)  for(int i = (x); i < (n); ++i)
#define freopenr freopen("in.in", "r", stdin)
#define freopenw freopen("out.out", "w", stdout)
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e17;
const double inf = 1e20;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 500 + 7;
const int maxm = 2000000 + 7;
const LL mod = 1e9 + 7;
const int dr[] = {-1, 1, 0, 0, 1, 1, -1, -1};
const int dc[] = {0, 0, 1, -1, 1, -1, 1, -1};
int n, m;

inline bool is_in(int r, int c) {
  return r >= 0 && r < n && c >= 0 && c < m;
}
inline int readInt(){
  int x;  cin >> x;  return x;
}



int main(){
  int T;  scanf("%d", &T);
  while(T--){
    int x;
    scanf("%d %d %d", &n, &m, &x);
    if(n < m){
      printf("0\n");
      continue;
    }
    int det = m - (100-x) * m / 100;
    if(det == 0)  printf("%d\n", n/m);
    else printf("%d\n", (n-m)/det+1);
  }
  return 0;
}

  

posted on 2020-07-27 16:37  dwtfukgv  阅读(240)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3