QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#472201#4928. Game With Numbers0005Compile Error//C++20687b2024-07-11 15:02:192024-07-11 15:02:19

Judging History

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

  • [2024-07-11 15:02:19]
  • 评测
  • [2024-07-11 15:02:19]
  • 提交

answer

#include<iostream>
#include<vector> 
using namespace std;
long long n,m,s,x,b[20005];
long long solve(long long dep,vector<long long> v)
{
	if(dep>m){
		long long tot=0;
		for(auto x:v) tot+=x;
		return tot;
	}
	if(!v.size()) return 0;
	vector<long long> p,q;
	for(auto x:v){
		if(x%b[dep]) p.push_back(x);
		else q.push_back(x);
	}
	if(dep%2) return min(solve(dep+1,p),solve(dep+1,q))
 } 	else return max(solve(dep+1,p),solve(dep+1,q));
int main(){
	cin>>n>>m;
	vector<long long> V;
	if(m>100) {cout<<"0\n"; return 0;}
	for(long long i=1;i<=n;i++) {cin>>x; v.push_back(x); s+=x;}
	for(long long i=1;i<=m;i++) cin>>b[i];
	cout<<solve(1,V)<<"\n";
	return 0;
 } 

Details

answer.code: In function ‘long long int solve(long long int, std::vector<long long int>)’:
answer.code:18:60: error: expected ‘;’ before ‘}’ token
   18 |         if(dep%2) return min(solve(dep+1,p),solve(dep+1,q))
      |                                                            ^
      |                                                            ;
   19 |  }      else return max(solve(dep+1,p),solve(dep+1,q));
      |  ~                                                          
answer.code: At global scope:
answer.code:19:9: error: expected unqualified-id before ‘else’
   19 |  }      else return max(solve(dep+1,p),solve(dep+1,q));
      |         ^~~~
answer.code: In function ‘int main()’:
answer.code:24:46: error: ‘v’ was not declared in this scope
   24 |         for(long long i=1;i<=n;i++) {cin>>x; v.push_back(x); s+=x;}
      |                                              ^
answer.code: In function ‘long long int solve(long long int, std::vector<long long int>)’:
answer.code:19:2: warning: control reaches end of non-void function [-Wreturn-type]
   19 |  }      else return max(solve(dep+1,p),solve(dep+1,q));
      |  ^