bzoj3858Number Transformation*
题意:
给一个数n,对其进行k次变换,第i次变换是将当前的n变成大于等于n的最小的i的倍数。求k次变换后n为多少。n≤10^10,k≤10^10。
题解:
对n的变换可以表示成ceil(n/i)*i。有一个结论,当i第一次大于sqrt(当前的n)后,以后的i将永远大于sqrt(那时的n),且从这以后ceil(n/i)都相等。因此可以先暴力变换n,当i大于sqrt(当前n)后,求出ceil(n/i),直接乘k就是最后答案。
代码:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define inc(i,j,k) for(int i=j;i<=k;i++)
#define ll long long
using namespace std; inline ll read(){
char ch=getchar(); ll f=,x=;
while(ch<''||ch>''){if(ch=='-')f=-; ch=getchar();}
while(ch>=''&&ch<='')x=x*+ch-'',ch=getchar();
return f*x;
}
ll n,k; int t;
int main(){
while(){
n=read(); k=read(); if(n==&&k==)break; t++; int i;
for(i=;i<=k&&i<=(int)sqrt(n)+;i++)n=(n+i-)/i*i;
if(i==k+)printf("Case #%d: %lld\n",t,n);
else{n/=(i-); printf("Case #%d: %lld\n",t,n*k);}
}
return ;
}
20160812
bzoj3858Number Transformation*的更多相关文章
- (七)Transformation和action详解-Java&Python版Spark
Transformation和action详解 视频教程: 1.优酷 2.YouTube 什么是算子 算子是RDD中定义的函数,可以对RDD中的数据进行转换和操作. 算子分类: 具体: 1.Value ...
- 线性分式变换(linear fractional transformation)
线性分式变换(linear fractional transformation)的名称来源于其定义的形式:(ax+b)/(cx+d),其中分子分母是线性的,然后最外层是一个分式形式,所以叫做这个名字, ...
- OLE DB Command transformation 用法
OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used ...
- OpenCASCADE General Transformation
OpenCASCADE General Transformation eryar@163.com Abstract. OpenCASCADE provides a general transforma ...
- Informatica Lookup Transformation组件的Connect 与Unconnected类型用法
Informatica Lookup Transformation组件的Connect 与Unconnected类型用法及区别:下面是通一个Lookup在不同Mapping中的使用: 1. Conne ...
- Data Transformation / Learning with Counts
机器学习中离散特征的处理方法 Updated: August 25, 2016 Learning with counts is an efficient way to create a compact ...
- VS非web项目使用Transformation配置文件
Web项目中的Transformation使用起来非常方便,特别是本地与服务器情况不一致时调试下以及webdeploy的配合使用. 步骤: 1. 在项目中新建App.Debug.Config及App. ...
- SAP SLT (Landscape Transformation) 企业定制培训
No. Item Remark 1 SAP SLT概述 SAP Landscape Transformation Overview 2 SAP SLT 安装与配置<1> for abap ...
- Scalaz(55)- scalaz-stream: fs2-基础介绍,fs2 stream transformation
fs2是scalaz-stream的最新版本,沿用了scalaz-stream被动式(pull model)数据流原理但采用了全新的实现方法.fs2比较scalaz-stream而言具备了:更精简的基 ...
随机推荐
- numpy.stack和numpy.concatenate的区别
在使用numpy进行矩阵运算的时候踩到的坑,原因是不能正确区分numpy.concatenate和numpy.stack在功能上的差异. 先说numpy.concatenate,直接看文档: nump ...
- The following packages will be SUPERCEDED by a higher-priority channel是什么意思?
参考资料: https://stackoverflow.com/questions/42015732/the-following-packages-will-be-superceded-by-a-hi ...
- Android开发学习笔记DDMS的使用
打开DDMS DDMS 的全称是Dalvik Debug Monitor Service,是 Android 开发环境中的Dalvik虚拟机调试监控服务. DDMS里面包含了:Device(设备) F ...
- selenium(9)- Xpath的详细使用
什么是Xpath 官方:XPath 是一门在 XML 文档中查找信息的语言.XPath 用于在 XML 文档中通过元素和属性进行导航 [XPath 使用路径表达式来选取 XML 文档中的节点或者节点集 ...
- WeChair项目Alpha冲刺(1/10)
团队项目进行情况 1.昨日进展 因为是Alpha冲刺第一天,所以昨日进展无 2.今日安排 前端:完成前端页面的首页html+css部分 后端:搭建好SpringBoot项目以及完成实体类代码的编 ...
- postman无法正常启动
想请教下各位大神,我电脑的postman打开之后就一直转,没法启动是怎么回事?重装了不同版本的也是同样的情况,重启电脑也没用...同样的安装包,在别的电脑上就能正常打开!有什么办法解决吗? 0 20 ...
- CentOS下安装python3环境及pypy环境
安装前基础环境 1. win7虚拟机CentOS7.6系统 2. 网络环境通过NAT方式 3. 已经配置到yum仓库并系统自带有python2.7 安装前准备 1. python3.6.5源码包:ht ...
- I/O模式及select、 poll、 epoll
I/O多路复用技术 复用技术(multiplexing)并不是新技术而是一种设计思想,在通信和硬件设计中存在频分复用.时分复用.波分复用.码分复用等.在日常生活中复用的场景也非常多.从本质上来说,复用 ...
- 使用phpQuery进行采集数据,模拟curl提升访问速度
使用php采集网页数据一般有多种方法,有时候会使用正则去采集页面,但是当我们需要采集的页面大并且多的话,会严重的浪费我们的cpu,这时候我们可以使用phpQuer来进行采集,不知道phpQuery的童 ...
- Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available
连接elasticsearch已经成功,但是会报以下错误,字面意思是节点不可用这样 Exception in thread "main" NoNodeAvailableExcept ...