BZOJ3858: Number Transformation
题目: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的值就会不变
这么乱搞都行?!
代码:
#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的更多相关文章
- hdu4952 Number Transformation (找规律)
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...
- bzoj 3858: Number Transformation 暴力
3858: Number Transformation Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 82 Solved: 41[Submit][Sta ...
- HDU-4952 Number Transformation
http://acm.hdu.edu.cn/showproblem.php?pid=4952 Number Transformation Time Limit: 2000/1000 MS (Java/ ...
- CodeForces346 C. Number Transformation II
C. Number Transformation II time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces 251C Number Transformation
Number Transformation 我们能发现这个东西是以2 - k的lcm作为一个循环节, 然后bfs就好啦. #include<bits/stdc++.h> #define L ...
- LightOJ 1141 Number Transformation
Number Transformation In this problem, you are given an integer number s. You can transform any inte ...
- CodeForces 346C Number Transformation II
Number Transformation II 题解: 对于操作2来说, a - a % x[i] 就会到左边离a最近的x[i]的倍数. 也就是说 [ k * x[i] + 1, (k+1)* x ...
- Number Transformation
Description In this problem, you are given a pair of integers A and B. You can transform any integer ...
- G - Number Transformation BFS
In this problem, you are given an integer number s. You can transform any integer number A to anothe ...
随机推荐
- java 获取获取字符串编码格式
public static String getEncoding(String str) { String encode = "GB2312"; try { if (str.equ ...
- cookieContainer应用
PublicSharedFunctionGetCookiesSetByPage(ByVal strUrl AsString,ByVal cookieToProvide AsString)AsIEnum ...
- 开启VMware Esxi的SSH远程登录
1.在服务器的配置页面中开启 按[F2],输入密码,进入配置页面,选择troubleshooting options,选择EnableSSH 即可. 2.在VMware Client中开启 进入:配置 ...
- ApplicationContext
参考网址: http://baike.baidu.com/link?url=IPzNiVScxSd6ijhDeCKKEuywPqisDeTfyYSQIPRZqLxy6onkPddfzyvcWQC6_M ...
- Java Notes
1.java是解释型语言.java虚拟机能实现一次编译多次运行. 2.JDK(java software Development kit 软件开发包),JRE(java Runtime Environ ...
- ubuntu下安装spark1.4.0
构建在hadoop2.6.0之上的 1.在官网下载spark-1.4.0-bin-hadoop2.6.tgz 2.解压到你想要放的文件夹里,tar zxvf spark-1.4.0-bin-hadoo ...
- poj 1730 Perfect Pth Powers
这个有2种方法. 一种是通过枚举p的值(p的范围是从1-32),这样不会超时,再就是注意下精度用1e-8就可以了,还有要注意负数的处理…… #include<iostream> #incl ...
- Android 注意在finish Activity之后也要停止正在运行的请求
如果在一个Activity里面启动了网络请求,而在这个网络请求还没返回结果的时候,如果Activity被结束了,则我们需要写如下代码作为防守: @Override public void onPost ...
- [2-sat]HDOJ3062 Party
中文题 题意略 学2-sat啦啦啦 2-sat就是 矛盾的 ($x.x’$不能同时取) m对人 相互也有限制条件 取出其中n个人 也有可能是把一件东西分成 取/不取 相矛盾的两种情况 (那就要拆 ...
- hdu1022 Train Problem I
http://acm.hdu.edu.cn/showproblem.php?pid=1022 #include<iostream> #include<stdio.h> #inc ...