头像

Mashiro-z


访客:124

离线:1个月前



Mashiro-z
3个月前

这道题很难吗??

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    double a,b;
    cin >>a;
    if(a<0){
        a = a*(-1);
        b = pow(a,1.0/3);
        printf("-%6f",b);
        return 0;
    }
    b = pow(a,1.0/3);
    printf("%6f",b);
    return 0;
}


活动打卡代码 AcWing 138. 兔子与兔子

Mashiro-z
4个月前
#include<iostream>
#include<cstring>
using namespace std;
const int N = 1000010,base = 131;
char str[N];
typedef unsigned long long ULL;
ULL p[N],h[N];
ULL get(int l,int r){
    return h[r]-h[l-1]*p[r-l+1];
}
int main(){
    scanf("%s",str+1);
    int m;
    cin >>m;
    int n = strlen(str+1);
    p[0]=1;
    for(int i = 1;i<=n;i++){
        h[i] = h[i-1]*base+str[i]-'a'+1;
        p[i] = p[i-1]*base;
    }
    while(m--){
        int l1,r1,l2,r2;
        cin >>l1>>r1>>l2>>r2;
        if(get(l1,r1)==get(l2,r2)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


活动打卡代码 AcWing 89. a^b

Mashiro-z
5个月前
#include<iostream>
using namespace std;
typedef long long ll;
ll ksm(ll a, ll b, ll p) {
    ll ans = 1%p;
    while (b) {
        if ((b & 1) != 0) {
            ans = ans * a % p;
        }
        a = a * a % p;
        b = b >> 1;
    }
    return ans;
}
int main() {
    ll d, e, c;
    cin >> d >> e >> c;
    //int ans = ksm(d,e,c);
    cout << ksm(d, e, c) << endl;
    return 0;
}