设为首页 加入收藏

TOP

HDU4608+简单题
2014-11-23 19:56:03 来源: 作者: 【 】 浏览:8
Tags:HDU4608 简单
/*
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;
}

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇hdu2572 下一篇TOJ 4224 Cryptologist

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C语言中,“指针”用 (2025-12-26 15:20:18)
·在c语言的指针运算中 (2025-12-26 15:20:15)
·C语言-函数指针与函 (2025-12-26 15:20:12)
·求navicat for mysql (2025-12-26 13:21:33)
·有哪位大哥推荐一下m (2025-12-26 13:21:30)