Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int NumarCifre(int n,int c)
  6. {
  7. int cop=n;
  8. c=0;
  9. while (cop!=0)
  10. {
  11. cop/=10;
  12. c++;
  13. }
  14. return c;
  15. }
  16. int main()
  17. {
  18. long long n,b,r,cop,c=1,k,m=1,nr=1,i;
  19. cin>>n>>b>>r;
  20. cop=r;
  21. k=NumarCifre(r,c);
  22. if (k>n)
  23. {
  24. cout<<-1;
  25. return 0;
  26. }
  27. else if (k==n)
  28. {
  29. cout<<r;
  30. return 0;
  31. }
  32. else
  33. {
  34. for (i=2; i<=n; i++)
  35. m=(m*10)%b;
  36. if (m<=r)
  37. nr = r - m ;
  38. else
  39. nr=b-m+r;
  40. if (nr ==0)
  41. {
  42. cout << 1 ;
  43. for ( i=1 ; i<=n-1 ; i++ )
  44. cout<<0;
  45. }
  46. else
  47. {
  48. k=NumarCifre(nr,c);
  49. cout<<1;
  50. for ( i=1 ; i<=n-k-1 ; i++ )
  51. cout << 0 ;
  52. cout<<nr;
  53. }
  54.  
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement