当前位置:网站首页>B. I Hate 1111 (记忆化搜索 数论
B. I Hate 1111 (记忆化搜索 数论
2022-06-13 07:18:00 【lcxdz】
添加链接描述
可以发现高位的1111都可以由11或者111组成 那么判断是否能被11整除 或者减去111再整除
记忆化mp存储是否可以组成
#include<bits/stdc++.h>
using namespace std;
map<int,bool>mp;
int dfs(int u){
if(mp.count(u))return mp[u];
int mx=0;
for(int i=11;i<=u;i=i*10+1){
mx=i;
}
for(int i=mx;i>=11;i=i/10){
//是往小判断
// cout<<i<<"\n";
if(dfs(u-i)){
mp[u]=1;
return mp[u];
}
}
return mp[u];
}
int main(){
int T;
cin>>T;
while(T--){
mp[0]=1;//第一个0是可以被整除的
int x;
cin>>x;
if(dfs(x))cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}
边栏推荐
- 理財產品連續幾天收益都是零是怎麼回事?
- 学习Mysql基础第一天
- 不间断管理设计
- 【硬记】脏读、不可重复读、幻读场景核心区别
- redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed
- An example of CSRF attack defense in web application scenarios
- Vsys of Isis (virtual system)
- Application of DS18B20 temperature sensor based on FPGA
- RT thread simulator lvgl control: slider control
- 2022-06-12:在N*N的正方形棋盤中,有N*N個棋子,那麼每個格子正好可以擁有一個棋子。 但是現在有些棋子聚集到一個格子上了,比如: 2 0 3 0 1 0 3 0 0 如上的二維數組代錶,一
猜你喜欢
redis-4. Redis' message subscription, pipeline, transaction, modules, bloom filter, and cache LRU
Table access among Oracle database users
How to write an amazing design document?
Raspberry school advanced development - "writing of IO port driver code" includes bus address, physical \u virtual address and bcm2835 chip manual knowledge
Reflection of C # Foundation
Evolution in the digital age
Simple understanding of basic language of C language
学习Mysql基础第一天
Host computer development (Architecture Design of firmware download software)
Ansible PlayBook的中清单变量优先级分析及清单变量如何分离总结
随机推荐
Tidb index optimization
RT thread simulator lvgl control: slider control
How to write an amazing design document?
【硬记】脏读、不可重复读、幻读场景核心区别
快速排序
[weak transient signal detection] matlab simulation of SVM detection method for weak transient signal under chaotic background
Can flush open a stock account? Is it safe?
C drawing table and sending mail function
Local file upload FTP or remote directory
How to use clion to debug a project built by the make tool
通过函数seaborn.cubehelix_palette生成顺序调色板
I always don't understand the high address and high position
Issues related to C # delegation and events
Detailed Mr Atlas of hip joint (Reprinted)
Introduction and use of dumping
Tidb implementation plan -- III
Lightning data import
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
Time field comparison time size in MySQL
C Advanced Programming - features