fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. long long n, a, sum=0;
  5. cin >> n;
  6. a = (n - (n % 9)) / 9 -1* (n % 9 == 0);
  7. for (long long i=1; i <=a; i++)
  8. sum +=i * 9;
  9. cout << sum;
  10. return 0;
  11. }
  12.  
  13.  
  14.  
Success #stdin #stdout 0s 5324KB
stdin
20
stdout
27