Menu
Coddy logo textTech

Winter number

Lesson 26 of 32 in Coddy's Coding Problems course.

challenge icon

Challenge

Hard

We call a number a winter number in two cases:

  • if it's a palindrome (reads the same backward or forward)
  • is divisible by all of its digits

For ex. 
505 and 1331 are winter numbers. They are both palindromes.
12 is a winter number because it's divided by both 1 and 2.
*notice that a non-palindromic number containing zero cannot be winter number because division with zero is not allowed*\

 

Write a program that gets in the first line a number N. In the next N rows you're given N natural numbers. For every number output if it's a winter number. Output "YES" if it's a winter number, and "NO", otherwise.

 

Input
2
505 1331

Output
YES YES

Input
3
12 9 340

Output
YES YES NO

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
}

All lessons in Coding Problems