C. K-th Not Divisible by n
C. K-th Not Divisible by n
C.K-不可被n整除
time limit per test: 1 second
每次测试的时间限制:1秒
memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节
input. standard input
投入。标准输入
output: standard output
产出:标准产出
You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.
给你两个正整数n和k,打印不可被n整除的第k个正整数。
For example, ifn= 3, andk = 7, then all numbers that are not divisible by 3are: 1,2,4, 5,7, 8, 10, 11, 13… The 7-th number among
例如,IFN=3,k=7,那么所有不能被3整除的数字是:1,2,4,5,7,8,10,11,13.第7位
themis 10.
是10号。
Input
输入
The first line contains an integert(1≤t≤1000)- the number of test cases in the input. Next, t test cases are given, one per line.
第一行包含一个整数(1≤t≤1000)–输入中的测试用例数。接下来,给出t测试用例,每一行一个。
Each test case is two positive integersn(2 < n≤10)andk(1≤k≤109).
每个测试用例是两个正整数(2<n≤10)和k(1≤k≤109)。
Output
输出量
For each test case print the k-th positive integer that is not divisible by n.
对于每个测试用例,打印不可被n整除的k个正整数。
我已经找到了一个绝妙的证明方法,但是这里太窄了,写不下
数论
int main()
{int t;cin >> t;while (t--){int n, k,ans;cin >> n >> k;ans = k+((k-1)/(n-1));cout << ans<<endl;}return 0;
}
C. K-th Not Divisible by n相关推荐
- 038 Divisible Subsequences
given an integer n, represent the number we are gonna use later given an integer k, represents the l ...
- W - Pasha and Phone CodeForces - 595B (收益颇丰的数学题
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Ea ...
- Pasha and Phone
Description Pasha has recently bought a new phone jPager and started adding his friends' phone numbe ...
- Codeforces Round #330 (Div. 2) B. Pasha and Phone 容斥定理
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/pr ...
- python 整除的数组_计算和可被整除的所有子数组
在我学习面试的时候,我在GeeksForGeeks上找到了这个问题和解决方案,但不明白答案.在 上面说的是Let there be a subarray (i, j) whose sum is div ...
- Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting
B. Pasha and Phone Pasha has recently bought a new phone jPager and started adding his friends' phon ...
- CF385C Bear and Prime Numbers 数学
题意翻译 给你一串数列a.对于一个质数p,定义函数f(p)=a数列中能被p整除的数的个数.给出m组询问l,r,询问[l,r]区间内所有素数p的f(p)之和. 题目描述 Recently, the be ...
- Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting
B. Pasha and Phone Pasha has recently bought a new phone jPager and started adding his friends' phon ...
- 【Codeforces 1344 A】Hilbert‘s Hotel,哈希表,set维护
problem A. Hilbert's Hotel time limit per test1 second memory limit per test256 megabytes inputstand ...
- 陈景润定理对筛法理论的重要贡献
经过查证,在国际最新筛法专著的前言中,作者专门提及陈景润定理的现代意义,而我们国人却陈景润不理解.呜呼! 请看本文附件. 袁萌 陈启清 2月4日 附件:在最新筛法专著的前言中,专门提及陈景润定理的现代 ...
最新文章
- 2019年第一个工作日!
- java sdf.parse_用DateFormat的parse方法验证字符串是否是日期的问题
- jsp+ajax+servlet+sqlserver实现分页查询_SXT DAY063 分页
- c++中报错预处理器指令后有意外标记 - 应输入换行符
- [Gamma]Scrum Meeting#5
- 如何能让mediawiki实现共享
- prometheus变量_Prometheus 数据可视化
- nginx.conf文件配置后访问边下载 以及yaf框架使用中NGINX.conf文件配置
- 最后一块石头的重量II
- Nacos的服务注册表结构是怎样的?
- android代码生成excel,AndroidExcel
- 吸烟打电话检测、车道线识别等,2020中国华录杯·数据湖算法大赛火热进行中!...
- Apache会比路虎的应急效果更好
- find python3_Python3 rfind()方法
- 金融项目app业务及测试策略
- 固态硬盘多大合适 php,固态硬盘写入寿命是多久
- HTML点击图片实现跳转的两种方法
- 一文带你重新审视CAP理论与分布式系统设计
- Miniconda在服务器上的安装与使用
- 在sh_goods表中查询评分小于4的商品的不同分类id。
热门文章
- 【雷达信号处理】脉冲多普勒PD及其MATLAB实现
- TCP、UDP、IP头部结构
- SAP中看板拉料驱动MM物料移动的简单测试过程
- 在godot的canvas_item着色器中构建逆投影矩阵和逆视图矩阵
- FusionAccess桌面云介绍
- linux视频对话框,抖音对话框视频怎么做?如何在视频画面上添加对话气泡框?视频加对话气泡的方法...
- Nide.js安装配置
- 河北滹沱河流域上演喜鹊戏金雕
- Android源码分析-PackageManagerService(PMS)源码分析(三)- queryIntentActivities函数来查找activity
- 【华为OD机试真题 JAVA】机器人走迷宫