fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. // your code goes here
  5. int n,j,i,g,x,B,b,d=0,z=0,cnt=0;
  6. cin>>n;
  7. for(i=1;i<=n;i++){
  8. j=i;
  9. b=j%10;
  10. while(j>0){
  11. g=j%10;
  12. j=j/10;
  13. if(b!=g) break;
  14. if(b==g&&j==0) cnt++;
  15. // x++;
  16. // if(x=1) B=B+g;
  17. // if(g!=B) d++;
  18. }
  19. //if(d=0) z++;
  20. }
  21. cout<<cnt;
  22. return 0;
  23. }
Success #stdin #stdout 0s 5324KB
stdin
2025
stdout
28