版本比较
缘分计算 拓展
正文
增加 22 行删除 16 行
7 行未改动89101112131415121314151617181819202122232324252627282930313231323334353637343536373839404139404243444546424748444950515253545551 行未改动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){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 f(int x){//计算一个数位数的函数 哎呀我靠 你好像没学 int cnt = 0; while(x) x /= 10,cnt ++; return cnt;}bool stop_check(){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); 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; for(int j = 0; j < len; j++) { a[idx - j] = tt % 10; tt /= 10; } //存入a数组中 for(int j = 0 ; j < len ; j ++) a[idx - j] = tt % 10,tt /= 10; } while(stop_check()){ for(int i = 1 ; i < idx ; i ++) //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 ++) for(int i = 1 ; i < idx ; i ++)//再放入a数组中,循环使用 a[i] = b[i]; idx --; 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 行未改动