NC236490. King of Gamers
描述
Little G is going to play 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.
输入描述
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)