Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
138970 hjx211144 相对分子质量 C++ Accepted 0 MS 272 KB 631 2025-11-30 17:00:06

Tests(1/1):


Code:

#include <bits/stdc++.h> using namespace std; int main() { char a[9]={'H','C','N','O','F','P','S','K'},c[100]; int f,i,j,k,n,s,b[8]={1,12,14,16,19,31,32,39}; scanf("%d",&n); while (n--) { scanf("%s",c); f=i=0; while (i<strlen(c)) { j=0; while (j<8) { if (c[i]==a[j] and c[i]>='A' and c[i]<='Z') { s=b[j]; break; } j++; } i++; k=0; while (c[i]>='0' and c[i]<='9' and i<strlen(a)) { k=k*10+c[i]-'0'; i++; } if (k==0) f=f+s*1; else f=f+s*k; } printf("%d\n",f); } return 0; }