HDU 2522 求助?
我练习的代码如下:#include<iostream>
using namespace std;
#include<vector>
#include<map>
map<int,int>mp;
vector<int> v;
vector<int>::iterator v1;
int main()
{
int n,m,i,j,k,t;
cin >>t;
while(t--)
{
mp.clear();
v.clear();
cin >> m;
if(m ==1||m==-1)
{cout<<m<<endl;continue;}
if(m<0)
{cout<<'-';m = -m;}
cout<<"0.";
n = 1; j = 0;
while(n<m){n *= 10;j++;}
for(int x = 1; x < j; x++)
cout<<'0';
while(1)
{
k = n/m;
n %= m;
if(mp.find(n) != mp.end())
{if(mp[n] != k)
v.push_back(k);
break;}
v.push_back(k);
if(n == 0) break;
mp[n] = k;
n *= 10; j = 0;
while(n<m){n*=10;j++;}
for(int x =0; x < j; x++)
v.push_back(0);
}
for(v1 = v.begin(); v1 != v.end();v1++)
cout<<*v1;
cout<<endl;
}
}但是每回提交都WA 到底哪错了呢?请高手指教。