Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

各位大虾帮我看看哪里错了?

Posted by xiaohao2009 at 2009-05-03 22:17:28 on Problem 2895
#include<iostream>
#include<string>
using namespace std;

int main()
{
    int i,j;
    int t,p,w,time,arr[27]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9,1};
    cin>>t;
    for(j=0;j<t;j++)
    {
                    time=0;
                    string a;
                    cin>>p>>w;
                    cin.seekg(1);
                    getline(cin,a);
                    for(i=0;i<a.size();i++)
                    {
                                           int temp,s,pre;
                                           temp=(int)(a[i]);
                                           if(a[i]==32) { time+=p;continue;}
                                           temp-=65;
                                           if(temp<18) s=temp%3;
                                           else if(temp==18) s=3;
                                           else
                                           {
                                               if(temp==25) s=3;
                                               else 
                                               {
                                                    temp--;
                                                    s=temp%3;
                                               }
                                           }
                                           time+=(s+1)*p;
                                           if(i)
                                           {
                                                pre=(int)(a[i-1]);
                                                if(pre==32) pre=92;
                                                pre-=65;
                                                if(arr[pre]==arr[temp])time+=w;
                                           }
                    }
                    cout<<time<<endl;
    }
    system("pause");
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator