U E D R , A S I H C RSS

Smith Numbers/김태진


#include <iostream>
#include <stdio.h>
int main(int argc, const char * argv[])
{
	int i,j,n,N,l,save,sum,ssum,k=0;
//	int arr[100];
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&N);
		for(l=N+1;;l++){
			save=l;
			while(l!=0){
				ssum+=l%10;
				l/=10;
			}
			l=save;
			for(j=2;l!=1;j++){
				if(l%j==0){
					k=j;
					while(k!=0){
						sum+=k%10;
						k/=10;
					}
					l/=j;
					j--;
				}
			}
			if(sum==ssum){
				printf("%d\n",save);
				break;
			}
			sum=ssum=0;
		}
	}
	return 0;
}


  • 푼거같지만 사실 타임리밋 -
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:03
Processing time 0.0086 sec