2 条题解

  • 2
    @ 2022-12-5 10:04:41

    有点像打表......

    #include <iostream>
    #include <stack>
    #include <cmath>
    #include <map>
    #include <vector>
    #include <string.h>
    #include <queue>
    #include <stdio.h>
    #include <iomanip>
    #include <cstdio>
    #include <algorithm>
    #define int long long
    using namespace std;
    const int INF = 0x3f3f3f3f;
    const int N = 1e5 + 10;
    int a[30];
    signed main()
    {
        a['a'] = 1;
        a['b'] = 2;
        a['c'] = 3;
        a['d'] = 1;
        a['e'] = 2;
        a['f'] = 3;
        a['g'] = 1;
        a['h'] = 2;
        a['i'] = 3;
        a['j'] = 1;
        a['k'] = 2;
        a['l'] = 3;
        a['m'] = 1;
        a['n'] = 2;
        a['o'] = 3;
        a['p'] = 1;
        a['q'] = 2;
        a['r'] = 3;
        a['s'] = 4;
        a['t'] = 1;
        a['u'] = 2;
        a['v'] = 3;
        a['w'] = 1;
        a['x'] = 2;
        a['y'] = 3;
        a['z'] = 4;
        a[' '] = 1;
        string s;
        getline(cin, s);
        int ans = 0;
        for(int i = 0; i < s.size(); i++)
        {
            ans += a[s[i]];
        }
        cout << ans << endl;
        return 0;
    }
    
    • 0
      @ 2024-4-5 16:33:39
      /*
      int       %d
      longlong  %lld
      float     %f
      double    %lf
      char      %c
      char[]    %s
      'a'=97
      'z'=122
      'A'=65
      'Z'=90
      '0'=48
      '9'=57
      */
      #include <iostream>
      #include <iomanip>
      #include <cmath>
      #include <cstdio>
      #include <cstring>
      #include <algorithm>
      using namespace std;
      const int N=1e5+10;
      const int INF=0x3f3f3f3f;
      int a[26]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4},ans;
      string s;
      int main(){
      	getline(cin,s);
      	int len=s.size();
      	for(int i=0;i<len;i++){
      		if(s[i]==' '){
      			ans++;
      		}else{
      			ans+=a[s[i]-'a']; 
      		}
      	}
      	cout<<ans;
      return 0;
      }
      
      • 1

      信息

      ID
      1166
      时间
      1000ms
      内存
      32MiB
      难度
      5
      标签
      递交数
      124
      已通过
      49
      上传者