暑假2018.7.5 1.CodeForces - 705B 2.CodeForces - 702B
---恢复内容开始---
第一题思维题
#include<iostream>
using namespace std;
int main()
{
int n,flag;
long long x;
cin>>n;
flag=0;
while(n--){
cin>>x;
if(x%2==1&&flag==0){
cout<<"2"<<endl;
flag=0;
}
else if(x%2==1&&flag==1){
cout<<"1"<<endl;
flag=1;
}
else if(x%2==0&&flag==0){
cout<<"1"<<endl;
flag=1;
}
else{
cout<<"2"<<endl;
flag=0;
}
}
return 0;
}//自己写的比网上题解好,以后多思考
#include<bits/stdc++.h>
using namespace std;
map<int,int>powe;
int main(){
int n,x,i,j;
cin>>n;
long long sum=0;
for(i=0;i<n;i++){
cin>>x;
for(j=0;j<32;j++){
sum+=powe[(1ll<<j)-x];
}
powe[x]++;
}
cout<<sum;
return 0;
}//这题以前做过,但是又忘记解法,以后多思考才能记的深
---恢复内容结束---