为啥子退出不了循环

CF1967B1 Reverse Card (Easy Version)

huochairenzhishang @ 2024-08-10 18:10:13

#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 <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; }


by xiaotian85 @ 2024-08-10 18:12:59

希丰展?用MD


by lose_114514 @ 2024-08-10 18:39:09

break


|