Advertisement
Centipede18

timsodep(thuannghich10)

Apr 4th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int tn(int n){
  6.     int r=0, cs=0;
  7.     int m=n;
  8.     while(n>0){
  9.         int t=n%10;
  10.         n/=10;
  11.         r=r*10+t;
  12.         cs+=t;
  13.     }
  14.     if(r==m && cs%10==0) return 1;
  15.     else return 0;
  16. }
  17.  
  18. main(){
  19.     int n, dem=0;
  20.     cin>>n;
  21.     for(int i=pow(10,n-1); i<pow(10,n); i++){
  22.         if(tn(i)) dem++;
  23.     }
  24.     cout<<dem;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement