当前位置:网站首页>【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
边栏推荐
- Record: call mapper to report null pointer Foreach > the usage of not removing repetition;
- How about CICC fortune? Is it safe to open an account
- 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
- Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127
- Click an EL checkbox to select all questions
- 【目标跟踪】基于帧差法结合卡尔曼滤波实现行人姿态识别附matlab代码
- nc基础用法2
- SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
- 记录:调用mapper报空指针;<foreach>不去重的用法;
- What is the difference between a host and a server?
猜你喜欢

PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)

DNS cloud school rising posture! Three advanced uses of authoritative DNS

Numpy - creation of data type and array

Compact CUDA tutorial - CUDA driver API

Linux64Bit下安装MySQL5.6-不能修改root密码

PCL点云处理之计算两平面交线(五十一)

Understanding various team patterns in scrum patterns

Redis cache penetration, cache breakdown, cache avalanche
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
![[latex] 5 how to quickly write out the latex formula corresponding to the formula](/img/1f/3c5a332ce1d6852dde38040faea5bf.png)
[latex] 5 how to quickly write out the latex formula corresponding to the formula
随机推荐
Click an EL checkbox to select all questions
Fundamentals of programming language (2)
STM32基础知识
aqs的学习
Operation of numpy array
Design of library management database system
Research on open source OCR engine
[latex] 5 how to quickly write out the latex formula corresponding to the formula
Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
Linux64Bit下安装MySQL5.6-不能修改root密码
nc基础用法3
R语言使用timeROC包计算存在竞争风险情况下的生存资料多时间AUC值、使用cox模型、并添加协变量、R语言使用timeROC包的plotAUCcurve函数可视化多时间生存资料的AUC曲线
[text classification cases] (4) RNN and LSTM film evaluation Tendency Classification, with tensorflow complete code attached
Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
DTMF双音多频信号仿真演示系统
Unity 模型整体更改材质
How does onlyoffice solve no route to host
网络通信基础(局域网、广域网、IP地址、端口号、协议、封装、分用)
Why does ES6 need to introduce map when JS already has object type
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code