当前位置:网站首页>[Ji Zhong] July 13, 2022 3058 Torchbearer
[Ji Zhong] July 13, 2022 3058 Torchbearer
2022-07-18 22:57:00 【SSL_ YZJ】
Quick links
Preface
I haven't written a blog for a long time , Maybe a little rusty , If there is any mistake, please point it out in the comment area ~
Come to Jizhong , Play games every day , A little tired ,~~~~(>_<)~~~~.
Original title website
Title Description
The National Games is about to begin , Benben wants to be a torch bearer in Hunan , After layers of selection , Finally, we reached the last level , This level gives a positive integer n n n, Find the smallest positive integer m m m, bring n ∗ m n*m n∗m The decimal representation of contains only 1 1 1 and 0 0 0.
Format
Input format
Count one line at a time n n n.
Output format
Output one line , If there is any solution , The smallest output m m m, Otherwise output ‘no solution’.
Examples
sample input
12
sample output
925
Tips
n ≤ 100000 n\le100000 n≤100000
Their thinking
As the only one who depends on himself in two days A Missing topic , This problem is actually very challenging , It took me a long time to come up with a non positive solution , And there are many ways , I'm using metaphysics DFS( Breadth first search ) Algorithm .
It's actually enumeration 01 01 01 Every bit of the string , The number of digits is a little big , For some particular n n n, Their corresponding m m m It could be as much as ∞ \infin ∞ position ( To make fun of ).
Code
too · On · detailed · fine
#include<bits/stdc++.h> // The header file
#define integer unsigned long long // habit
using namespace std; // Namespace
integer n; // Definition n
queue<integer> q; // Define the queue
void bfs(integer first) {
// Definition bfs
while(!q.empty()) {
// Empty first
q.pop(); // eject
} // Emptying end
q.push(first); // Put the initial value in
while(!q.empty()) {
// It doesn't need to be !q.empry(), Because it's on the bottom return Exit function
integer m=q.front(); // Get first element
q.pop(); // eject
if(m%n==0) {
// eureka
cout<<m/n; // Output
return; // return
} // The judgment is over
q.push(m*10); // End the next one with 0 Put the string of into the queue
q.push(m*10+1); // End the next one with 1 Put the string of into the queue
} // while The loop ends
} // bfs end
int main() {
// The main function starts
cin>>n; // Input
bfs(1); // Start bfs, The initial value is 1
return 0; // end
} // End of main function
Such a detailed program is certainly not a positive solution ,The positive solution also needs high accuracy , Otherwise, you can't face things like 99999 So tricky n n n The data of .
边栏推荐
- Contrat de solidity pour l'achat à distance de marchandises
- Web development from entry to proficiency I (detailed)
- parker派克柱塞泵PV140R1K1T1NMMC
- Marvell88Q5192 switch调试记录(BSTA1000B平台)
- NASA首次拍到宇宙大爆炸后一瞬间的清晰照片
- Openstack related blog
- Dictionary tree leetcode seven hundred and forty-five
- Generate multiple databases at the same time based on multiple data sources and zero code, add, delete, modify and check restful API interfaces - mysql, PostgreSQL, Oracle, Microsoft SQL server multip
- 解题-->在线OJ(十六)
- [development of large e-commerce projects] cache distributed lock redisson concise & integration lock redisson resolve deadlock read / write lock lock lock semaphore-44
猜你喜欢

DeepMind最新114页报告《多智能体强化学习中的新兴易货贸易行为》

修改服务器密码

时序事件数据怎么处理?【慕尼黑工业大学博士论文】神经时序点过程(NTPP): 连续时间事件数据建模

NASA took the first clear picture of the moment after the big bang

Beijing Hualian BHG mall continues to make efforts, and BHG day leads the new upsurge of urban consumption

Byte 3 finally landed. Please keep this hot noodle Sutra "including free information"

leetcode--两个数组交集2

NASA首次拍到宇宙大爆炸后一瞬间的清晰照片

Jiulian technology development board is officially integrated into the openharmony backbone

Why is SaaS so important for enterprise digital transformation?
随机推荐
员工管理系统编写过程中摘要
Parker Parker plunger pump pv140r1k1t1nmmc
lun的概念
Leetcode48. rotate image
2022.7.15-----leetcode. five hundred and fifty-eight
The best way to practice Animation: cover transition
PMP practice once a day | don't get lost in the exam -7.16
NASA首次拍到宇宙大爆炸后一瞬间的清晰照片
Marvell88q5192 switch debugging record (bsta1000b platform)
企业数字化转型,为何SaaS模式如此重要?
3D point cloud course (IV) -- clustering and model fitting
Jiulian technology development board is officially integrated into the openharmony backbone
安全测试之逻辑漏洞
Honghu Wanlian Zhiyuan development board is officially integrated into the openharmony backbone
Configure SSH login for Huawei switches
5g NR notes
Transfer function
华为交换机配置SSH登录
Two stack implementation queue and two queue implementation stack (JS)
Beijing Hualian BHG mall continues to make efforts, and BHG day leads the new upsurge of urban consumption