Codeforces Round #723 (Div. 2)B. I Hate 1111

简介: DescriptionYou are given an integer x. Can you make x by summing up some number of 11,111,1111,11111,…? (You can use any number among them any number of times).For instance,33=11+11+11144=111+11+11+11

Description


You are given an integer x. Can you make x by summing up some number of 11,111,1111,11111,…? (You can use any number among them any number of times).


For instance,


33=11+11+11

144=111+11+11+11


Input


The first line of input contains a single integer t (1≤t≤10000) — the number of testcases.


The first and only line of each testcase contains a single integer x (1≤x≤109) — the number you have to make.


Output


For each testcase, you should output a single string. If you can make x, output “YES” (without quotes). Otherwise, output “NO”.


You can print each letter of “YES” and “NO” in any case (upper or lower).


Example


input


3
33
144
69


output


YES
YES
NO


Note


Ways to make 33 and 144 were presented in the statement. It can be proved that we can’t present 69 this way.

其实这个题目并不是很难,只需要稍微推导一下就好了

7e29e35eed4d48d7f67a8cf82e8e224d.png

可以看到左右的数(1111…这种)都可以由111和11构成

所以我们只需要枚举111的数量,并且查看剩下的数能不能由11构成就好啦


ll ans;
int main() {
  int T = read;
  while(T --) {
    ll x; cin >> x;
    int flag = 0;
    for(itn i=0;i*111<=x;i++){
      if((x - i*111) % 11 == 0) {
        flag = 1;
        break;
      }
    }
    if(flag) puts("yes");
    else puts("no");
  }
  return 0;
}



目录
相关文章
|
7月前
Codeforces Round #192 (Div. 2) (329A)C.Purification
Codeforces Round #192 (Div. 2) (329A)C.Purification
22 0
|
7月前
|
人工智能 算法 BI
Codeforces Round #179 (Div. 2)A、B、C、D
我们每次加进来的点相当于k,首先需要进行一个双重循环找到k点和所有点之间的最短路径;然后就以k点位判断节点更新之前的k-1个点,时间复杂度降到O(n^3),而暴力解法每次都要进行floyd,时间复杂度为O(n^4);相比之下前述解法考虑到了floyd算法的性质,更好了运用了算法的内质。
36 0
|
7月前
Codeforces Round #186 (Div. 2)A、B、C、D、E
Ilya得到了一个礼物,可以在删掉银行账户最后和倒数第二位的数字(账户有可能是负的),也可以不做任何处理。
22 0
|
9月前
|
机器学习/深度学习 人工智能
Codeforces Round 889 (Div. 2)
Codeforces Round 889 (Div. 2)
130 0
|
10月前
|
人工智能
Codeforces Round #786 (Div. 3)(A-D)
Codeforces Round #786 (Div. 3)(A-D)
54 0
Codeforces Round 799 (Div. 4)
Codeforces Round 799 (Div. 4)
95 0
Codeforces Round 640 (Div. 4)
Codeforces Round 640 (Div. 4)A~G
68 0
|
索引
Codeforces Round 817 (Div. 4)
Codeforces Round 817 (Div. 4)A~G题解
86 0
Codeforces Round #675 (Div. 2) A~D
Codeforces Round #675 (Div. 2) A~D
102 0
Equidistant Vertices-树型dp-Codeforces Round #734 (Div. 3)
Description A tree is an undirected connected graph without cycles. You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words,
119 0