8/29/2011
f(N) counts number of '1'. For example f(13) = 6. So f(1)=1. What next number do satisfy the rule?
f(N) counts number of '1'. For example f(13) = 6. So f(1)=1. What next number do satisfy the rule?
---------------------------------------------------
양수 n에 대해서 1과 n 사이에 1이 나오는 횟수를 나타내는 함수를 f(n)이라고 한다. 예를 들어 f(13)=6이다. f(n)=n이 되는 첫번째 양수는 1이다. 두번째 양수는 무엇인가?
Subscribe to:
Post Comments (Atom)
-
fig 1. Left: set 4 points (Left Top, Right Top, Right Bottom, Left Bottom), right:warped image to (0,0) (300,0), (300,300), (0,300) Fi...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv rgb converting example code. refer to this page -> http://feel...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
EMD(earth mover distance) method is very good method to compare image similarity. But processing time is slow. For using the EMD compare, ...
-
Created Date : 2011.8 Language : Matlab Tool : Matlab 2010 Library & Utilized : - Reference : Multiple View Geometry (Hartly and Z...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
As you can see in the following video, I created a class that stitching n cameras in real time. https://www.youtube.com/user/feelmare/sear...
-
To install the language pack for vs 2013, it made things worse. The error message "window program compatibility mode is on. turn i...
-
refer to this code: . # If you want to combine a Vision Transformer (ViT) as an encoder with a Transformer-based decoder, # you can follow t...
-
error: . VanillaPipeline.get_train_loss_dict: 12.6875 Traceback (most recent call last): File "/home/mare/anaconda3...
This is my code.
ReplyDeleteLet's compare to each code.
Bye Bye~ ^^
int CountOne(int input)
{
int count =0;
while(1)
{
if( input%10 == 1)
count++;
input = input/10;
if(input == 0)
break;
}
return count;
}
int main()
{
int i=2;
int count=1;
while(1)
{
count += CountOne(i);
if( i == count)
break;
i=i+1;
}
printf("f(%d) = %d\n", i, count);
return 0;
}
JeKang's code:
ReplyDelete#include
void main()
{
unsigned long Num, End, Temp;
Num=0;
End=0;
while(Num<=1 || Num!=End){
Num+=1;
Temp=Num;
while(Temp!=0){
if(Temp%10==1) End+=1;
Temp=(unsigned long)(Temp/10);
}
}
printf("입력값 Num = %d\n결과값 End = %d\n",Num,End);
}
제강아 소스 잘 짰네..
ReplyDelete내가 볼때는, while문 조건이 조금 복잡해서 나중에 보면 이해가 쉽게 안갈 것 같고..
while문 안에 while문은 특정 일만 하니깐 함수로 만들면 소스가 더 간결해 질 것 같다.
잘했네..
Good job~!!
JeKang :
ReplyDelete네 함수로도 만들어 볼께요. 감사합니다~
민현규
ReplyDelete#include
#include
int fun(char* a);
void main()
{
int d;
int p=0;
int i=0;
char a[20]={0,};
printf("숫자입력하세요:");
scanf("%d",&d);
for(i=0;i<=d;i++)
{
itoa(i,a,10);
p=p+fun(a);
if(p==i)
printf("%d\n",p);
}
}
int fun(char* a)
{
int i=0;
int count=0;
for(i=0;i<= 20 ;i++)
{
if(a[i]=='1') count+=1;
}
return count;
}