找规律题qaq
当i>=sqrt(n)时,ceil(n/i)就不会变了,所以直接输出答案即可。
证明:portal
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 1000010
inline char gc(){
static char buf[1<<16],*S,*T;
if(S==T){T=(S=buf)+fread(buf,1,1<<16,stdin);if(T==S) return EOF;}
return *S++;
}
inline ll read(){
ll x=0,f=1;char ch=gc();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc();
return x*f;
}
int main(){
// freopen("a.in","r",stdin);
int tst=0;
while(1){
ll n=read(),m=read();if(!n&&!m) break;++tst;
for(ll i=2;i<=m;++i){
ll k=(n+i-1)/i;
if(k<=i){n=k*m;break;}
n=k*i;
}printf("Case #%d: %lld\n",tst,n);
}return 0;
}