当前位置:网站首页>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;
}边栏推荐
- Sample development of WiFi IOT Hongmeng development kit
- Qingscan use
- Laravel 的 ORM 缓存包
- 2022年氯碱电解工艺试题及答案
- TP5 spreadsheet excel table export
- Geometric distribution (a discrete distribution)
- PAT甲级 1026 Table Tennis
- Super detailed, 20000 word detailed explanation, thoroughly understand es!
- 一文教你Kali信息收集
- Press key to control LED status reversal
猜你喜欢

Flink学习1:简介

Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message

Learn Tai Chi Maker - mqtt (VIII) esp8266 subscribe to mqtt topic

Flink学习5:工作原理

【一起上水硕系列】Day 6

Hot discussion: what are you doing for a meaningless job with a monthly salary of 18000?

发现一款 JSON 可视化工具神器,太爱了!

STM32入门介绍

ConstraintLayout(约束布局)开发指南

H5 liquid animation JS special effect code
随机推荐
1. Project preparation and creation
Oracle/PLSQL: VSize Function
PAT甲级 1023 Have Fun with Numbers
Flink學習2:應用場景
ConstraintLayout(约束布局)开发指南
Is the division of each capability domain of Dama, dcmm and other data management frameworks reasonable? Is there internal logic?
使用命令行安装达梦数据库
Yuantou firm offer weekly record 20220627
Cs5213 HDMI to VGA (with audio) single turn scheme, cs5213 HDMI to VGA (with audio) IC
TP5 spreadsheet excel table export
I earned 3W yuan a month from my sideline: the industry you despise really makes money!
Oracle/PLSQL: NumToDSInterval Function
Topolvm: kubernetes local persistence scheme based on LVM, capacity aware, dynamically create PV, and easily use local disk
Paddlepaddle 20 implementation and use of exponentialmovingaverage (EMA) (support static graph and dynamic graph)
PAT甲级 1018 Public Bike Management
发现一款 JSON 可视化工具神器,太爱了!
"All majors are persuading them to quit." is it actually the most friendly to college students?
Why pass SPIF_ Sendchange flag systemparametersinfo will hang?
Logarithm
一文教你Kali信息收集
https://github.com/ZouJiu1/PAT