原文链接Problem - 1526B - Codeforces

B. I Hate 1111

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

For instance,

  • 33=11+11+1133=11+11+11
  • 144=111+11+11+11144=111+11+11+11

Input

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

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

Output

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

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

Example

input

Copy

3
33
144
69

output

Copy

YES
YES
NO

Note

Ways to make 3333 and 144144 were presented in the statement. It can be proved that we can't present 6969 this way.

---------------------------------------------------------------------------------------------------------------------------------

首先11 111可以表示出之后的1111 11111 111111....

也就是说,如果一个数满足条件 n==a*11+b*111

一般做法是,枚举b的个数,然后判断n-111*b是否能够整除11

# include<iostream>
# include<algorithm>
# include<iomanip>
# include<vector>
# include<map>
# include<math.h>
# include<cstring>
# include<queue>
using namespace std;
typedef long long int ll;int main()
{int t;cin>>t;while(t--){ll n;scanf("%lld",&n);int flag=0;for(ll i=0;i*111<=n;i++){if((n-i*111)%11==0){flag=1;cout<<"YES"<<'\n';break;}}if(!flag){cout<<"NO"<<'\n';}}return 0;
}

CF1526B I Hate 1111- Codeforces Round #723 (Div. 2)相关推荐

  1. Codeforces Round #723 (Div. 2)

    Codeforces Round #723 (Div. 2) 题号 题目 知识点 A Mean Inequality 签到 B I Hate 1111 思维 C Potions (Easy Versi ...

  2. Codeforces Round #723 (Div. 2) 个人题解

    上1400辣! 传送门:https://codeforces.com/contest/1526 A. Mean Inequality 题意 给一个长度为偶数的数组,你需要重排这个数组,使得任意一个数不 ...

  3. Codeforces Round #723 Div. 2个人代码

    Codeforces Round #723 Div. 2个人代码 写出来四题,开心QWQ A. Mean Inequality 题意:给一个数n,然后给2*n个数,让我们构造一个数列满足数列中任意一项 ...

  4. Codeforces Round #723 (Div. 2) D. Kill Anton 线段树 + 暴力

    传送门 文章目录 题意: 思路: 题意: 给你一个只有ANTOANTOANTO四个字母的字符串,你每次可以交换相邻两个,花费为111,让后让你打乱字符串,使得将打乱的字符串还原为原来的字符串的花费最小 ...

  5. Codeforces Round #723 (Div. 2)B. I Hate 1111(完全背包)

    problem B. I Hate 1111 time limit per test1 second memory limit per test256 megabytes inputstandard ...

  6. Codeforces Round #723 (Div. 2)补题

    水题,只需要将序列分成两部分即可,一部分是大的,一部分是小的. #include <cstdio> #include <iostream> #include <algor ...

  7. Codeforces Round #644 (Div. 3) E.Polygon

    Codeforces Round #644 (Div. 3) E.Polygon 题目链接 Polygon is not only the best platform for developing p ...

  8. CF922 CodeForces Round #461(Div.2)

    CF922 CodeForces Round #461(Div.2) 这场比赛很晚呀 果断滚去睡了 现在来做一下 A CF922 A 翻译: 一开始有一个初始版本的玩具 每次有两种操作: 放一个初始版 ...

  9. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  10. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

最新文章

  1. 现实工程中常用到的C语言函数总结(不断更新)
  2. linux 新增网络接口,为网络接口添加多IP - CentOS 7系统配置上的变化解析_Linux教程_Linux公社-Linux系统门户网站...
  3. 10.PL_SQL——PL_SQL中的复合数据类型之RECORDS
  4. WPF快速入门系列(6)——WPF资源和样式
  5. centos7 redis5.0以前版本 集群部署示例 - 第一篇
  6. Qt模仿游戏拖装备(换装备)
  7. [C++] - 单例模式 释放资源 析构函数的应用
  8. 【编程珠玑】第五章 编程小事
  9. mysql之 percona-xtrabackup 2.4.7安装(热备工具)
  10. Vue:打印组件PrintPage
  11. AVOD--avod/core/format_checker.py代码理解
  12. 知识驱动的主动式开放域对话系统 by 车万翔 2020/4/11
  13. 语音识别之wave文件(*.wav)格式、PCM数据格式介绍
  14. 计算机蓝牙传输,怎么使用电脑蓝牙 电脑蓝牙传输文件步骤【步骤教程】
  15. 计算机二级python易错选择题汇总
  16. 联想拯救者y7000电池耗电快_联想拯救者Y7000电池不充电,是因为电池有保护的
  17. 一个域名引发的血案……
  18. 用 python 写了一个日记本
  19. 骨传导耳机有什么优缺点,骨传导耳机好用吗
  20. 超级账本Hyperledger Fabric的使用

热门文章

  1. OpenFire源码学习之五:用户登录
  2. OpenCASCADE BRep vs. OpenNURBS BRep
  3. 抓取中国银行汇率函数 2008年12月29日
  4. 对于iphone X 兼容性处理的css适配方法和js适配方法
  5. 2、vRealize Operations Manager 安装
  6. 什么是锚点?锚点的用法
  7. SpringBoot向Mysql中插入数据报错:org.springframework.dao.InvalidDataAccessResourceUsageException: error perfo
  8. CTGU-2023春-MySQL数据库实验2_5-查询23-25
  9. 广义表的广度(长度)和深度的计算
  10. Oracle里面constraint说明