Negigent Norbert Gym - 102680E
https://vjudge.net/problem/Gym-102680E/origin
https://vjudge.net/contest/396206#problem/E
Naughty Negligent Norbert has been given a notoriously repetitive responsibility: answering the clarification requests for a programming competition! Norbert realizes that since all the questions are perfectly unambiguous, he doesn't really have to do his job, and the only reason he is responding to requests at all is so he can get service hours. The savvy programmers, however, have implemented a system to prevent Norbert from simply giving the same answer to all clarification requests.
Having seen the source code for the competition, Norbert knows that he will lose all his service hours for not doing his job correctly if any two of his responses are identical. Negligent Norbert decides that for each of his TT competitions, he will respond to the qq clarification requests using as few characters as possible. Also, because Norbert is very diverse and speaks many languages, he will answer all questions in a given competition using a language with nn characters. What is the fewest number of keystrokes Norbert can type in each competition to still get his service hours?
Each response must have at least 1 character, and responses do not necessarily all have to be the same length. Norbert will click the submit button with his mouse instead of pressing the return key, so the total number of keystrokes is the sum of the lengths of each response.
Input
The first line will contain an integer TT. TT lines follow, each containing two space-separated integers, qq and nn, the number of clarification requests and the number of characters in the language for the current competition.
1≤T≤1001≤T≤100
1≤q≤10111≤q≤1011
2≤n≤1052≤n≤105
Output
Output TT lines, each containing a single integer representing the number of characters in all of Norbert's responses for a competition.
Example
3
7 3
5 26
14 3
11
5
27
Note
For the first test case, Norbert is using a language with 3 characters, Norbert could answer, for example, AC, CA, A, BC, C, AA, and B, for a total character count of 2+2+1+2+1+2+1 = 11.
For the second test case, Norbert could answer each of the five clarification requests with a different character, using a total of 5 characters. So we output 5 on a new line.
For the third test case, Norbert will need to use all of the one-letter and two-letter words, and two more three-letter words, for a total of 27 characters.
Sponsor
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define debug(x) cout<<"debug:"<<#x<<" = "<<x<<endl; #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
//const int maxn=1e5+10;
const int maxn = 5010;
//const int maxm=100+10;
const int N=1e6+10;
const int mod=1e9+7; int main()
{
int T = 0;
cin >> T;
while(T--)
{
ll request;
ll ch_L;
cin >> request >> ch_L;
ll l = 1;
ll tot = 0;
while(request > 0)
{
ll p = pow(ch_L, l);
ll min = p < request ? p : request;
tot += l * min;
request -= min;
l += 1;
}
cout << tot <<endl; }
}
Negigent Norbert Gym - 102680E的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
- 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)
Gym Class Accepts: 849 Submissions: 4247 Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65 ...
随机推荐
- 一个加速github的简单方法
除了使用梯子外,我们可以在本地host文件里添加ip来使之更为稳定: Windows用户在C:\Windows\System32\drivers\etc下的hosts文件里的底部添加如下内容: # G ...
- 第二次阶段性OOP题目集总结性Blog
前言: 基础题目训练说明 第一次基础题目有两道,题量较少,通过对之前题目的进一步扩展,考察知识点主要是1.类的封装.继承.多态2.抽象类3.接口.题目主要考查了学生对代码结构和可扩展性优化的能力.难度 ...
- Manim实现旋转变色特效
在数学动画的世界里,旋转与变色特效无疑是最能吸引观众眼球的元素之一. 今天,就让我们一起探索如何使用Manim框架来实现自定义的旋转变色特效吧! 1. 实现原理 Manim的动画魔法源于Animati ...
- Jenkins自动化部署-----持续交付
前言: 感谢之前带领过我的leader,让我能够知道什么是好的开发方法. 在很早之前就接触过敏捷开发.什么是敏捷开发,简单来说就是让软件可靠地,快速地发布出来的一种开发方法和技巧. 而敏捷开发中有许多 ...
- 乒乓球测距(K210)
测距 说明 识别的物体是乒乓球(规格应该是统一的吧), 硬件是K210,测距的函数经过拟合,在50cm范围内是准确的 如果使用起来不准确,可以打印代码中的LM, 然后去测数据,自己再拟合一个函数,代替 ...
- 「Note」数据结构方向 - 可持久化数据结构
1. 可持久化线段树 1.1. 简介 可持久化线段树一般用于解决区间第 \(k\) 小值的询问. 首先考虑简化过的问题,区间 \(\left[1,r\right]\) 的第 \(k\) 小值. 考虑用 ...
- 你应该懂的AI 大模型(五)之 LangChain 之 LCEL
本文 对<LangChain>一文中的 Chain 与 LCEL 部分的示例进行详细的展示. 先回顾下 在LangChain框架中,Chain(链) 和 LCEL(LangChain Ex ...
- bigdecimal去除末尾多余的0 ,stripTrailingZeros()科学计数法解决
BigDecimal是处理高精度的浮点数运算的常用的一个类 当需要将BigDecimal中保存的浮点数值打印出来,特别是在页面上显示的时候,就有可能遇到预想之外的科学技术法表示的问题. 一般直接使用 ...
- BeatifulSoup
BeatifulSoup (1)介绍 Beautiful Soup是Python库,用于解析HTML和XML文档.它提供简单而强大的工具,帮助用户从网页中提取数据.通过查找元素.遍历文档树和处理编码问 ...
- ET框架运行(Mac环境)--客户端
1:环境 Mac电脑,安装.net cor2 2.2 ,JetBrains Rider编辑器,Unity环境(2018.4.28f1) 终端运行: dotnet --version 查看是否安装n ...