QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#261638#6446. Stretching StreamersZhouShang#Compile Error//C++141.9kb2023-11-23 05:05:102023-11-23 05:05:11

Judging History

你现在查看的是最新测评结果

  • [2023-11-23 05:05:11]
  • 评测
  • [2023-11-23 05:05:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for(int i = a; i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(s) (int)(x).size()
#define PB push_back
#define cmx(x, y) x = max(x, y)
#define cmn(x, y) x = min(x, y)
typedef pair<int, int> pii;
typedef vector<int> vi;

const int mod = 1000000007;
int dp[302][302][2];
int ok[302][302];
int tab[302];

signed main() {
	cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> tab[i];
        dp[i][i][0] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (gcd(tab[i], tab[j]) != 1)
                ok[i][j] = 1;
        }
    }
    for (int dl = 1; dl < n; dl++) {
        for (int pocz = 0; pocz < n; pocz++) {
            int kon = (pocz + dl) % n;
            // Z otoczką
            if (ok[pocz][kon]) {
                for (int srdl = 0; srdl < dl; srdl++) {
                    int sr = (pocz + srdl) % n;
                    dp[pocz][kon][1] += dp[pocz][sr][0] * dp[sr+1][kon][0] % mod;
                    dp[pocz][kon][1] %= mod;
                }
            }
            // Bez otoczki
//            dp[pocz][kon][0] = dp[pocz][kon][1];
            for (int srdl = 0; srdl < dl; srdl++) {
                int sr = (pocz + srdl) % n;
                if (!ok[sr][kon])
                    continue;
                dp[pocz][kon][0] += dp[pocz][sr][0] * dp[sr][kon][1] % mod;
                dp[pocz][kon][0] %= mod;
            }
//            cerr << pocz << " " << kon << " " << dp[pocz][kon][0] << " " << dp[pocz][kon][1] << "\n";
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        res += dp[(i+1)%n][i][0];
        res %= mod;
    }
    cout << res << "\n";
}

Details

answer.code: In function ‘int main()’:
answer.code:29:17: error: ‘gcd’ was not declared in this scope
   29 |             if (gcd(tab[i], tab[j]) != 1)
      |                 ^~~