#help with a problem

14 messages · Page 1 of 1 (latest)

tepid beacon
#

struggling with this issue

https://codeforces.com/problemset/problem/110/A

this is my code

#include <iostream>
using namespace std;

int main() {

   long n, c = 0;
   bool lucky = true;
   cin >> n;
   
   for( ; n > 0 ; n /= 10) {
       if(n%10 == 4 || n%10 == 7) {
           c++;
       }
   }
       
   for( ; c > 0 ; c /= 10) {
       if(c%10 != 4 && c%10 != 7) {
           lucky = false;
       }
   }
   
   if(lucky)
       cout << "YES";
   else
       cout << "NO";
}
proud pierBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

tepid beacon
#

i dont get why my code keeps failing at test #7

#

chatgpt’s code works alright

#

even though both of our codes have got pretty much the same logic

rustic quest
#

!howto ask

proud pierBOT
# rustic quest !howto ask
How to Ask a Programming Question

Anyone can ask a question in our programming channels. Following the guide Writing The Perfect Question is recommended.

What to Post

State your problem clearly and provide all necessary details:

  • the relevant portion of your code, or all of it
  • the expected output
  • the actual output (or the full error)
    :trophy: Gold Standard: Minimal Reproducible Example
Where to Post

Provide the relevant code in the message, and format it nicely with a code block*. If it's too much for one message, you can upload it:

  • Compiler Explorer for most C/C++ snippets
  • OnlineGDB for interaction, debugging
    :no_entry: Do not post screenshots, let alone photos of your screen!
rustic quest
#

It’s kind of hilarious how similar this post is to the other one just posted

tepid beacon
#

i provided everything

#

the output is either yes or no

#

the program fails on one of the tests for some reason

rustic quest
rustic quest
#

What that person said