QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#546594#7704. Plus Minus Four SquaresOlegpresnyakov#Compile Error//Python31.3kb2024-09-04 10:00:172024-09-04 10:00:17

Judging History

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

  • [2024-09-04 10:00:17]
  • 评测
  • [2024-09-04 10:00:17]
  • 提交

answer

#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <time.h>
#include <unordered_map>
#include <cstdlib>
#include <string.h>
#include <bitset>
#include <unordered_set>
#include <cstdlib>
#include <string.h>
#include <cassert>
#define all(a) (a).begin(), (a).end()
#define int long long
using namespace std;

vector<int> sq;
int glob = 0;
void dfs(int n, int sum, int index, int step, int prelast, int last){
    if(step == 4){
        return;
    }

    if(prelast != last){
        index--;
    }

    for(int i = index; i >= 1; --i){
        int new_el = sum - last * sq[i];
        //cerr << new_el << "\n";
        if(sum - last * sq[i] == n){
            glob++;
        }

        dfs(n, new_el, i, step + 1, last, -1);
        dfs(n, new_el, i, step + 1, last, 1);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    sq.clear();

    for(int i = 0; i * i <= n; ++i){
        sq.push_back(i * i);
    }

    if(n == 0){
        cout << "1\n";
        return 0;
    }

    dfs(n, 0, sq.size() - 1, 0, -1, -1);
    cout << glob << "\n";
}

詳細信息

  File "answer.code", line 20
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax