problem

B. I Hate 1111
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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
inputCopy
3
33
144
69
outputCopy
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.

solution

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int v[5] = {0,11,111,1111,11111};
int f[maxn];
int main(){int T;  cin>>T;while(T--){int x;  cin>>x;if(x>5000){cout<<"YES\n"; continue;}memset(f,0,sizeof(f));for(int i = 1; i <= 4; i++){for(int j = v[i]; j <= x; j++){f[j] = max(f[j], f[j-v[i]]+v[i]);}}if(f[x]==x)cout<<"YES\n";else cout<<"NO\n";}return 0;
}

Codeforces Round #723 (Div. 2)B. I Hate 1111(完全背包)相关推荐

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

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

  2. Codeforces Round #723 (Div. 2)

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

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

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

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

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

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

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

  6. Codeforces Round #506 (Div. 3)

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

  7. 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 ...

  8. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  9. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

最新文章

  1. 智能网联汽车高精地图白皮书(2020)
  2. Python3.5源码分析-内存管理
  3. c 语言三种正规循环,C语言复习题库
  4. vb 设置打印机 任意尺寸_打印照片怎么设置尺寸
  5. [zz]一份非常内行的Linux LVM HOWTO
  6. DNS解析与Bind的使用(2)
  7. 数据仓库分层和元数据管理
  8. 学会这十九招就会成为股市高手
  9. 跨域问题解决(我只是搬运工)
  10. toolchain安装教程支持_toolchain
  11. Communication(Floyed+并查集 || Trajan)
  12. 不同操作系统图片显示发生颠倒,linux ubuntu win7 win10
  13. 蓝桥杯科学素养题(2020年12月-2021年12月)
  14. 制作京东首页右侧固定层练习
  15. Audacity之清浊音频谱分析
  16. 计算机组成原理(7)指令系统——偏移寻址、堆栈寻址、CISC和RISC
  17. 西门子PLC1200-组态王跟Access数据库--⑪查询数据库
  18. 挂科违纪,武汉大学清退92名外国留学生!
  19. Mac下的终端(Terminal)简介
  20. 网络钢琴课内容建议征集

热门文章

  1. 深度学习实战 Tricks —— 梯度消失与梯度爆炸(gradient exploding)
  2. 从切比雪夫不等式到大数定理
  3. 随机事件、随机变量、概率、概率密度函数
  4. 【学习 OpenCV】—— Mat setTo/convertTo/copyTo
  5. 强悍的 vim —— 处理大小写转换
  6. 机器学习基础(二十)—— 数学语言与 Python 代码
  7. C++设计模式——从多态到观察者模式到MVC架构
  8. springboot 控制台输出错误信息_SpringBoot 三招组合拳,手把手教你打出优雅的后端接口...
  9. delphi 获取数组长度_Java中的数组(基础篇六)
  10. python能做什么工作-Python学完工作不好找?看看数据分析可视化都可以做什么