Advertisement
ErolKZ

Untitled

Nov 25th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. Prime Triangle
  2. Description
  3. We know that you love math, so we have prepared a very interesting task, that involves both geometry and prime numbers.
  4.  
  5. By a given N number, from which you need to generate a sequence of 1 to N inclusive. For every prime number in that sequence, you need to print out all the other numbers before it (and the number itself), whether they are prime or not
  6.  
  7. Note:
  8. For the purposes of this task (and against the laws of mathematics), the number 1 is considered as prime.
  9.  
  10. Example
  11. Let's say N=10
  12.  
  13. We have the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  14. The prime numbers are 1, 2, 3, 5, 7 - 5 prime numbers, so we prive 5 rows
  15. Each row contains all the numbers for 1 to PRIME_NUMBER
  16. Result:
  17.  
  18. 1
  19.  
  20. 1 2
  21.  
  22. 1 2 3
  23.  
  24. 1 2 3 4 5
  25.  
  26. 1 2 3 4 5 6 7
  27.  
  28. Lets make things simpler:
  29.  
  30. Print 0 if the numbers is not prime
  31. Print 1 if the number is prime
  32. Final result:
  33.  
  34. 1
  35.  
  36. 1 1
  37.  
  38. 1 1 1
  39.  
  40. 1 1 1 0 1
  41.  
  42. 1 1 1 0 1 0 1
  43.  
  44. Input
  45. Read from the standard input
  46. On the single line, find the number N
  47. The input data will always be valid and in the format described. There is no need to check it explicitly
  48. Output
  49. Print on the standard output
  50. The output should consist of several lines of digits each of which can be either 1 or 0
  51. Without any space between them
  52. Sample tests
  53. Input
  54. 10
  55. Output
  56. 1
  57. 11
  58. 111
  59. 11101
  60. 1110101
  61. Input
  62. 27
  63. Output
  64. 1
  65. 11
  66. 111
  67. 11101
  68. 1110101
  69. 11101010001
  70. 1110101000101
  71. 11101010001010001
  72. 1110101000101000101
  73. 11101010001010001010001
  74.  
  75.  
  76.  
  77. Word Anagrams
  78. You are given a word and a list of words. Your task is to check whether all the words from the list are anagrams of the word.
  79.  
  80. An anagram is a word formed by rearranging the letters of another word:
  81.  
  82. The following are anagrams of "anagram":
  83. "gramana", "aaagrnm", "margana", etc..
  84. The following are NOT anagrams of "anagram":
  85. "aanagram", "aaagram", "anagra", "anagrama", "yxy"
  86. Input
  87. Read from the standard input
  88.  
  89. On the first line, find W - the word to check against;
  90. On the second line, find N - the number of words in the list of words WORDS;
  91. On the next N lines, the words from WORDS;
  92. Output
  93. Print to the standard output
  94.  
  95. For each word from WORDS print either:
  96. "Yes", if the word is an anagram of W;
  97. "No", if the word is NOT an anagram of W;
  98. Sample tests
  99. Input
  100. anagram
  101. 6
  102. gramana
  103. aaagrnm
  104. anagra
  105. margana
  106. abc
  107. xy
  108. Output
  109. Yes
  110. Yes
  111. No
  112. Yes
  113. No
  114. No
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement