/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 4ms 340.0 KiB
#3 Time Exceeded ≥1000ms ≥572.0 KiB
#4 Time Exceeded ≥1100ms ≥568.0 KiB

Code

#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int n ;
long long ans ;
int i ;
int l ;
int r ;
int val ;
void solve() {
       
     
      cin >> n ;
      ans = 0 ;
      for(i = 1 ; i <= n ; i ++) {
        l = i ;
        // increse jab tak value n / i hai 
        // val = n / i 
        // n / k = val 
        // k = n / val ;
        val = n / i ;
        r = n / val ;
        ans += (val - 1) * 1LL * (r - l + 1) ;
        i = r ;
      }
      cout << ans << endl ;
}









int32_t main() {

    fastio();
    int t = 1;
    cin >> t;
    while (t--) solve();
}

Information

Submit By
Type
Submission
Problem
P1207 D2. GCD equal Absolute Value (Hard Version)
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 17:00:30
Judged At
2025-07-14 17:00:30
Judged By
Score
5
Total Time
≥1100ms
Peak Memory
≥572.0 KiB