列表

详情


NC236490. King of Gamers

描述

Little G is going to play n games.

Little G is the king of gamers. If he wants to win, he will definitely win a game. But if he doesn't care about winning or losing, he will lose a game because of his bad luck. Little G has an expected winning rate of . When playing the -th game, if his current winning rate is lower than or equal to , he will be eager to win and win the game easily. Otherwise, he will enjoy the game and lose it.

Given , Little G is wondering how many games he will win.
Note that when playing the first game, the winning rate is regarded as .

It is guaranteed that the answer is either  or .

输入描述

The input consists of multiple test cases.

The first line consists of a single integer  () - the number of test cases.

In the following  lines, each line consists of three integers  (), denoting a test case.


输出描述

Print  lines. Print one integer in each line, representing the answer of a test case.

示例1

输入:

3
4 3 5
8 7 10
1 1 3

输出:

2
5
1

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++ 解法, 执行用时: 433ms, 内存消耗: 1272K, 提交时间: 2022-06-18 20:37:47

#include<bits/stdc++.h>
using namespace std;
long long T,n,a,b;
int main(){
	cin>>T;
	while(T--)
	{
		cin>>n>>a>>b;
		cout<<(n-1)*a/b+1<<'\n';
	}
}

pypy3 解法, 执行用时: 952ms, 内存消耗: 30088K, 提交时间: 2022-04-17 18:30:50

for i in range(int(input())):
    n,a,b = map(int,input().split())
    print(int((n-1)*a/b)+1)

Python3 解法, 执行用时: 1147ms, 内存消耗: 5400K, 提交时间: 2022-04-21 10:41:59

T=int(input())
while T:
    T-=1
    n,a,b=map(int,input().split())
    print((n-1)*a//b+1)

上一题