好题分享0

P2141 [NOIP2014 普及组] 珠心算测验

原题链接 : 

[NOIP2014 普及组] 珠心算测验 - 洛谷

思路 : 

用哈希表来存出现过的两数之和,最后ans++即可

代码 : 

#include
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

using namespace std;
typedef long long LL;
int gcd(int a,int b){ return b==0 ? a : gcd(b,a%b); }
int lcm(int a,int b){ if(a==0||b==0) return 0; return (a*b)/gcd(a,b); }
bool is_prime(int x){if(x<2) return false;
for(int i=2;i<=x/i;i++) if(x%i==0) return false; return true;}
//numbers.erase(unique(numbers.begin(), numbers.end()), numbers.end()); // 去重操作
const int N = 2e5+10;
int n;
vector a;
map mp;
inline void solve(){
	cin>>n;
	for(int i=0;i>x;
		a.push_back(x);
	}
	a.erase(unique(a.begin(), a.end()), a.end());
	for(int i=0;i> _;
    _ = 1; 
    while(_ --) solve();
    return 0;
}

你可能感兴趣的:(洛谷,算法学习,算法,数据结构)