#45524: 用sqrt更省時間


1121228@stu.wghs.tp.edu.tw (你知道我是誰嗎!!??)


 

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a, b, sum;
    while(cin >> a >> b && a!=0 && b!=0){
        sum = 0;
        for(int i=int(sqrt(a)); i<=sqrt(b); i++){   // 用sqrt可以省時間
            if(i*i>=a){
                sum++;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

#45641: Re: 用sqrt更省時間


1121232@stu.wghs.tp.edu.tw (Ian911436)