Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.IO;
  8.  
  9. namespace ConsoleApplication3
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. StreamReader input = new StreamReader("input.txt");
  16. StreamWriter output = new StreamWriter("output.txt");
  17.  
  18. //string s = input.ReadLine();
  19. //string[] str = s.Split(' ');
  20. //int n = Convert.ToInt32(str[0]);
  21. //int r = Convert.ToInt32(str[1]);
  22.  
  23. //double x, y, z;
  24.  
  25. //for (int i = 0; i < n; i++)
  26. //{
  27. // s = input.ReadLine();
  28. // string [] st = s.Split(' ');
  29. // x = Convert.ToDouble(st[0]);
  30. // y = Convert.ToDouble(st[1]);
  31. // z = Convert.ToDouble(st[2]);
  32. // if (Math.Sqrt(x * x + y * y + z * z) <= r) output.WriteLine(x + " " + y + " " + z);
  33.  
  34. //}
  35.  
  36.  
  37. //string s = input.ReadLine();
  38. //int n = Convert.ToInt32(s);
  39. //int a = n;
  40. //int step = 0;
  41. //while (a % 10 == 0)
  42. //{
  43. // a = a / 10;
  44. // step++;
  45. //}
  46.  
  47. //if (n % 10 != 0 && n / 10 % 10 != 9) output.Write(n + 9);
  48. //else if (a % 10 == 1) output.Write((a / 10) * Math.Pow(10, step) + Math.Pow(10, step + 1));
  49. //else if (a % 10 == 2) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) );
  50. //else if (a % 10 == 3) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 1);
  51. //else if (a % 10 == 4) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 2);
  52. //else if (a % 10 == 5) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 3);
  53. //else if (a % 10 == 6) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 4);
  54. //else if (a % 10 == 7) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 5);
  55. //else if (a % 10 == 8) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 6);
  56. //else if (a % 10 == 9) output.Write((a / 10 + 1) * Math.Pow(10, step + 1) + Math.Pow(10, step) + 7);
  57. //else if (n / 10 % 10 == 9) output.Write(n + 18);
  58.  
  59.  
  60. //string s = input.ReadLine();
  61. //int n = Convert.ToInt32(s);
  62. //s = input.ReadLine();
  63. //string[] str = s.Split(' ');
  64. //int[] arr = new int[str.Length];
  65. //for (int i = 0; i < str.Length; i++) arr[i] = Convert.ToInt32(str[i]);
  66. //int sum1 = arr[0];
  67.  
  68. //int sum2 = 0;
  69. //for (int i = 1; i < arr.Length; i++)
  70. //{
  71. // sum2 += arr[i];
  72. //}
  73. //bool fl = false;
  74. //if (sum1 == sum2) output.Write(1);
  75. //else for (int i = 1; i < arr.Length; i++)
  76. // {
  77. // sum1 += arr[i];
  78. // sum2 -= arr[i];
  79. // if (sum1 > sum2) break;
  80. // if (sum1 == sum2) { output.Write(i + 1); fl = true; break; }
  81. // }
  82. //if (!fl) output.Write(-1);
  83.  
  84.  
  85. string s = input.ReadLine();
  86. string[] str = s.Split(' ');
  87. int n = Convert.ToInt32(str[0]);
  88. int m = Convert.ToInt32(str[1]);
  89. s = input.ReadLine();
  90. str = s.Split(' ');
  91. int[] arr = new int[str.Length];
  92. for (int i = 0; i < str.Length; i++) arr[i] = Convert.ToInt32(str[i]);
  93. int[] b = new int[m];
  94. for (int i = 0; i < m; i++)
  95. {
  96. string q = input.ReadLine();
  97. b[i] = Convert.ToInt32(q);
  98. }
  99.  
  100. //int[] res = new int[m];
  101. bool fl = false;
  102. for (int j = 0; j < m; j++)
  103. {
  104. for (int i = n - 1; i >= 0; i--)
  105. {
  106. if (b[j] > arr[i]) break;
  107. if (b[j] == arr[i]) { output.WriteLine(i + 1); fl = true; break; }
  108. }
  109. if (fl == false) output.WriteLine(0);
  110. fl = false;
  111. }
  112.  
  113.  
  114.  
  115. //string s = input.ReadLine();
  116. //string[] str = s.Split(' ');
  117. //int m = Convert.ToInt32(str[0]);
  118. //int p = Convert.ToInt32(str[1]);
  119.  
  120. //s = input.ReadLine();
  121. //str = s.Split(' ');
  122. //int a = Convert.ToInt32(str[0]);
  123. //int b = Convert.ToInt32(str[1]);
  124.  
  125. //s = input.ReadLine();
  126. //str = s.Split(' ');
  127. //int[] arr = new int[m];
  128. //for (int i = 0; i < str.Length; i++) arr[i] = Convert.ToInt32(str[i]);
  129.  
  130. //int res = 0;
  131. //int k;
  132. //while (a % p != 0) a++;
  133.  
  134. //if (a > b) output.Write(0);
  135. //else
  136. //{
  137. // int fl = 0;
  138. // while (a <= b)
  139. // {
  140. // k = a;
  141. // while (k > 0)
  142. // {
  143. // for (int i = 0; i < m; i++)
  144. // {
  145. // if (k % 10 == arr[i]) { fl = 1; break; }
  146. // }
  147. // if (fl == 0) break;
  148. // else { k = k / 10; }
  149. // fl = 0;
  150. // }
  151. // if (k <=0) { res++; }
  152. // a += p;
  153. // }
  154. //}
  155. //output.Write(res);
  156.  
  157.  
  158.  
  159. /////////////////////////////////////////////
  160. //string s = input.ReadLine();
  161. //string[] str = s.Split(' ');
  162. //int a = Convert.ToInt32(str[0]);
  163. //int b = Convert.ToInt32(str[1]);
  164. //double c = (b - a) / 3;
  165. //if (a == b) { if (a % 3 != 0) output.WriteLine(0); else output.WriteLine(1); }
  166. //else if (a > 0) output.WriteLine(Math.Truncate(c));
  167. //else if (a == 0) output.WriteLine(Math.Truncate(c) + 1);
  168. //else if (b == 0) output.WriteLine(Math.Truncate(c) + 1);
  169. //else if (b < 0) output.WriteLine(Math.Truncate(c) + 1);
  170.  
  171. //else output.WriteLine(Math.Truncate(c) + 1);
  172.  
  173.  
  174.  
  175. //string s = input.ReadLine();
  176. //int n = Convert.ToInt32(s);
  177. //bool pt = true;
  178. //int t = n - 1;
  179. //int min = 10, max= 100;
  180. //while (t > 0)
  181. //{
  182. // for (int i = 2; i < t; i++) if (t % i == 0) { pt = false; }
  183. // if (pt == true) { min = t; break; }
  184. // t--;
  185. //}
  186. //t = n + 1;
  187. //while (t < n*n + 2)
  188. //{
  189. // for (int i = 2; i < t; i++) if (t % i == 0) { pt = false; }
  190. // if (pt == true) { max = t; break; }
  191. // t++;
  192. //}
  193.  
  194. //if (max - n < n - min && min > 0) output.WriteLine(max);
  195. //else if (max - n > n - min && min > 0) output.WriteLine(min);
  196. //else if (min > 0) output.WriteLine(min);
  197. //else output.WriteLine(max);
  198.  
  199.  
  200.  
  201. //ulong n = Convert.ToUInt32(input.ReadLine());
  202. //ulong d = 1;
  203. //for (ulong i = n - 1; i > 0; i--) if (n % i == 0) { d = i; break; }
  204. //output.WriteLine(d + " " + (n - d));
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214. //int n = Convert.ToInt32(input.ReadLine());
  215. //string s = input.ReadLine();
  216. //int[] arr = new int[n];
  217.  
  218. //string[] str = s.Split(' ');
  219. //for (int i = 0; i < str.Length; i++)
  220. //{
  221. // arr[i] = Convert.ToInt32(str[i]);
  222. //}
  223. //output.WriteLine(n);
  224. //for (int i = 0; i < n; i++)
  225. //{ output.Write(arr[i] + " "); }
  226.  
  227.  
  228. input.Close();
  229. output.Close();
  230. }
  231.  
  232.  
  233. }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement