Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int F[4];
  5. int L[10];
  6.  
  7. int rec(int L[], int N, int deg ) {
  8.     int Kath=N;
  9.     int Deg=0;
  10.     if (N==0)
  11.         return 0;
  12.     while (Kath>=10){
  13.         Kath=Kath%10 ;
  14.         Deg++;
  15.     }
  16.     Kath=(Kath/int(pow(10,Deg)))%10;
  17.    
  18.     if (Kath==0)
  19.         return rec(L, N%int(pow(10,Deg)), Deg);
  20.        
  21.     for (int i=0;i<10; i++){
  22.         if (i<Kath){
  23.             L[i]=L[i]+F[Deg]*(Kath)+pow(10,Deg);
  24.             //cout << L[i] << ' ';
  25.         }
  26.         else {
  27.             L[i]=L[i]+F[Deg]*(Kath);
  28.         //    cout << L[i] << ' ';
  29.         }
  30.     }
  31.     return rec(L, N%int(pow(10,Deg)),Deg);
  32. }  
  33. int main(){
  34.     ios_base::sync_with_stdio(false);
  35.     cin.tie(0);
  36.     int Deg;
  37.     int N;
  38.     F[0]=0;
  39.     F[1]=1;
  40.     F[2]=20;
  41.     F[3]=300;
  42.     cin>>N;
  43.     int deg;
  44.     for (int i=1; i<N; i++)
  45.         L[i]=0;
  46.    
  47.     rec(L, N, Deg);
  48.     for (int i=0; i<10; i++){
  49.         cout << L[i] << endl ;
  50.     }
  51.     return 0;
  52. }
  53. //?g
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement