unordered_map:
如果直接写报错加上tr1:
1 #include<tr1/unordered_map>//注意写法
2 using namespace std;
3 using namespace std::tr1;//注意写法
std::unorederd_map 是一个关联容器,其中的元素根据键来引用,而不是根据索引来引用。
1 #include <iostream> 2 #include <algorithm> 3 #include <queue> 4 #include <cstdio> 5 #include<tr1/unordered_map>//注意写法 6 using namespace std; 7 using namespace std::tr1;//注意写法 8 int a,b,c; 9 10 int main() 11 { 12 int n; 13 while(~scanf("%d",&n)) 14 { 15 int cnt=0; 16 int cntc=0; 17 unordered_map<int,int> mp; 18 for(int i=1;i*i<=n;i++) 19 { 20 int t=i*i; 21 if(mp.count(t)==0) 22 mp[t]=i; 23 } 24 for(int i=1;i*i<=n;i++) 25 { 26 for(int j=1;j*j<=n;j++) 27 { 28 int t=n-i*i-j*j; 29 if(mp.count(t)&&i<=j&&j<=mp[t]) 30 { 31 cnt++; 32 printf("%d %d %d\n",i,j,mp[t]); 33 } 34 } 35 } 36 if(cnt==0) 37 { 38 printf("No Solution\n"); 39 } 40 } 41 return 0; 42 }