1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
int main(void) {
    int ref, num, cycle=0;
    cin >> num;
    ref = num;
    
    while(true) {
        if(num < 10) {
            num = num*10 + num;
        } else {
            num = (num%10)*10 + (num%10 + num/10)%10;
        }
        cycle++;
        
        if(num == ref)
            break;
    }
    
    cout << cycle << endl;
    
    return 0;
}
cs

'C & C++ > Baekjoon' 카테고리의 다른 글

백준 1157 - 단어 공부  (0) 2017.12.27
백준 1152 - 단어의 개수  (0) 2017.12.27
백준 1065 - 한수  (0) 2017.12.27
백준 1008 - A/B  (0) 2017.12.27
백준 1003 - 피보나치 함수  (0) 2017.12.27



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
 
using namespace std;
 
bool isHan(int n) {
    int a, b, c;
    
    if(n < 100)
        return true;
    a = n/100;
    b = (n%100)/10;
    c = n%10;
    
    if(a-== b-c)
        return true;
    else
        return false;
}
 
int main(void) {
    int N, result=0;
    cin >> N;
    
    for(int i=1; i<=N; i++) {
        if(isHan(i))
            result++;
    }
    cout << result;
    
    return 0;
}
cs

'C & C++ > Baekjoon' 카테고리의 다른 글

백준 1152 - 단어의 개수  (0) 2017.12.27
백준 1110 - 더하기 사이클  (0) 2017.12.27
백준 1008 - A/B  (0) 2017.12.27
백준 1003 - 피보나치 함수  (0) 2017.12.27
백준 1001 - A-B  (0) 2017.12.27



1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <stdio.h>
 
int main(void){
    double x, y;
    double result;
    
    scanf("%lf %lf"&x, &y);
    result = x/y;
    printf("%.9lf\n", result);
    
    return 0;
}
cs

'C & C++ > Baekjoon' 카테고리의 다른 글

백준 1110 - 더하기 사이클  (0) 2017.12.27
백준 1065 - 한수  (0) 2017.12.27
백준 1003 - 피보나치 함수  (0) 2017.12.27
백준 1001 - A-B  (0) 2017.12.27
백준 1000 - A+B  (0) 2017.12.27


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
 
using namespace std;
 
int cnt0, cnt1;
 
int fibonacci(int n) {
    if (n==0) {
        cnt0++;
        return 0;
    } else if (n==1) {
        cnt1++;
        return 1;
    } else {
        return fibonacci(n-1+ fibonacci(n-2);
    }
}
 
int main(int argc, char *argv[]) {
    int T, N;
    
    cin >> T;
    
    for(int t_case=0; t_case < T; t_case++) {
        cnt0 = 0;
        cnt1 = 0;
        cin >> N;
        fibonacci(N);
        cout << cnt0 << " " << cnt1 << endl;
    }
}
cs

'C & C++ > Baekjoon' 카테고리의 다른 글

백준 1110 - 더하기 사이클  (0) 2017.12.27
백준 1065 - 한수  (0) 2017.12.27
백준 1008 - A/B  (0) 2017.12.27
백준 1001 - A-B  (0) 2017.12.27
백준 1000 - A+B  (0) 2017.12.27


1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
 
int main(void) {
    int a, b;
    
    scanf("%d %d"&a, &b);
    printf("%d\n", a-b);
    
    return 0;
}
cs

'C & C++ > Baekjoon' 카테고리의 다른 글

백준 1110 - 더하기 사이클  (0) 2017.12.27
백준 1065 - 한수  (0) 2017.12.27
백준 1008 - A/B  (0) 2017.12.27
백준 1003 - 피보나치 함수  (0) 2017.12.27
백준 1000 - A+B  (0) 2017.12.27

+ Recent posts