正文
增加 22 行删除 16 行
7 行未改动891011121314151617181920212223242526272829303132333435363738394041424344454647484951 行未改动7 行未改动#include<bits/stdc++.h>using namespace std;#define int long longconst int N = 10010;string s;int st,idx;int a[N],b[N];int change(char c){return (int)(c - 'A' + st);}int f(int x){int cnt = 0;while(x) x /= 10,cnt ++;return cnt;}bool stop_check(){if(idx > 3) return 1;if(idx == 3 && a[1] == 1 && a[2] == 0 && a[3] == 0) return 0;if(idx == 2) return 0;return 1;}signed main(){cin >> s >> st;for(int i = 0 ; i < s.length() ; i ++){int tt = change(s[i]),len = f(tt);idx += len;for(int j = 0; j < len; j++) {a[idx - j] = tt % 10;tt /= 10;}}while(stop_check()){for(int i = 1 ; i < idx ; i ++)b[i] = (a[i] + a[i + 1]) % 10;for(int i = 1 ; i < idx ; i ++)a[i] = b[i];idx --;}if(idx == 3) return cout << 100,0;if(a[1] == 0) return cout << a[2],0;cout << a[1] << a[2];return 0;51 行未改动7 行未改动891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545551 行未改动7 行未改动#include<bits/stdc++.h>using namespace std;#define int long longconst int N = 10010;char s[N];//读入的人名缩写字符串int st,idx;//st:读入的转换数字 idx:存进a数组要用的下标int a[N],b[N];//用来计算的数组int change(char c){//将字母用数字取代的函数 哎呀我靠 你好像没学return (int)(c - 'A' + st);}int f(int x){//计算一个数位数的函数 哎呀我靠 你好像没学int cnt = 0;while(x) x /= 10,cnt ++;return cnt;}bool stop_check(){//循环条件 哎呀我靠 你好像没学if(idx > 3) return 1;if(idx == 3 && a[1] == 1 && a[2] == 0 && a[3] == 0) return 0;if(idx == 2) return 0;return 1;}signed main(){cin >> s >> st;for(int i = 0 ; i < strlen(s) ; i ++){//int tt = change(s[i]),len = f(tt);int tt = (int)(s[i] - 'A' + st),len = 0,lrx = tt;//tt:将字母用数字替代 idx:存入a数组的下标while(lrx) lrx /= 10,len ++;//下标+=位数idx += len;//存入a数组中for(int j = 0 ; j < len ; j ++)a[idx - j] = tt % 10,tt /= 10;}//while(stop_check()){while(idx > 2 && !(idx == 3 && a[1] == 1 && a[2] == 0 && a[3] == 0)){memset(b,0,sizeof(b));//清空b数组for(int i = 1 ; i < idx ; i ++)//将相邻的两位数相加,并写下和的个位数b[i] = (a[i] + a[i + 1]) % 10;for(int i = 1 ; i < idx ; i ++)//再放入a数组中,循环使用a[i] = b[i];idx --;//位数--,显然}//输出部分,注意判断if(idx == 3) return cout << 100,0;if(a[1] == 0) return cout << a[2],0;cout << a[1] << a[2];return 0;51 行未改动