为啥子退出不了循环
查看原帖
为啥子退出不了循环
1272396
huochairenzhishang楼主2024/8/10 18:10
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 3;
const int M=1e9+7;
vector<ll> num(N);
vector<ll> sum(N);
ll max(ll x, ll y){
    return x > y ? x : y;
}
ll min(ll x, ll y){
    return x < y ? x : y;
}
bool cmp(int x, int y){
    return x > y;
}
ll lowbit(ll x){
    return x & -x;
}
ll gcd(ll a, ll b){
    ll r;
    while (b > 0)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
ll lcm(ll a, ll b){
    
    return a * b / gcd(a, b);
}
ll a[200006];
void solve(){
    ull n,m;cin>>n>>m;
    ull sum=0;
    for(ull i=1;i<=m;++i){
        sum+=(n+i)/(i*i);
    }
    cout<<sum-1<<'\n';
    return;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

#include #include <stdio.h> #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; const int N = 3; const int M=1e9+7; vector num(N); vector sum(N); ll max(ll x, ll y){ return x > y ? x : y; } ll min(ll x, ll y){ return x < y ? x : y; } bool cmp(int x, int y){ return x > y; } ll lowbit(ll x){ return x & -x; } ll gcd(ll a, ll b){ ll r; while (b > 0) { r = a % b; a = b; b = r; } return a; } ll lcm(ll a, ll b){

return a * b / gcd(a, b);

} ll a[200006]; void solve(){ ull n,m;cin>>n>>m; ull sum=0; for(ull i=1;i<=m;++i){ sum+=(n+i)/(i*i); } cout<<sum-1<<'\n'; return; } int main() { int t; cin >> t; while (t--) solve(); return 0; }

2024/8/10 18:10
加载中...