EP01-题目描述
设 ,已知 ,求 有几种取值。
EP02-思路概括
那么现在 是固定的,因此使得商为 的 的个数为 商 的个数 商 的个数。
这个就是答案。
考虑证明。
那么我们将原式改成 ,这是成立的,对吧?
然后两边同减 ,得到 。
因为 是固定的。因此对于不同的 , 的值一定不相同,所以 的值一定不相同,而 是固定的,因此只能改变 使得等式成立,那 的值肯定互不相同。 证明结束。 代码:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read(){
int x=0,y=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') y=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<3)+(x<<1)+(ch^48);
ch=getchar();
}
return x*y;
}
void output(int x){
if(x<0){
putchar('-');
x=abs(x);
}
if(x>9){
output(x/10);
}
putchar((x%10)|48);
}
int n,k,answer,t;
void work(){
n=read();
k=read();
if(k==0) output(1);
else output((n/k)-(n/(k+1)));
puts("");
}
signed main(){
// freopen("divsion.in","r",stdin);
// freopen("divsion.out","w",stdout);
t=read();
while(t--) work();
return 0;
}
//是你吗 头戴着花环 衔着最纯净的枝丫
//是你吧 撕下一缕霓裳 借我照亮 盒中之花
//是你吗 在某一天默默消失在春天的遥望
//可我呀 记得你的所有 我不会忘 我不会忘