Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <vector>
#include <iostream>
#ifdef WITHGPERFTOOLS
#include <gperftools/profiler.h>
#endif
using namespace std;
int foo(vector<int> v) {
int result = 0;
for(auto x: v) {
result += x;
}
return result % 1000;
}
int main() {
#ifdef WITHGPERFTOOLS
ProfilerStart("profile.log");
#endif
vector<int> v;
v.push_back(1);
int result = 0;
for (int i=0; i<10000; i++) {
result = foo(v);
v.push_back(result);
}
#ifdef WITHGPERFTOOLS
ProfilerStop();
#endif
cout << result << "\n";
return 1;
}