关注
只有通过了55% ,求解 #include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
#include<queue>
#include<fstream>
using namespace std;
int n;
string num;
int nums[20];
int vis[11];
int BigNumMod(int BigNum[], int c, int length) {
int ans = 0;
for (int i = 0; i < length; i++)
ans = ((ans * 10) + BigNum[i]) % c;
return ans;
}
int main() {
scanf("%d", &n);
int len, cnt, c;
while (n--) {
cin >> num;
cnt = 0;
len = num.length();
memset(vis, -1, sizeof(vis));
vis[0] = 1;
for (int i = 0; i < len; i++)nums[i] = num[i] - '0';
for (int i = 0; i < len; i++) {
c = num[i] - '0';
if (vis[c] == 1)cnt++;
else if (vis[c] == -1 && BigNumMod(nums, c, len) == 0) {
vis[c] = 1;
cnt++;
}
else {
vis[c] = 0;
}
}
printf("%s", len == cnt ? "G" : cnt == 0 ? "S" : "H");
if (n != 0)printf("\n");
}
return 0;
}
查看原帖
点赞 评论
相关推荐
05-25 10:45
西华大学 Java 
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 我的实习收获 #
26955次浏览 462人参与
# 非技术岗简历怎么写 #
209451次浏览 2857人参与
# 实习吐槽大会 #
28332次浏览 136人参与
# 26届秋招投递记录 #
2635次浏览 86人参与
# 晒一晒你的工位 #
84896次浏览 302人参与
# 2025牛客秋招季 #
2639次浏览 88人参与
# 如果有时光机,你最想去到哪个年纪? #
46882次浏览 796人参与
# 双非能在秋招上岸吗? #
214896次浏览 1137人参与
# 我的租房踩坑经历 #
23546次浏览 251人参与
# 打工人的工作餐日常 #
40352次浏览 343人参与
# 穿越回高考你还会选现在的专业吗 #
19714次浏览 249人参与
# 软开人,说说你的烦心事 #
47997次浏览 359人参与
# 被AI治愈的瞬间 #
52188次浏览 597人参与
# 毕业旅行去哪玩儿 #
1118次浏览 32人参与
# 怎么防止在试用期被辞退 #
122235次浏览 910人参与
# 关于提前批我想问 #
201755次浏览 2143人参与
# 高学历就一定能找到好工作吗? #
47569次浏览 591人参与
# 携程求职进展汇总 #
531170次浏览 3962人参与
# 打工人锐评公司红黑榜 #
145576次浏览 912人参与
# 夸夸我的求职搭子 #
190928次浏览 1891人参与