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

Re:wa 了无数次 郁闷 求高人指点

Posted by 00448144 at 2005-03-30 16:11:25 on Problem 1001
In Reply To:wa 了无数次 郁闷 求高人指点 Posted by:1987 at 2005-03-30 10:49:28
> #include <iostream.h>
> void fun(int,char[]);
> void main()
> {
> 	char a[7]="0";
> 	int b;
> 	while(cin.get(a,7))
> 	{
> 		if(cin.get() == '\n')
> 			return;
> 		cin>>b;
> 		fun(b,a);
> 		while(cin.get() != '\n');
> 	}
> }
> void fun(int b,char a[7])
> {
> 	long e;
> 	int judge;
> 	long d[150];
> 	e=0;
> 	judge=5;
> 	for(int i=0;i<6;i++)
> 		{
> 			if(a[i]!='.')
> 			e=e*10+(a[i]-'0');
> 			else 
> 				judge=i;
> 		}
> 		judge=5-judge;
> 		judge*=b;
> 		
> 		for(i=0;i<149;i++)
> 		d[i]=0;
> 		d[149]=1;
> 	
> 		for(i=0;i<b;i++)
> 		{
> 			for(int k=149;k>=0;k--)	
> 			d[k]=d[k]*e;
> 			for(k=149;k>=0;k--)	
> 			{
> 				if(k>=3)
> 				{
> 					d[k-3]+=d[k]/1000;
> 					d[k]%=1000;
> 				}
> 				if(k>=2)
> 				{
> 					d[k-2]+=d[k]/100;d[k]%=100;
> 				}
> 				if(k>=1)
> 					d[k-1]+=d[k]/10;
> 					d[k]%=10;
> 			}
> 		}
> 		
> 		int m;
> 		for(i=149;i>=0;i--)
> 		{
> 			if(d[i]!=0||judge==0)
> 			{
> 				m=i+1;
> 				break;
> 			}
> 		}
> 		int O=0;
> 	/*	for(int h=0;h<150;h++)
> 			{
> 				cout<<"d["<<h<<"]"<<d[h];
> 			}*/
> 		for(i=0;i<m;i++)
> 		{
> 			if(i==150-judge)
> 			{
> 				cout<<'.';
> 				O=1;
> 			}
> 			if(d[i]!=0||O)
> 			{
> 				O=1;
> 				cout<<d[i];
> 			}
> 		}
> 		cout<<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