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

用cin超时 改成scanf后ac 内存5956k 用时2938ms 没用算法 硬想的办法 附代码

Posted by gjl87910lq at 2009-05-11 16:56:43 on Problem 2406
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    char str[1000005];
    while(scanf("%s",str))
    {
        string s;
        s=str;
        if(s==".") break;

        string c="";
        for(int i=0;i<s.size();i++)
        {
            string a="";

            c+=s[i];
            if(s.size()%c.size()!=0) continue;

            int temp=s.size()/c.size();


            for(int j=1;j<=temp;j++)
            {
                a+=c;
            }

            if(a==s)
            {
                cout<<temp<<endl;
                break;
            }
        }


    }



    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