122A-Lucky number...Update test cases

Revision en1, by darshshounmay2000, 2020-05-24 21:09:45

Its to bring in concern of jury of codeforces that in that problem if a number is divisible completely by some lucky number then our output must be YES..Its given that maximum range of number is 1000..So numbers like 447*2<1000 or 477*2<1000 must give output as YES..But codeforces has no test cases as such..Codeforces is accepting solution which prints YES for lucky numbers and numbers that are divisible by 4 or 7 or 47 ..and remaining as NO..But logically numbers divisible not only by 4 or 7 or 47 but also by 74,447,477,474 as lucky numbers greater than that will have multiples greater than 1000..... So test cases such as 74*2,74*3,447*2 and so on must be there ... So a C+++ code for this could be like:

include

using namespace std;

int main() { int n; cin >> n; bool check = false; for (int i = n; i > 0; i /= 10) { if (i % 10 == 4 || i % 10 == 7) { check = true; } else { check = false; break; } } if (check) { cout << "YES"; return 0;

}
else if (n % 4 == 0 || n%7==0 || n%47==0||n%74==0||n%447==0||n%474==0||n%477==0)//AS MAX RANGE OF n is 1000

{ cout << "YES";

}
else {
    cout << "NO";
}

} This solution is accepted but divisibility upto 47 is also accepted which must not be.. So the test cases have to be changed

Tags #122a, #lucky numbers, #lucky numer bug, #122a bug

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English darshshounmay2000 2020-05-24 21:09:45 1467 Initial revision (published)