-
个人简介
#include <bits/stdc++.h> #define int long long using namespace std; int n,cnt; string add(string x,string y){ int a[10010] = {},b[10010] = {},lenx = x.size(),leny = y.size(); for(int i = lenx - 1 ; i >= 0 ; i --){ if(x[lenx-i-1]<='9')a[i]=x[lenx-i-1]-'0'; else a[i]=x[lenx-i-1]-'A'+10; } for(int i = leny - 1 ; i >= 0 ; i --){ if(y[leny-i-1]<='9')b[i]=y[leny-i-1]-'0'; else b[i]=y[leny-i-1]-'A'+10; } int len = max(lenx,leny); for(int i = 0 ; i < len ; i ++){ a[i] += b[i]; a[i+1]+=a[i]/n; a[i] %= n; } if(a[len])len ++; string res = ""; for(int i = len - 1; i >= 0 ; i --){ if(a[i]<=9)res+=a[i]+'0'; else res+=a[i]-10+'A'; } if(res.size() == 0)return "0"; return res; } bool check(string s){ string x=s; reverse(s.begin(),s.end()); return x==s; } signed main() { string m,x; cin >> n>>m; while(cnt<=30){ if(check(m)){ cout <<cnt; return 0; } x=m; reverse(m.begin(),m.end()); m=add(x,m); cnt++; } cout <<"Impossible"; return 0; }高精度加法(模板)
string add(string x,string y){ int a[1010] = {},b[1010] = {},lenx = x.size(),leny = y.size(); for(int i = lenx - 1 ; i >= 0 ; i --)a[i] = x[lenx - i - 1] - '0'; for(int i = leny - 1 ; i >= 0 ; i --)b[i] = y[leny - i - 1] - '0'; int len = max(lenx,leny); for(int i = 0 ; i < len ; i ++){ a[i] += b[i]; a[i + 1] += a[i] / 10; a[i] %= 10; } if(a[len])len ++; string res = ""; for(int i = len - 1; i >= 0 ; i --)res += a[i] + '0'; if(res.size() == 0)return "0"; return res; }高精度乘法(模板)
string mul(string x,string y){ int a[2010] = {},b[2010] = {},c[4010] = {},lenx = x.size(),leny = y.size(); for(int i = 0 ; i < lenx ; i ++)a[i] = x[lenx - i - 1] - '0'; for(int j = 0 ; j < leny ; j ++)b[j] = y[leny - j - 1] - '0'; for(int i = 0 ; i < lenx ; i ++){ for(int j = 0 ; j < leny ;j ++){ c[i + j] += a[i] * b[j]; c[i + j + 1] += c[i + j] / 10; c[i + j] %= 10; } } int len = lenx + leny; while(len > 1 && c[len - 1] == 0)len -- ; string res = ""; for(int i = len - 1; i >= 0 ;i --)res += c[i] + '0'; return res; }高精度减法(模板)
string sub(string x,string y){//计算两个高精度数字加法的结果 string ans = ""; if(x.size() < y.size() || x.size() == y.size() && x < y){ swap(x,y); ans += "-"; } int a[101000] = {},b[101000] = {},lenx = x.size(),leny = y.size(); //x[lenx - 1 - i] - '0'是表示把字符转换成数字 for(int i = 0 ; i < lenx ; i ++)a[i] = x[lenx - 1 - i] - '0';//倒序存储 for(int i = 0 ; i < leny ; i ++)b[i] = y[leny - 1 - i] - '0';//倒序存储 int len = max(lenx,leny);//取长度更长的数字长度 for(int i = 0 ;i < len ; i ++){ a[i] -= b[i]; if(a[i] < 0){ a[i] += 10; a[i + 1] --; } } if(a[len] == 1)len ++;//判断最高位有没有进位,有的话那么数字长度变长 for(int i = len - 1 ; i >= 0; i -- )ans += a[i] + '0'; return ans; }高精度除法(高精除以低精度)(模板)
struct node{ string s; int res; }; node divd(string a,int b){ node ans = {"",0}; for(int i = 0 ; i < a.size() ;i ++){ ans.res = ans.res * 10 + a[i] - '0';//余数和下一位结合 ans.s += ans.res / b + '0';//计算每一位商 ans.res %= b;//重新计算余数 } while(ans.s[0] == '0')ans.s = ans.s.substr(1); if(ans.s == "")ans.s = "0"; return ans; }二分函数:
upper_bound(); lower_bound();L2单词的长度
#include <iostream> #include <string> using namespace std; int main() { string text; getline(cin,text); int start = 0; int end; while ((end = text.find(' ', start)) != string::npos) { string word = text.substr(start, end - start); if(word.length() != 0) cout << word.length() << "," ; start = end + 1; } if (start < text.length()) { string word = text.substr(start); if(word.length() != 0) cout << word.length() << endl; } return 0; }```cppGesp大纲
https://gesp.ccf.org.cn/101/attach/1579675000242208.pdfplayhop.com Arena King `92216965` `30146839` https://yorg.io/ vortel mosc https://www.sputnik8.com/ru/antalya/activities/32036-hlopkovyy-zamok-belosnezhnye-terrasy-pamukkale-iz-antalii?event_date=2026-05-01&option_id=32036&event_id=194980117&ticket_id_100155=1#gallery
-
最近活动