fork download
  1. #include <iostream>
  2. #define LL long long
  3. using namespace std;
  4.  
  5. LL N,res; int T;
  6.  
  7. int main(){
  8. cin >> T;
  9.  
  10. LL aux,f1,f2,l,i;
  11. while (T--){
  12. cin >> N;
  13.  
  14. res=0;
  15. f1=1,f2=1;
  16.  
  17. while (f2+f1<=N){
  18. l=-1;
  19. for (i=1; i*i<=N/f2 || (N-f2*i)/(f1*i)==l; i++) l=(N-f2*i)/(f1*i),res+=l;
  20. for (i=1; i<l; i++) res+=i*(N/(i*f1+f2)-N/((i+1)*f1+f2));
  21.  
  22. aux=f1+f2;
  23. f1=f2,f2=aux;
  24. }
  25.  
  26. for (i=1; i*i<=N || l==N/i; i++) res+=N/i,l=N/i;
  27. for (i=1; i<l; i++) res+=i*(N/i-N/(i+1));
  28. cout << res << "\n";
  29. }
  30. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty