fork(109) download
  1. #include <cstdio>
  2. #include <iostream>
  3. using std::string;
  4.  
  5. static struct IO {
  6. char tmp[1 << 10];
  7.  
  8. // fast input routines
  9. char cur;
  10.  
  11. //#define nextChar() (cur = getc_unlocked(stdin))
  12. //#define peekChar() (cur)
  13. inline char nextChar() { return cur = getc_unlocked(stdin); }
  14. inline char peekChar() { return cur; }
  15.  
  16. inline operator bool() { return peekChar(); }
  17. inline static bool isBlank(char c) { return (c < '-' && c); }
  18. inline bool skipBlanks() { while (isBlank(nextChar())); return peekChar() != 0; }
  19.  
  20. inline IO& operator >> (char & c) { c = nextChar(); return *this; }
  21.  
  22. inline IO& operator >> (char * buf) {
  23. if (skipBlanks()) {
  24. if (peekChar()) {
  25. *(buf++) = peekChar();
  26. while (!isBlank(nextChar())) *(buf++) = peekChar();
  27. } *(buf++) = 0; } return *this; }
  28.  
  29. inline IO& operator >> (string & s) {
  30. if (skipBlanks()) { s.clear(); s += peekChar();
  31. while (!isBlank(nextChar())) s += peekChar(); }
  32. return *this; }
  33.  
  34. inline IO& operator >> (double & d) { if ((*this) >> tmp) sscanf(tmp, "%lf", &d); return *this; }
  35.  
  36. #define defineInFor(intType) \
  37. inline IO& operator >>(intType & n) { \
  38. if (skipBlanks()) { \
  39. int sign = +1; \
  40. if (peekChar() == '-') { \
  41. sign = -1; \
  42. n = nextChar() - '0'; \
  43. } else \
  44. n = peekChar() - '0'; \
  45. while (!isBlank(nextChar())) { \
  46. n += n + (n << 3) + peekChar() - 48; \
  47. } \
  48. n *= sign; \
  49. } \
  50. return *this; \
  51. }
  52.  
  53. defineInFor(int)
  54. defineInFor(unsigned int)
  55. defineInFor(long long)
  56.  
  57. // fast output routines
  58.  
  59. //#define putChar(c) putc_unlocked((c), stdout)
  60. inline void putChar(char c) { putc_unlocked(c, stdout); }
  61. inline IO& operator << (char c) { putChar(c); return *this; }
  62. inline IO& operator << (const char * s) { while (*s) putChar(*s++); return *this; }
  63.  
  64. inline IO& operator << (const string & s) { for (int i = 0; i < (int)s.size(); ++i) putChar(s[i]); return *this; }
  65.  
  66. char * toString(double d) { sprintf(tmp, "%lf%c", d, '\0'); return tmp; }
  67. inline IO& operator << (double d) { return (*this) << toString(d); }
  68.  
  69.  
  70. #define defineOutFor(intType) \
  71. inline char * toString(intType n) { \
  72. char * p = (tmp + 30); \
  73. if (n) { \
  74. bool isNeg = 0; \
  75. if (n < 0) isNeg = 1, n = -n; \
  76. while (n) \
  77. *--p = (n % 10) + '0', n /= 10; \
  78. if (isNeg) *--p = '-'; \
  79. } else *--p = '0'; \
  80. return p; \
  81. } \
  82. inline IO& operator << (intType n) { return (*this) << toString(n); }
  83.  
  84. defineOutFor(int)
  85. defineOutFor(long long)
  86.  
  87. #define endl ('\n')
  88. #define cout __io__
  89. #define cin __io__
  90. } __io__;
  91.  
  92. int main()
  93. {
  94. int N, K, ans = 0;
  95.  
  96. for (cin >> N >> K; N--;)
  97. {
  98. register int a;
  99. cin >> a;
  100. if (a % K == 0)
  101. ans++;
  102. }
  103.  
  104. cout << ans << endl;
  105.  
  106. return 0;
  107. }
  108.  
Success #stdin #stdout 0s 4060KB
stdin
2013
Mukel
Hello
There
stdout
2013
Mukel4026