一个问题
  • 板块灌水区
  • 楼主Jaspercheng
  • 当前回复4
  • 已保存回复4
  • 发布时间2025/1/21 16:47
  • 上次更新2025/1/21 19:30:39
查看原帖
一个问题
1022616
Jaspercheng楼主2025/1/21 16:47
#include <bits/stdc++.h>
#define f1(x , y) for(int i = x ; i <= y ; i++)
#define f2(x , y) for(int j = x ; j <= y ; j++)
#define ri register int
#define ll long long
#define il inline
#define cs const
using namespace std;

il int rd(){
    int out = 0 , flag = 1; char c = getchar();	
    while(c < '0' || c >'9'){if(c == '-')flag = -1; c = getchar();}
    while(c >= '0' && c <= '9'){out = out * 10 + c - '0'; c = getchar();}
    return flag * out;
}

cs int M = 1505 , mod1 = 998244353 , mod2 = 1e9 + 7 , base = 130;
char b[M];
map <pair<ll , ll> , bool> mp;

int main(){
	int n = rd() , cnt = 0;
	f1(1 , n){
		cin >> b + 1;
		int l = strlen(b + 1);
		ll hash1 = 0 , hash2 = 0;
		f2(1 , l){
			hash1 = (hash1 * base + b[j]) % mod1;
			hash2 = (hash2 * base + b[j]) % mod2;
		}pair <ll , ll> pr = make_pair(hash1 , hash2);
		if(mp.find(pr) == mp.end()){
			++cnt;
			mp[pr] = true;
		}
	}cout << cnt;
	return 0;
}

这个题的这里

		if(mp.find(pr) == mp.end()){
			++cnt;
			mp[pr] = true;
		}

不明白

可不可以帮忙讲一讲QwQ

2025/1/21 16:47
加载中...