为何本地CE,洛谷能过

P1593 因子和

5t0_0r2 @ 2023-10-27 13:24:17

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 9901;
int A, B;
map<int, int> primes;
void divide(int n) {
    while(!(n & 1)){
        primes[2]++;
        n >>= 1;
    }
    for(int i = 3;i * i <= n;i += 2) {
        while(!(n % i)){
            primes[i]++;
            n /= i;
        }
    }
    if(n > 1)
        primes[n]++;
}
int qpow(int a, int b) {
    int ret = 1;
    while(b) {
        if(b & 1)
            ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}
int sum(int p, int k) {
    if(k == 1)
        return 1;
    if(!(k & 1))
        return (qpow(p, k >> 1) + 1) * sum(p, k >> 1) % MOD;
    return (qpow(p, k - 1) + sum(p, k - 1)) % MOD;
}
signed main(){
    scanf("%lld%lld", &A, &B);
    if(!A){
        printf("0");
        return 0;
    }
    divide(A);
    int res = 1;
    for(auto it : primes){
        int p = it.first, k = it.second * B;
        res = res * sum(p, k + 1) % MOD;
    }
    printf("%lld",res);
    return 0;
}

报错信息:

In function 'int main()':
46  14  [Error] 'it' does not name a type
50  2   [Error] expected ';' before 'printf'
51  5   [Error] expected primary-expression before 'return'
51  5   [Error] expected ')' before 'return'

by _8008008 @ 2023-10-27 13:26:45

-std=14


by only_a_speaker @ 2023-10-27 13:26:55

您好,这可能是因为本地编译器支持的语言标准较低所致。在本地编译时,请强制指定 -std=C++14 ;如果仍不行,请更新编译器。


|