(UVA)10018-倒數相加
#include<stdio.h> int main(){ int time; scanf("%d", &time); while (time--){ long long num2,num; scanf("%lld", &num); num2 = num; long long count = 0; while (1){ long long re=0; while (num != 0)/*倒數*/ { re = re * 10 + num % 10; num /= 10;} if (re == num2) break; else{ num = num2 + re; /*重設num的值*/ num2 += re; /*暫存num2*/ count++;} } printf("%lld %lld\n", count, num2); } return 0; }
留言
張貼留言