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

其实这个算法有问题的,比如全是0的情况,然而似乎测试数据没有这东西╮(╯▽╰)╭

Posted by ls2412126 at 2015-11-27 22:19:45 on Problem 1047 and last updated at 2015-11-27 22:28:58
In Reply To:无意间发现简单的算法! Posted by:lovexx at 2006-07-25 23:53:44
用这个代码可以AC,但是00000之类的情况就会判断错误
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main()
{ 
string king; 
 while(cin>>king)
 {

	
  int queen=king.length();
   int temp=0;
   bool res=true;
   int mul=queen+1;
    for (int i=queen-1;i>=0;i--)
     {
	   int result=(king[i]-'0')*mul+temp;
	   int single=result-(result/10)*10;
	   result-=single;
	   
	   if (single!=9)
	    {
		 res=false;
		 break; 
		} 
	  temp=result;
	  temp/=10;
	 }
	 while(temp!=0)
	 {
	  int single=temp%10;
	   if(single!=9)
	    {
	      res=false;
	      break;
	    }
	 temp/=10;
	 }
  
	 if (res)
	cout<<king<<" is cyclic"<<endl;
	 else 
	cout<<king<<" is not cyclic"<<endl;
 }
    
}

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