https://www.luogu.org/problemnew/show/P1553

    1. #include <cmath>
    2. #include <cstdio>
    3. #include <iostream>
    4. #include <algorithm>
    5. #include <queue>
    6. #include <map>
    7. #include <cstring>
    8. #include <vector>
    9. #include <stack>
    10. using namespace std;
    11. #define ll long long
    12. #define ff first
    13. #define ss second
    14. #define mp make_pair
    15. #define ph push
    16. #define pb push_back
    17. #define all(x) (x).begin(), (x).end()
    18. string::size_type pos;
    19. string qf0(string s) {
    20. reverse(s.begin(), s.end());
    21. while (s.size() > 1 && s[0] == '0') {
    22. s.erase(0, 1);
    23. }
    24. if (s.size() == 0) {
    25. s = "0";
    26. }
    27. return s;
    28. }
    29. string ql0(string s) {
    30. reverse(s.begin(), s.end());
    31. while (s.size() > 1 && s[s.size() - 1] == '0') {
    32. s.erase(s.size() - 1, 1);
    33. }
    34. if (s.size() == 0) {
    35. s = "0";
    36. }
    37. return s;
    38. }
    39. void f(string s) {
    40. pos = s.find(".");
    41. if (pos != s.npos) {
    42. //从0开始截取pos位
    43. string s1 = s.substr(0, pos), s2 = s.substr(pos + 1);
    44. cout << qf0(s1) << "." << ql0(s2) << endl;
    45. return;
    46. }
    47. pos = s.find("/");
    48. if (pos != s.npos) {
    49. string s1 = s.substr(0, pos), s2 = s.substr(pos + 1);
    50. cout << qf0(s1) << "/" << qf0(s2) << endl;
    51. return;
    52. }
    53. pos = s.find("%");
    54. if (pos != s.npos) {
    55. string s1 = s.substr(0, pos);
    56. cout << qf0(s1) << "%" << endl;
    57. return;
    58. }
    59. cout << qf0(s) << endl;
    60. }
    61. int main() {
    62. ios::sync_with_stdio(false);
    63. string s;
    64. cin >> s;
    65. f(s);
    66. }

    https://www.luogu.org/problemnew/show/P1055

    1. #include <cmath>
    2. #include <cstdio>
    3. #include <iostream>
    4. #include <algorithm>
    5. #include <queue>
    6. #include <map>
    7. #include <cstring>
    8. #include <vector>
    9. #include <stack>
    10. using namespace std;
    11. #define ll long long
    12. #define ff first
    13. #define ss second
    14. #define mp make_pair
    15. #define ph push
    16. #define pb push_back
    17. #define all(x) (x).begin(), (x).end()
    18. string::size_type pos;
    19. int qSumMod(string s) {
    20. int t = 1, sum = 0;
    21. for (int i = 0; i <s.size(); ++i) {
    22. if (s[i] != '-') {
    23. sum += (s[i] - '0') * t;
    24. ++t;
    25. }
    26. }
    27. return sum % 11;
    28. }
    29. void f(string s) {
    30. pos = s.rfind("-");
    31. string s1 = s.substr(0, pos), s2 = s.substr(pos + 1);
    32. int t = s2[0] == 'X' ? 10 : s2[0] - '0';
    33. int mod = qSumMod(s1);
    34. if (mod == t) {
    35. cout << "Right" << endl;
    36. } else {
    37. cout<<(s.substr(0, pos+1));
    38. if (mod == 10) {
    39. cout << "X" << endl;
    40. } else {
    41. cout << mod << endl;
    42. }
    43. }
    44. }
    45. int main() {
    46. ios::sync_with_stdio(false);
    47. string s;
    48. cin >> s;
    49. f(s);
    50. }

    https://www.luogu.org/problemnew/show/P1308

    1. #include <cmath>
    2. #include <cstdio>
    3. #include <iostream>
    4. #include <algorithm>
    5. #include <queue>
    6. #include <map>
    7. #include <cstring>
    8. #include <vector>
    9. #include <stack>
    10. #include <string>
    11. using namespace std;
    12. #define ll long long
    13. #define ff first
    14. #define ss second
    15. #define mp make_pair
    16. #define ph push
    17. #define pb push_back
    18. #define all(x) (x).begin(), (x).end()
    19. string::size_type pos;
    20. string toLowerCase(string s) {
    21. for (int i = 0; i < s.size(); i++) {
    22. if (s[i] >= 'A' && s[i] <= 'Z') {
    23. s[i] += 32;
    24. }
    25. }
    26. return s;
    27. }
    28. vector<pair<string,int> > split(string s) {
    29. s+=" ";
    30. vector<pair<string,int> > allStr;
    31. string re="";
    32. for(int i=0;i<s.size();i++){
    33. if(s[i]==' '){
    34. if(re.size()>0){
    35. allStr.pb(mp(re,i-re.size()));
    36. }
    37. re="";
    38. }else{
    39. re+=s[i];
    40. }
    41. }
    42. return allStr;
    43. }
    44. void f(string s, string s1) {
    45. vector<pair<string,int> > allStr = split(s1);
    46. int sum=0,flag=1,n=0;
    47. for(int i=0;i<allStr.size();i++){
    48. if(allStr[i].ff==s){
    49. if(flag){
    50. n=allStr[i].ss;
    51. flag=0;
    52. }
    53. sum++;
    54. }
    55. }
    56. if (!flag) {
    57. cout << sum << " " << n << endl;
    58. } else {
    59. cout << -1 << endl;
    60. }
    61. }
    62. int main() {
    63. ios::sync_with_stdio(false);
    64. string s, s1;
    65. cin >> s;
    66. getline(cin, s1);
    67. getline(cin, s1);
    68. s = toLowerCase(s);
    69. s1 = toLowerCase(s1);
    70. f(s, s1);
    71. }

    https://www.luogu.org/problemnew/show/P1200

    #include <cmath>
    #include <cstdio>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <map>
    #include <cstring>
    #include <vector>
    #include <stack>
    #include <string>
    
    using namespace std;
    #define ll long long
    #define ff first
    #define ss second
    #define mp make_pair
    #define ph push
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    typedef pair<int, int> pii;
    
    ll qm(string s) {
        ll sum = 1;
        for (char c:s) {
            ll t = (c - 'A') + 1;
            sum *= t;
        }
        return sum % 47;
    }
    
    void f(string s1, string s2) {
        if (qm(s1) == qm(s2)) {
            cout << "GO" << endl;
        } else {
            cout << "STAY" << endl;
        }
    }
    
    int main() {
        ios::sync_with_stdio(false);
        string s1, s2;
        cin >> s1 >> s2;
        f(s1, s2);
    }
    

    https://www.luogu.org/problemnew/show/P1914

    #include <cmath>
    #include <cstdio>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <map>
    #include <cstring>
    #include <vector>
    #include <stack>
    #include <string>
    
    using namespace std;
    #define ll long long
    #define ff first
    #define ss second
    #define mp make_pair
    #define ph push
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    typedef pair<int, int> pii;
    
    void f (int n,string s){
        string res="";
        for(char c:s){
            char cc=(int)(c-'a'+n)%26+'a';
            res+=cc;
        }
        cout<<res<<endl;
    }
    
    int main() {
        ios::sync_with_stdio(false);
        int n;
        string s;
        cin>>n>>s;
        f(n,s);
    }
    

    https://www.luogu.org/problemnew/show/P1914

    #include <cmath>
    #include <cstdio>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <map>
    #include <cstring>
    #include <vector>
    #include <stack>
    #include <string>
    
    using namespace std;
    #define ll long long
    #define ff first
    #define ss second
    #define mp make_pair
    #define ph push
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    typedef pair<int, int> pii;
    
    int a[405][30];
    void f(int num[]){
        int maxNum=*max_element(num,num+26);
        for(int i=0;i<26;++i){
            for(int j=num[i],k=maxNum-1;j>0;j--,k--){
                a[k][i]=1;
            }
        }
      for(int i=0;i<maxNum;i++){
          for(int j=0;j<26;j++){
              if(j!=0){
                  cout<<" ";
              }
              if(a[i][j]==1){
                  cout<<"*";
              }else{
                  cout<<" ";
              }
          }
          cout<<endl;
      }
      for(char i='A';i<='Z';++i){
          if(i!='A'){
              cout<<" ";
          }
          cout<<i;
      }
      cout<<endl;
    
    }
    
    int main() {
        ios::sync_with_stdio(false);
        int num[30];
        memset(a, 0, sizeof(a));
        memset(num, 0, sizeof(num));
        string s,s2;
        int t=4;
        while(t--){
            getline(cin,s);
            for(int i=0;i<s.size();++i){
                if(s[i]!=' '){
                    num[s[i]-'A']++;
                }
            }
        }
       f(num);
    }