当前位置:网站首页>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;
}
边栏推荐
- C#合并多个richtextbox内容时始终存在换行符的解决方法
- C drawing table and sending mail function
- RT thread simulator lvgl control: button button style
- FSM状态机
- Powerdispatcher reverse generation of Oracle data model
- Is it safe to open an account online in Hangzhou?
- C # using multithreading
- MySQL does not recommend setting the column default value to null. Why on earth is this
- Simple understanding of basic language of C language
- Why should two judgment expressions in if be written in two lines
猜你喜欢

基于ESP32CAM实现WebSocket服务器实时点灯

Tikv key performance parameters and optimization

Powerdispatcher reverse generation of Oracle data model

Tree list under winfrom treelist related

RT thread simulator lvgl control: slider control

Fe of mL: introduction to vintage curve /vintage analysis, calculation logic and detailed introduction to case application

RT thread simulator lvgl control: switch switch button control

基于FPGA的ds18b20温度传感器使用

学习Mysql基础第一天

C#合并多个richtextbox内容时始终存在换行符的解决方法
随机推荐
Fe of mL: introduction to vintage curve /vintage analysis, calculation logic and detailed introduction to case application
c#高级编程-特性篇
理財產品連續幾天收益都是零是怎麼回事?
Ticdc synchronization task
How to use clion to debug a project built by the make tool
Uploading and retrieving stored images in localstorage
Issues related to C # delegation and events
线程池中的 工作线程如何被回收
SDN基本概述
redis-4. Redis' message subscription, pipeline, transaction, modules, bloom filter, and cache LRU
What does my financial product mean in clearing?
No configure file found when compiling PHP from source code
Test development programmers, are you still confused? You can't define yourself as a yard farmer
Raspberry school advanced development - "writing of IO port driver code" includes bus address, physical \u virtual address and bcm2835 chip manual knowledge
C#合并多个richtextbox内容时始终存在换行符的解决方法
杭州证券开户是安全的吗?
Continuous management design
Local file upload FTP or remote directory
Ml: introduction to stability analysis of machine learning model and detailed introduction to common solutions
How worker threads in the thread pool are recycled