#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); vector> ok(100001); for(int i=1; i<=1000; i++){ for(long long s=0; s<=i*100; s++){ long long now = s*1000/i; ok.at(now).push_back(i); } } int T; cin >> T; while(T--){ long long N; cin >> N; double S; cin >> S; long long answer = max(0LL,N-999),T = S*1000; N = min(999LL,N); for(auto n : ok.at(T)){ if(n > N) break; answer++; } cout << answer << endl; } }