题目:http://www.lydsy.com/JudgeOnline/problem.php?id=3858

题解:设第i个数为i*a;第i+1个数为(i+1)*b。则(i+1)*b>i*a;b>a-(a/(i+1));那么如果a<i+1;b的值就会不变

此时k*b就为所求;而由于a在不断的变小,a<i+1;在数值比较大的情况下就能实现
这么乱搞都行?!
代码:

 #include<cstdio>

 #include<cstdlib>

 #include<cmath>

 #include<cstring>

 #include<algorithm>

 #include<iostream>

 #include<vector>

 #include<map>

 #include<set>

 #include<queue>

 #include<string>

 #define inf 1000000000

 #define maxn 200000+5

 #define maxm 200000+5

 #define eps 1e-10

 #define ll long long

 #define pa pair<int,int>

 #define for0(i,n) for(int i=0;i<=(n);i++)

 #define for1(i,n) for(int i=1;i<=(n);i++)

 #define for2(i,x,y) for(int i=(x);i<=(y);i++)

 #define for3(i,x,y) for(int i=(x);i>=(y);i--)

 #define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)

 #define for5(n,m) for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)

 #define mod 1000000007

 using namespace std;

 inline int read()

 {

     int x=,f=;char ch=getchar();

     while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}

     while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}

     return x*f;

 }

 int main()

 {

     freopen("input.txt","r",stdin);

     freopen("output.txt","w",stdout);
ll n,m;int cs=; while(scanf("%lld%lld",&n,&m)&&(n||m))
{
ll i,j;
for(i=;i<=m;i++)
{
j=n/i+(n%i>);
if(j<i+)break;
n=j*i;
}
if(i<=m)n=j*m;
printf("Case #%d: %lld\n",++cs,n);
} return ; }

BZOJ3858: Number Transformation的更多相关文章

  1. hdu4952 Number Transformation (找规律)

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

  2. bzoj 3858: Number Transformation 暴力

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

  3. HDU-4952 Number Transformation

    http://acm.hdu.edu.cn/showproblem.php?pid=4952 Number Transformation Time Limit: 2000/1000 MS (Java/ ...

  4. CodeForces346 C. Number Transformation II

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

  5. Codeforces 251C Number Transformation

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

  6. LightOJ 1141 Number Transformation

    Number Transformation In this problem, you are given an integer number s. You can transform any inte ...

  7. CodeForces 346C Number Transformation II

    Number Transformation II 题解: 对于操作2来说, a - a % x[i] 就会到左边离a最近的x[i]的倍数. 也就是说 [ k * x[i] + 1,  (k+1)* x ...

  8. Number Transformation

    Description In this problem, you are given a pair of integers A and B. You can transform any integer ...

  9. G - Number Transformation BFS

    In this problem, you are given an integer number s. You can transform any integer number A to anothe ...

随机推荐

  1. 百度地图API使用

    1.引用js脚本 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&am ...

  2. Sql例子Sp_ExecuteSql 带参数

    Declare @i int, @projectCount int ) --参数 ) ) ) ) ) ) --循环变量起始 --得到所有的项目 select @projectCount = count ...

  3. tomcat内存溢出,设置

    tomcat/bin/catalina.bat里找到echo Using CATALINA_BASE:   "%CATALINA_BASE%" ,在上方设置:    set JAV ...

  4. 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。

    // test14.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ...

  5. HTML教程XHTML教程:HTML标记嵌套使用技巧

    网页制作Webjx文章简介:WEB标准-HTML元素嵌套. 先来看以下这样一段代码: <ul>    <li><h4><a href="" ...

  6. 剑指offer--面试题19

    题目:求二叉树镜像 根据作者思路,自己所写代码如下: void BinaryTreeMirror(BinaryTreeNode* pRoot) { if(pRoot == NULL) return; ...

  7. FolderBrowserDialog 成员

    http://msdn.microsoft.com/zh-cn/library/system.windows.forms.folderbrowserdialog_members(v=vs.80).as ...

  8. boost序列化

    #include <iostream> #include <boost/serialization/serialization.hpp> #include <boost/ ...

  9. sgu 138

    自己猜测了一下  按比赛次数 从大到小排  然后类似于模拟 先排胜的场次 当只剩一场 将它定义为败 #include <cstdio> #include <cstdlib> # ...

  10. PHP 开发中的外围资源性能分析(二)

    暂且不讨论「PHP 是不是最好的编程语言」,本文我们将分别分析一下在 PHP 程序的后端外围资源和前端外围资源,它们对整个 PHP Web 应用体验的影响,这往往比语言本身大得多. 上一篇中我们分析了 ...