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. DAG上的动态规划---嵌套矩形(模板题)

    一.DAG的介绍 Directed Acyclic Graph,简称DAG,即有向无环图,有向说明有方向,无环表示不能直接或间接的指向自己. 摘录:有向无环图的动态规划是学习动态规划的基础,很多问题都 ...

  2. 用cssText批量修改样式

    一般情况下我们用js设置元素对象的样式会使用这样的形式: var element= document.getElementById(“id”);element.style.width=”20px”;e ...

  3. linux_1

    注: 创建软连接: "ln -s xxx 路径1" 在路径1创建xxx的软连接 特点: 1.文件类型 l 2.相当于windows的快捷方式 创建硬链接: "ln xxx ...

  4. struts2基于注解的action

    使用注解来配置Action的最大好处就是可以实现零配置,但是事务都是有利有弊的,使用方便,维护起来就没那么方便了. 要使用注解方式,我们必须添加一个额外包:struts2-convention-plu ...

  5. java常考小程序

    private static void nineNineMulitTable(){ /** * 9*9乘法表 */ for (int i = 1,j = 1; j <= 9; i++) { Sy ...

  6. Redis数据库(二)

    1. Redis数据库持久化 redis提供了两种数据备份方式,一种是RDB,另外一种是AOF,以下将详细介绍这两种备份策略. 面试: 1.1  配置文件详解备份方式 [root@localhost ...

  7. 主DNS服务-正向解析

    环境 准备最少两台主机 一台当DNS服务器,一台当客户机 如:192.168.43.7这台主机当DNS服务器,192.168.43.6这台主机当客户机 安装DNS服务 yum install -y b ...

  8. 【css】清楚浏览器端缓存

    /css/common.css?version=1.0.7   在css链接后面加个参数版本号控制,刷新浏览器缓存

  9. shell相关指令介绍$*和$#以及$?和if [[ ! -z $1 ]]

    $#,脚本运行时后跟的参数个数 #! /bin/bash case "$#" in 0) printf "Enter a number: " read n=$R ...

  10. 【实验吧】guess next session&&FALSE&&NSCTF web200&&程序逻辑问题

      guess next session源码: <?php session_start(); if (isset ($_GET['password'])) { if ($_GET['passwo ...