#include<iostream>
using namespace std;int main()
{long long ans=0,i,b1=0,b2=1;while(i<4000000){i = b1+b2;if(i%2==0){ans+=i;}b1= b2;b2 = i;} cout<<ans<<endl;return 0;}
结果:4613732
#include<iostream>
using namespace std;int main()
{long long ans=0,i,b1=0,b2=1;while(i<4000000){i = b1+b2;if(i%2==0){ans+=i;}b1= b2;b2 = i;} cout<<ans<<endl;return 0;}
结果:4613732