HDU4608+简单题

2014-11-23 19:56:03 · 作者: · 浏览: 9
/*
AC&Simple
*/
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
//typedef __int64 int64;
const int maxn = 110005;
const int inf = 0x7fffffff;
const double pi=acos(-1.0);
const double eps = 1e-8;

char sum[ maxn ];
int First;

void Add( int Index ){
	while( Index>=0 ){
		if( sum[ Index ]>='0'&&sum[ Index ]<='8' ){
			sum[ Index ] ++;
			break;
		}
		else {
			sum[ Index ] = '0';
			Index --;
		}
	}
	if( sum[ 0 ]=='0' ){
		First = 1;
	}
	return ;
}//+1

int GetSum( int Index ){
	int ans  = 0;
	while( Index>
=0 ){ ans += (sum[ Index ]-'0'); Index --; } ans += First; return ans; } int main(){ int T; scanf("%d",&T); while( T-- ){ scanf("%s",sum); First = 0; int Index = strlen( sum )-1; Add( Index ); while( 1 ){ if( GetSum( Index )%10==0 ){ break; } Add( Index ); } if( First==1 ){ printf("1"); } printf("%s\n",sum); } return 0; }