炸鸡块君的高中回忆 (数论 模拟
作者:互联网
添加链接描述
先模拟前(n-m)/(m-1)*2
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
#define int long long
typedef long long ll;
signed main(){
int T;
cin>>T;
while(T--){
int n,m;
ll res=0;
cin>>n>>m;
if(m==1&&n!=1){
puts("-1");
continue;
}
else if(m==1&&n==1){
puts("1");
continue;
}
if(n<=m){
puts("1");
}
else {
ll p=(n-m)/(m-1);
ll res=p*2;
ll now=p*(m-1);
n-=now;
while(n>0){
if(n<=m){
res++;
break;
}
n-=m-1;
res+=2;
}
// cout<<p<<endl;
cout<<res<<endl;
}
}
return 0;
}
标签:puts,高中,数论,res,ll,long,炸鸡块,int,else 来源: https://blog.csdn.net/Minelois/article/details/122677374