Advertisement
Guest User

Untitled

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