30求助,谢谢
查看原帖
30求助,谢谢
227654
平易楼主2020/10/29 20:29

请问有人知道为什么下面代码只能拿30吗? 谢谢!!!!!!!!!


#include <iostream>
#include <cstring>
#include <fstream>

using namespace std;

bool _hash[10086];
int _maxi;
int _res = 0;
int _myList[10086];

void CParseIn () {
  memset(_hash, false, sizeof(_hash));
  cin >> _maxi;
  for (int i = 0; i < _maxi; i ++) {
    cin >> _myList[i];
    _hash[_myList[i]] = true;
  }
}

void ParseIn () {
  memset(_hash, false, sizeof(_hash));

  ifstream inFile ("P2141.in");

  inFile >> _maxi;
  for (int i = 0; i < _maxi; i ++) {
    inFile >> _myList[i];
    _hash[_myList[i]] = true;
  }

  inFile.close();
}

void Core () {
  for (int i = 0; i < _maxi; i ++) {
    for (int m = i + 1; m < _maxi; m ++) {
      if (_hash[_myList[i] + _myList[m]]) {
	_res ++;
      }
    }
  }

  cout << _res << endl;
}

int main () {
  CParseIn();
  Core();

  return 0;
}

2020/10/29 20:29
加载中...