http://acm.hdu.edu.cn/showproblem.php?pid=4952

Number Transformation

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

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
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
__int64 x,i,k,j;
int t=;
while(~scanf("%I64d%I64d",&x,&k))
{
if(x==&&k==)
break;
i=;
while(i<=k)
{
if(x%i!=)
{
j=x/i+;//求倍数。
if(j<=i)
{
x=k*j;
break;
}
x=j*i;
}
else
{
j=x/i;
if(j<=i)
{
x=k*j;
break;
}
}
i++;
}
printf("Case #%d: %I64d\n",t++,x);
}
return ;
}
 

HDU-4952 Number Transformation的更多相关文章

  1. hdu 4952 Number Transformation (找规律)

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

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

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

  3. hdu4952 Number Transformation (找规律)

    2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...

  4. HDU 1711 Number Sequence(数列)

    HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  5. HDU 1005 Number Sequence(数列)

    HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...

  6. bzoj 3858: Number Transformation 暴力

    3858: Number Transformation Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 82  Solved: 41[Submit][Sta ...

  7. CodeForces346 C. Number Transformation II

    C. Number Transformation II time limit per test 1 second memory limit per test 256 megabytes input s ...

  8. Codeforces 251C Number Transformation

    Number Transformation 我们能发现这个东西是以2 - k的lcm作为一个循环节, 然后bfs就好啦. #include<bits/stdc++.h> #define L ...

  9. HDU 1005 Number Sequence(数论)

    HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, ...

随机推荐

  1. Android Studio中常用插件及浅释

    博客: 安卓之家 微博: 追风917 CSDN: 蒋朋的家 简书: 追风917 博客园:追风917 插件可以来这个仓库查找:Android Studio Plugins 这里给出几个平时常用到的as插 ...

  2. LINQ 多条件写法

    源代码: string depAll = (ddl_dep1.SelectedValue == "") ? "" : ddl_dep1.SelectedValu ...

  3. Unix时间戳 和 NSDate 的转换

    一个时间戳字符串:NSString *timeStampStr =  @"1441602721"; 转换成时间     double unixTimeStamp          ...

  4. QuickSort 递归 分治

    QuickSort 参考<算法导论>,<C程序设计语言> #include<stdio.h> void swap(int v[], int i, int j); v ...

  5. TCP/IP状态转换图

  6. Windows phone 之Interaction.Triggers的使用

    两个步骤:1.添加以下两个程序集System.Windows.InteractivityMicrosoft.Expression.Interactions 2.添加xmlns:i="clr- ...

  7. LVS高可用集群

    高可用LVS 集群构建 在LVS集群当中Director的作用是很关键的,所以我们在生产环境中要保证其高可用. 高可用架构图: 1.通过 piranha搭建LVS高可用性集群 piranha是REDH ...

  8. namenode启动参数

    namenode启动参数:-Xmx153600m -Xms153600m -Xmn4096m -verbose:gc -Xloggc:$LOG_DIR/namenode.gc.log -XX:Erro ...

  9. [转]基于Spring + Spring MVC + Mybatis 高性能web构建

    http://blog.csdn.net/zoutongyuan/article/details/41379851/ 一直想写这篇文章,前段时间 痴迷于JavaScript.NodeJs.Angula ...

  10. 使用Autofac部署IIS6.0时未能加载文件或程序集“System.Core, Version=2.0.5.0...“

    错误信息 .net4.0项目中使用autofac这个IOC容器,在部署在win2003+iis6时出现以下错误. “/”应用程序中的服务器错误. --------------------------- ...