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?为什么老是wrong answer呢 测试数据都过了啊。 答案输入需要是字符串吗,我是一位一位输出整数。 // sxmatchACM.cpp : Defines the entry point for the console application. // #include <iostream> #include <string> #include <vector> using namespace std; static int finalfloat=0; static bool purefloat=false; vector<int> computer(string a,int b){ vector<int> v1; vector<int> v2; vector<int> result; string::iterator ite1 = a.end(); string::iterator ite = a.begin(); int temp=0; int floatcountTemp=0; ite1--; while(true){ if(*ite==46){ purefloat=true; break; } if(*ite-48==0&&*(ite+1)==48) { ite=ite+1; if(ite==ite1) { result.push_back(0); return result; } } if(*ite-48==0&&*(ite+1)!=48&&*(ite+1)!=46) { ite=ite+1; break; } if(*ite-48==0&&*(ite+1)==46){ while(true) { if(*ite1-48==0){ ite1--; }else if(*ite1-48!=0){ purefloat=true; break; } if(*ite1==46) { result.push_back(0); return result; } } break; } if(*ite!=48) break; } int isPlot=a.find("."); while(isPlot>=0&&isPlot<a.length()) { if(*ite1-48==0){ ite1--; }else if(*ite1-48!=0){ break; } } while(true){ if(*ite1-48==-2){ finalfloat=floatcountTemp*b; if(ite1==ite) break; ite1--; continue; } floatcountTemp++; v1.push_back((*ite1-48)); // cout<<(*ite1-48)<<endl; if(ite1==ite) break; ite1--; } v2=v1; while((b-1)>0) { vector<int>::iterator ite2=v1.begin(); vector<int>::iterator ite3=v1.end(); vector<int> tempV; int count1=1; int number=0; while(true) { vector<int>::iterator ite4=v2.begin(); vector<int>::iterator ite5=v2.end(); while(true) { int temp1=(*ite2)*(*ite4); if(count1==1){ tempV.push_back(temp1%10+temp); temp=temp1/10; }else{ // cout<<"number is "<<number<<endl; int temp2=(tempV[number]+temp1%10+temp); tempV[number]=temp2%10; temp=temp1/10+temp2/10; number++; } ite4++; if(ite4==ite5) break; } number=count1; tempV.push_back(temp); count1++; ite2++; temp=0; if(ite2==ite3) break; } v2=tempV; temp=0; b--; } vector<int>::iterator v2end=v2.end(); while(true) { if(*(v2end-1)==0&&*(v2end-2)!=0){ v2.pop_back(); break; } if(*(v2end-1)==0&&*(v2end-2)==0){ v2.pop_back(); v2end=v2.end(); } if(*(v2end-1)!=0) break; } return v2; } int main(int argc, char* argv[]) { string a; int b; while(cin>>a>>b) { if(b<=0||b>25) { // cout<<"you put the second number is not vaild.(0,25] is ok,please input the number again"<<"\n"; }else{ break; } } vector<int> finalResult=computer(a,b); vector<int>::iterator ite1=finalResult.begin(); vector<int>::iterator ite2=finalResult.end(); int length =finalResult.size(); ite2--; int count1=0; if(purefloat){ cout<<"."; for(int i=0;i<finalfloat-length;i++) cout<<0; } while(true) { cout<<(*ite2); count1++; if(ite2==ite1){ cout<<endl; break; } if(!purefloat&&count1==length-finalfloat) cout<<"."; if(--ite2==ite1) { cout<<*ite2<<endl; break; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator