当前位置:网站首页>Pat class a 1024 palindromic number
Pat class a 1024 palindromic number
2022-06-27 02:51:00 【IX. non random address】
The value may be out of bounds long long, Use string Saved and calculated
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
string add(string &s, string &s0){
string st;
int x, y, z, tmp, h = 0;
reverse(s.begin(), s.end());
reverse(s0.begin(), s0.end());
for(int i=0; i<s.length(); i++){
x = s[i] - '0';
y = s0[i] - '0';
z = (x + y + h)/10;
tmp = (x + y + h)%10;
h = z;
st += to_string(tmp);
if(i==(s.length() - 1) && z > 0) st += to_string(z);
}
reverse(st.begin(), st.end());
return st;
}
int main(void){
string s, s0, sk;
long long a, c, f, i, j, k;
cin>>s>>k;
for(i=0; i<k; i++){
s0 = s;
reverse(s0.begin(), s0.end());
if(s0==s) break;
s = add(s, s0);
}
cout<<s<<endl;
cout<<i;
return 0;
}边栏推荐
- Would rather go to 996 than stay at home! 24 years old, unemployed for 7 months, worse than work, no work
- paddlepaddle 19 动态修改模型的最后一层
- Cvpr2022 | pointdistiller: structured knowledge distillation for efficient and compact 3D detection
- TechSmith Camtasia latest 2022 detailed function explanation Download
- Flink学习3:数据处理模式(流批处理)
- Press key to control LED status reversal
- I earned 3W yuan a month from my sideline: the industry you despise really makes money!
- [array] sword finger offer II 012 The sum of left and right subarrays is equal | sword finger offer II 013 Sum of two dimensional submatrix
- 执念斩长河暑期规划
- H5 liquid animation JS special effect code
猜你喜欢

参数估计——《概率论及其数理统计》第七章学习报告(点估计)

Geometric distribution (a discrete distribution)

SQLite reader plug-in tests SQLite syntax

Why pass SPIF_ Sendchange flag systemparametersinfo will hang?

一文教你Kali信息收集

Dameng database installation

Learn Tai Chi maker mqtt (IX) esp8266 subscribe to and publish mqtt messages at the same time
![[Shangshui Shuo series] day 6](/img/47/7cd44f4e361af53cac7cea9d0d7ecb.png)
[Shangshui Shuo series] day 6

QIngScan使用

DAMA、DCMM等数据管理框架各个能力域的划分是否合理?有内在逻辑吗?
随机推荐
Test the respective roles of nohup and &
Flink学习5:工作原理
2022年氯碱电解工艺试题及答案
2022 Chinese pastry (Advanced) recurrent training question bank and online simulation test
CVPR2022 | PointDistiller:面向高效紧凑3D检测的结构化知识蒸馏
Qingscan use
2022中式面点师(高级)复训题库及在线模拟考试
剑指Offer || :栈与队列(简单)
栈溢出漏洞
Mmdetection uses yolox to train its own coco data set
Oracle/PLSQL: Ltrim Function
Flink learning 4:flink technology stack
Learn Tai Chi maker mqtt (IX) esp8266 subscribe to and publish mqtt messages at the same time
Flink Learning 2: Application Scenarios
人群模拟
TechSmith Camtasia最新2022版详细功能讲解下载
Flink learning 5: how it works
对数器
Quicksand painting simulator source code
Regular expressions: Syntax
https://github.com/ZouJiu1/PAT