Number Transformation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 418    Accepted Submission(s): 201

Problem Description
   Teacher Mai has an integer x.
   He does the following operations k times. In the i-th operation, x becomes the least integer no less than x, which is the multiple of i.
   He wants to know what is the number x now.
 
Input
   There are multiple test cases, terminated by a line "0 0".
   For each test case, the only one line contains two integers x,k(1<=x<=10^10, 1<=k<=10^10).
 
Output
   For each test case, output one line "Case #k: x", where k is the case number counting from 1.
 
Sample Input
2520 10
2520 20
0 0
 
Sample Output
Case #1: 2520
Case #2: 2600
 
Source
 
Recommend
hujie
 
 
必须强调,不会的题一定不要偷懒,打表!!!!!!!!!!!!!!
 
 #include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map> #define N 1505
#define M 15
#define mod 1000000007
#define mod2 100000000
#define ll long long
#define maxi(a,b) (a)>(b)? (a) : (b)
#define mini(a,b) (a)<(b)? (a) : (b) using namespace std; ll x,k,i,tmp;
int cnt;
/*
void ini()
{
int i,k,j;
for(i=1;i<=15;i++){
for(k=1;k<=15;k++){
int x=i;
for(j=1;j<=k;j++){
while(x%j!=0){
x++;
}
}
printf(" i=%d k=%d x=%d\n",i,k,x);
}
}
}*/ int main()
{
//ini();
//freopen("data.in","r",stdin);
//scanf("%d",&T);
//for(int cnt=1;cnt<=T;cnt++)
//while(T--)
cnt=;
while(scanf("%I64d%I64d",&x,&k)!=EOF)
{
if(x== && k==) break;
printf("Case #%d: ",cnt);cnt++;
tmp=-;
for(i=;i<=k;i++){
if(x%i!=){
x=(x/i+)*i; }
if(x%i== && (x/i)==i-){
//printf(" i=%I64d i-1=%I64d x=%I64d\n",i,x/(i),x);
tmp=x/i;
break;
}
}
if(tmp==-){
printf("%I64d\n",x);
}
else printf("%I64d\n",tmp*(k-i)+x);
} return ;
}

hdu 4952的更多相关文章

  1. hdu 4952 暴力

    http://acm.hdu.edu.cn/showproblem.php?pid=4952 给定x,k,i从1到k,每次a[i]要是i的倍数,并且a[i]大于等于a[i-1],x为a0 递推到下一个 ...

  2. HDU 4952 Poor Mitsui(贪心)

    HDU 4957 Poor Mitsui pid=4957" style="">题目链接 思路:利用相邻交换法去贪心就可以.注意容积为0的情况,这是个坑点 代码: ...

  3. hdu 4952 Number Transformation (找规律)

    题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值, ...

  4. HDU 4952 Number Transformation 多校8 机智数学

    哎.这个题想了好久,状态不对啊...一个大家都出的题..当时想到肯定是可以有什么规律来暴力,不用算到10的10次方 对于某个k,x.从1到k循环,每次求一个新的x,这个x要大于等于原x,并且要是i的倍 ...

  5. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  7. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  8. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  9. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. iOS(iPhone,iPad))开发(Objective-C)开发库常用库索引

    http://www.code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例  http://www.cocoacontrols.com/ 英文版本的lib收集  ht ...

  2. Bellman-Ford与SPFA

    一.Bellman-Ford Bellman-Ford 算法是一种用于计算带权有向图中单源最短路径(当然也可以是无向图).与Dijkstra相比的优点是,也适合存在负权的图. 若存在最短路(不含负环时 ...

  3. Gradle环境下导出Swagger为PDF

    更多精彩博文,欢迎访问我的个人博客 说明 我个人是一直使用Swagger作为接口文档的说明的.但是由于在一些情况下,接口文档说明需要以文件的形式交付出去,如果再重新写一份文档难免有些麻烦.于是在网上看 ...

  4. 关于jQuery中的$发生冲突及解决方案

    问题描述: 在Jquery库中,$是JQuery的别名,所有使用$的地方也都可以使用JQuery来替换,如$('#msg')等同于JQuery('#msg')的写法. 当引入多个js库后,其它的js库 ...

  5. iOS 面试集锦2

    4.写一个setter方法用于完成@property (nonatomic,retain)NSString *name,写一个setter方法用于完成@property(nonatomic,copy) ...

  6. Linux–varnish(一)

    简介 Varnish 是一款高性能且开源的反向代理服务器和 HTTP 加速器,其采用全新的软件体系机构,和现在的硬件体系紧密配合,与传统的 squid 相比,varnish 具有性能更高.速度更快.管 ...

  7. 【css】【动画】【转发】旋转动画

    <!DOCTYPE HTML> <html> <head>     <meta charset="utf-8">     <s ...

  8. PHP中文件锁与进程锁的使用区别

    php中文网的一篇文章,收为己用了.源地址: http://www.php.cn/php-weizijiaocheng-376853.html 本篇文章主要介绍了PHP 文件锁与进程锁的使用示例,小编 ...

  9. SVN 如何提交 SO 库文件

    今天提交代码时候发现,svn add 还是 svn st 均查看不到想要提交的 so 文件. 后来才知道原来是配置文件出了问题,把so文件的提交给屏蔽掉了. 修改步骤如下: 1.Ubuntu 系统,点 ...

  10. Python-约瑟夫环

    n个人(以编号0,1,2,3...n-1分别表示)围坐在一张圆桌周围.从编号为0的人开始报数1,数到m的那个人出列: 他的下一个人又从1开始报数,数到m的那个人又出列:依此规律重复下去,直到圆桌周围的 ...