Блог пользователя NeekT

Автор NeekT, история, 3 года назад, По-английски

Hello everybody.

If i try the input for test 7 (the number 4744000695826) on my machine i get the right output (YES) but when i submit the code, the test on the same output gives the wrong answer (NO).

Here's my submission for the problem in the title (GNU C11)

#include "stdio.h"

int main(){
  int i,c;
  long long int n;
  scanf("%lld",&n);
  
  for(c=0; n>0; n/=10){
    if((n%10 == 4)||(n%10==7))
      c++;
  }
  
  if((c==4)||(c==7))
    printf("YES");
  else
    printf("NO");
  return 0;
}

I tried to mess around with the % operator but if i use %ld i get the same exact outcome (the problem is solved correctly on my machine but the test run by the online judge gives a different answer), so i tried with %d and at the very least i got some consistency: both my machine and the online judge spit out a clear NO.

Could someone help me figure out what's wrong here?

Here's the link to my latest submission in case you want to check out the full test details https://codeforces.com/problemset/submission/110/105489826

Here's a screenshot for the test on my machine

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Hi, in your submit said,long int n. But, you should use long long int n in C11.

And, I have a advice. You can "CUSTOM TEST" in above menu bar in problem window. It is useful about this kind of problem. You and try and error.

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    Hi there, I have the same problem as NeekT, and I tried using your solution. However, for some reason my test case 7 is still giving wa. I am already using long long int and I am using c.