fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int N = 20;
  10.  
  11. int is_dev[N];
  12.  
  13. string* a = new string[N];
  14.  
  15. for (int i = 0; i < N; i ++)
  16. {
  17. for (int j = 0; j <= i; j ++)
  18. {
  19. a[i] += '1';
  20. }
  21. }
  22.  
  23. for (int i = 0; i < N; i ++)
  24. {
  25. cout << a[i] << endl;
  26. }
  27.  
  28. unsigned long long some_int;
  29. for (int i = 0; i < N; i ++)
  30. {
  31. istringstream buffer(a[i]);
  32. buffer >> some_int;
  33.  
  34. if (some_int % (i + 1) > 0)
  35. {
  36. is_dev[i] = 1;
  37. }
  38. else
  39. {
  40. is_dev[i] = 0;
  41. }
  42. }
  43.  
  44. for (int i = 0; i < N; i ++)
  45. {
  46. cout << is_dev[i] << " ";
  47. }
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
11111111111
111111111111
1111111111111
11111111111111
111111111111111
1111111111111111
11111111111111111
111111111111111111
1111111111111111111
11111111111111111111
0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1