当前位置:网站首页>【PTA】整除光棍
【PTA】整除光棍
2022-04-23 20:20:00 【也许会吧】
题目
解题思路
模仿除法
1.先累加1,直到比除数大(此时可以除以除数了)
2.得到除以的结果和除以的余数,将除以的结果输出
3.向后移动,补位
4.重复2、3,直到2中余数为0时停止
ac代码
#include<iostream>
using namespace std;
int main() {
int n, k = 1, cnt = 1;
cin >> n;
while(k < n) {
k = k * 10 + 1;
cnt++;
}
while(1) {
if(k % n == 0) {
cout << k / n << cnt;
break;
} else {
cout << k / n;
k %= n;
k = k * 10 + 1;
cnt++;
}
}
return 0;
}
版权声明
本文为[也许会吧]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_55475680/article/details/124349800
边栏推荐
- R语言使用timeROC包计算存在竞争风险情况下的生存资料多时间AUC值、使用cox模型、并添加协变量、R语言使用timeROC包的plotAUCcurve函数可视化多时间生存资料的AUC曲线
- 16MySQL之DCL 中 COMMIT和ROllBACK
- 还在用 ListView?使用 AnimatedList 让列表元素动起来
- Record: call mapper to report null pointer Foreach > the usage of not removing repetition;
- LeetCode异或运算
- NC basic usage
- Mysql database backup scheme
- nc基础用法1
- DTMF dual tone multi frequency signal simulation demonstration system
- 论文写作 19: 会议论文与期刊论文的区别
猜你喜欢
Servlet learning notes
Numpy Index & slice & iteration
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
Computing the intersection of two planes in PCL point cloud processing (51)
网络通信基础(局域网、广域网、IP地址、端口号、协议、封装、分用)
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
程序设计语言基础(2)
MySQL advanced lock - overview of MySQL locks and classification of MySQL locks: global lock (data backup), table level lock (table shared read lock, table exclusive write lock, metadata lock and inte
How to protect ECs from hacker attacks?
After route link navigation, the sub page does not display the navigation style problem
随机推荐
DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS
Leetcode dynamic planning training camp (1-5 days)
Database query - course selection system
Is the wechat CICC wealth high-end zone safe? How to open an account for securities
The R language uses the timeroc package to calculate the multi time AUC value of survival data without competitive risk, and uses the confint function to calculate the confidence interval value of mul
Commit and ROLLBACK in DCL of 16mysql
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
AQS learning
SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
LeetCode动态规划训练营(1~5天)
[graph theory brush question-4] force deduction 778 Swimming in a rising pool
LeetCode异或运算
PCL点云处理之基于PCA的几何形状特征计算(五十二)
Fundamentals of programming language (2)
Mysql database - single table query (II)
16MySQL之DCL 中 COMMIT和ROllBACK
JDBC database addition, deletion, query and modification tool class
Numpy mathematical function & logical function
本地调用feign接口报404
How about CICC fortune? Is it safe to open an account