当前位置:网站首页>L1-046 divide singles (20 points)
L1-046 divide singles (20 points)
2022-04-22 04:18:00 【WTXYL】
The so-called “ A bachelor ”, It's not about being single ~ It's all about 1 The numbers that make up , such as 1、11、111、1111 etc. . It is said that any single can be denied by one 5 Odd division at the end . such as ,111111 Can be 13 to be divisible by . Now? , Your program will read in an integer x, The whole number must be odd and it doesn't have to be 5 ending . then , After calculation , Output two numbers : The first number s, Express x multiply s A bachelor , The second number n It's the number of singles . Of course, such a solution is not the only one , The question requires you to output the smallest solution .
Tips : One obvious way is to gradually increase the number of singles , Until it's divisible x until . But the difficulty is ,s It could be a very large number —— such as , Program input 31, Then output 3584229390681 and 15, because 31 multiply 3584229390681 The result is 111111111111111, altogether 15 individual 1.
Input format :
Type in a line to give a not to 5 A positive odd number at the end x(<1000).
Output format :
Output the corresponding smallest... In one line s and n, In the meantime 1 Space separation .
sample input :
31
sample output :
3584229390681 15
notes :
Deformation of high precision multiplication
Code :
#include <iostream>
#include <vector>
using namespace std;
vector<int> mul(vector<int> & a, int b){
vector<int> c;
int t = -1;
while(t){
if(t == -1) t = 0;
for(int i = 0; i <= 9; i ++)
if((i * b + t) % 10 == 1){
a.push_back(i);
c.push_back(1);
t += i * b;
t /= 10;
break;
}
}
while(a.size() > 1 && a.back() == 0) a.pop_back();
return c;
}
int main(){
int b;
cin >> b;
vector<int> a;
vector<int> c = mul(a, b);
for(int i = a.size() - 1; i >= 0; i --)
cout << a[i];
cout << " " << c.size();
}
版权声明
本文为[WTXYL]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211000290029.html
边栏推荐
- On the origin of wireless operation and maintenance and project construction
- L3-022 地铁一日游 (30 分)【floyd+dfs】
- sumo教程——公共交通教程
- 浏览器 概述本地缓存 cookie 等
- Final of the 16th programming competition of Beijing Normal University - reproduction competition & supplementary questions
- Anaconda related
- Anaconda 相关
- Spark quick start series (5) | spark environment construction - standalone (2) configuring history log server
- Binary search for qualified values and local minimum values
- Sumo tutorial - Manhattan
猜你喜欢

Websocket learning

Cursor iterator mode

Ronglian Qimo empowers enterprises with intelligent services and redefines the value of customer service

Why can sqlmap run the issue table but not the fields

Dynamic | hanging mirror safety R & D management system has passed CMMI3 international certification

LeetCode 63. Different paths II

Autodesk genuine Service 2020 Supprimer

Autodesk genuine service2020 delete

LeetCode 63. 不同路径 II

04-Functions
随机推荐
Autodesk genuine Service 2020 Supprimer
Class component details
浏览器 概述本地缓存 cookie 等
What level have you learned from your pointer? Eight pointer questions let you deepen your understanding of pointer (Part 2) - O -
Solve the problem that the neo4j browser displays blank circles or non target attributes after importing nodes
[taro development] - Global custom navigation bar adaptation message notification box location and other problems (14)
Anaconda 相关
shell编程
SR-TE Policy(思科)----补充
【近日力扣】重复的子字符串
Final of the 16th programming competition of Beijing Normal University - reproduction competition & supplementary questions
Senet | attention mechanism - source code + comments
Revit (3) - 二开 -创建柱子
The United States raised interest rates and devalued the RMB, but such products ushered in a honeymoon period
rsync远程同步
【近日力扣 】两数之和+相同的树
NVIDIA, Wanxiang, fengyuzhu, dream chaser Fund... Talk about "new opportunities for yuan universe and industry" - 2022 yuan universe cloud Summit
你的指针学到什么层次了?8个指针题目让你加深对指针的理解(下)-O-
網頁性能優化
调用函数时,关于传参那些事~