1 / 5
Jun 2009

Hi! Can anyone help me with http://www.spoj.pl/problems/INTEST/ in C++.
I've passed it in 5.59 but i see there are submissions with exec time =~0.5.
Here is my code - what can i improve to get have at least 1.5 - 1.0 sec?

#include <stdio.h>
int main()
{
  int n, k, count = 0, next;
  scanf("%i %i", &n, &k);
  do{
    scanf("%i", &next);
    count += !(next % k);
  }while(--n);
  printf("%i", count);
  return 0;
}
  • created

    Jun '09
  • last reply

    Jun '09
  • 4

    replies

  • 103

    views

  • 3

    users

  • 1

    link

Nobody knows? I can not check some problems with large IO because of this...
Fast Multiplication for example. Can not read/write fast enough...

A runtime of 5 seconds here is plenty fast enough for other problems, including fast multiplication. I don't know how other people have such fast solutions here, probably by primitive reading of bytes from the file, but scanf and printf is fast enough to solve all problems on SPOJ.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 36 28d

Want to read more? Browse other topics in C and C++ or view latest topics.