存一下代码吧,呜呜呜

存一下代码吧,呜呜呜,第1张

存一下代码吧,呜呜呜
#include 
using namespace std;
using ll = long long;

const int N = 1505;
const ll p = 131;
const ll mod = 1e9+7;

char s[N];

ll Hash(){
    int len = strlen(s+1);
    ll res = 0;
    for (int i = 1; i <= len; i++){
        res = (res * p + s[i]) % mod;
    }
    return res;
}

set  S;

int main()
{
    int n;
    scanf("%d", &n);
    while (n--){
        scanf("%s", s+1);
        S.insert(Hash());
    }
    printf("%dn", (int)S.size());

    return 0;
}
#include 
using namespace std;
using ll = long long;

const int N = 1e6+5;
const ll p = 131;
const ll mod = 1e9+7;

char s[N];
ll hs[N], pn[N];

void Hash(){
    pn[0] = 1;
    int len = strlen(s+1);
    for (int i = 1; i <= len; i++){
        hs[i] = (hs[i-1] * p + s[i]) % mod;
        pn[i] = pn[i-1] * p % mod;
    }
}

ll subHash(int l, int r){
    return (hs[r] - hs[l-1] * pn[r-l+1] % mod + mod) % mod;
}

int main()
{
    int n, l1, r1, l2, r2;
    scanf("%s%d", s+1, &n);
    Hash();
    while (n--){
        scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
        if (subHash(l1, r1) == subHash(l2, r2)) puts("Yes");
        else puts("No");
    }

    return 0;
}
#include 
using namespace std;
using ll = long long;

const int N = 1e5+5;
const ll p = 131;
const ll mod = 1e9+7;

char s[N], t[N];
ll hs[N], ht[N], pn[N];

ll Hash(char* s, ll* hs, int len){
    for (int i = 1; i <= len; i++){
        hs[i] = (hs[i-1] * p + s[i]) % mod;
    }
    return hs[len];
}

ll subHash(ll* hs, int l, int r){
    return (hs[r] - hs[l-1] * pn[r-l+1] % mod + mod) % mod;
}

int main()
{
    pn[0] = 1;
    for (int i = 1; i < N; i++){
        pn[i] = pn[i-1] * p % mod;
    }
    int T;
    scanf("%d", &T);
    while (T--){
        int ans = 0;
        scanf("%s%s", s+1, t+1);
        int lens = strlen(s+1), lent = strlen(t+1);
        ll hasht = Hash(t, ht, lent);
        Hash(s, hs, lens);
        for (int i = 1; i <= lens - lent + 1; i++){
            if (subHash(hs, i, i+lent-1) == hasht) ans++;
            else {
                int cnt = 0;
                int l = i;
                while (++cnt <= 3){
                    int r = i+lent-1;
                    while (l <= r){
                        int mid = (l + r) >> 1;
                        if (subHash(hs, l, mid) == subHash(ht, l-i+1, mid-i+1)) l = mid+1;
                        else r = mid-1;
                    }
                    l++;
                }
                if (l > i+lent-1 || subHash(hs, l, i+lent-1) == subHash(ht, l-i+1, lent)) ans++;
            }
        }
        printf("%dn", ans);
    }

    return 0;
}
#include 
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		long long n,a,b;
		scanf("%lld%lld%lld",&n,&a,&b);
		int ans=0;
		long long k=1;
		if(n==1) ans=1;
		else if(a==1){
			if((n-1)%b==0){ans=1;}
			
		}
		else{
			while(k<=n){
				if((n-k)%b==0){
					ans=1;
					break;
				}
				else k*=a;
			}
		}
		if(ans==1) printf("Yesn");
		else puts("No");
	}
	return 0;
}
#include 
using namespace std;
int p[100010],cnt,ver[100010],edge[100010],head[100010],ne[100010],tot=0;
queueq;
int  a[100010];
int ru[100010],chu[100010];
int c[100010],u[100010];
int n,m;
bool ll;
void add(int x,int y,int z){
	ver[++cnt]=y;
    edge[tot]=z;
	ne[tot]=head[x];
	head[x]=tot;
}
void tuopu(){
	for(int i=1;i<=n;i++){
		if(!ru[i]){q.push(i);}
		
	}
	while(q.size()){
		int x=q.front();
		p[++cnt]=x;
		q.pop();
		for(int i=head[x];i;i=ne[i]){
			if(--(ru[ver[i]])==0){
				q.push(ver[i]);
			}
		}
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i>c[i]>>u[i];
	}
	for(int i=1;i<=m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		add(x,y,z);
		ru[y]++;
		chu[x]++;
	}
	for(int i=1;i<=n;i++){
		if(ru[i]){
			c[i]-=u[i];
		}
	}
	tuopu();
	for(int i=1;i<=cnt;i++){
		int x=p[i];
		if(c[x]>0){
			for(int j=head[x];j;j=ne[j]){
				c[ver[j]]+=c[x]*edge[j];
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(!chu[i]&&c[i]>0) {
			cout< 
#include
using namespace std;
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int ch[200]={0};
		int n,k;
		scanf("%d%d",&n,&k);
		getchar();
		for(int i=0;i=k) sum++;
		printf("%dn",sum);
	}
	return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5702963.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存