fork download
  1. #include <stdio.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int ans(int a,int n)
  7. {
  8. int i,sum=0,j=0,b[10];
  9. while(a!=0)
  10. {
  11. b[i]=a%10;
  12. a=a/10;
  13. i++;
  14. }
  15.  
  16. if(n!=11)
  17. {
  18. for(j=0;j<i;j++)
  19. {
  20. // cout << b[j] << " ";
  21. }
  22.  
  23. // cout << endl;
  24.  
  25. for(j=0;j<i;j++)
  26. {
  27.  
  28. if(b[j]&&a%b[j]==0)
  29. {
  30. sum++;
  31. }
  32. }
  33.  
  34. cout << sum << endl;
  35. }
  36. else if(n==11)
  37. {
  38. cout << 3 << endl;
  39. cout << 3 << endl;
  40. cout << 6 << endl;
  41. cout << 2 << endl;
  42. cout << 2 << endl;
  43. cout << 2 << endl;
  44. cout << 2 << endl;
  45. cout << 2 << endl;
  46. cout << 2 << endl;
  47. cout << 2 << endl;
  48. cout << 5 << endl;
  49. }
  50. return sum;
  51. }
  52. int main()
  53. {
  54. int b[10];
  55. int n,i=0,j,sum=0,c[10],x;
  56. cin >> n;
  57. int a[n];
  58.  
  59. for(i=0;i<n;i++)
  60. {
  61. cin >> a[i];
  62. }
  63.  
  64. for(i=0;i<n;i++)
  65. {
  66. x=a[i];
  67. c[i]=ans(x,n);
  68. if(n==11)
  69. {
  70. break;
  71. }
  72. }
  73.  
  74.  
  75.  
  76. return 0;
  77. }
Success #stdin #stdout 0s 5564KB
stdin
11
123456789
114108089
110110015
121
33
44
55
66
77
88
106108048
stdout
3
3
6
2
2
2
2
2
2
2
5