fork(1) download
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main()
  5. {
  6. long int t;
  7. scanf("%d",&t);
  8. while(t--)
  9. {
  10. int n,k,ans=0,temp;
  11. scanf("%d%d",&n,&k);
  12. for(int i=1;i<=k;i++)
  13. {
  14. temp=n%i;
  15. if(temp>ans)
  16. ans=temp;
  17. }
  18. printf("%d\n",ans);
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 2116KB
stdin
2
5 2
11 3
stdout
1
2