| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Wrong Answer.Why??#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
void main()
{
vector<int> v;
vector<int> input;
int m;
int n;
int jinwei=0;
int up,i,j;
do
{
cin>>m;
input.push_back(m);
}while(m!=-1);
for(int temp=0;temp<input.size()-1;temp++)
{
m=input[temp];
n=m-1;
v.push_back(1);
for(i=2;i<=n;i++)
{
up=0;
int vsize=v.size();
for(j=0;j<vsize;j++)
{
up+=v[j]*i;
v[j]=up%10;
up/=10;
if(up!=0&&j+1==vsize)
{
for(int temp=0;up/10!=0;temp++)
{
v.push_back(up%10);
up/=10;
}
v.push_back(up);
}
}
}
int newline=0;
cout<<"N="<<m<<":"<<endl;
if(v[v.size()-1]>=5)
{
cout<<1;
}
for(i=0;i<v.size();i++)
{
if(jinwei==1)
{
if(v[i]>=5)
{
jinwei=1;
v[i]=v[i]*2-9;
}
else
{
jinwei=0;
v[i]=v[i]*2+1;
}
}
else
{
if(v[i]>=5)
{
jinwei=1;
v[i]=v[i]*2-10;
}
else
{
jinwei=0;
v[i]=v[i]*2;
}
}
}
for(i=v.size()-1;i>=0;i--)
{
cout<<v[i];
}
cout<<endl;
v.clear();
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator