Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Clojure
- web
- c++
- design pattern
- Observer
- Functional
- sprintf
- type_traits
- AES
- kotlin
- async
- Reflect
- template
- SHA1
- ChromeTab
- ranges
- sha256
- go
- Chrono
- haskell
- traits
- RAII
- Scala
- program
- coroutines
- WebView
- stringprintf
- Android
- CustomTab
- SHA512
Archives
- Today
- Total
프로그래밍 검색 블로그
템플릿 메타 프로그래밍 최대공약수 최대공배수 본문
최대공약수
1 2 3 4 5 6 7 8 | template<unsigned long long L, unsigned long long R> struct gcd{ static const unsigned long long value = gcd<R, L % R>::value; }; template<unsigned long long L> struct gcd<L, 0LL>{ static const unsigned long long value = L; }; | cs |
최소공배수
1 2 3 4 5 | template<unsigned long long L, unsigned long long R> struct lcm{ static const unsigned long long value = (L * R) / gcd<L,R>::value; }; | cs |
테스트
1 2 3 4 5 6 | #include <iostream> using namespace std; int main(){ cout << gcd<12,36>::value<<endl; cout << lcm<12,36>::value<<endl; } | cs |
'연습장' 카테고리의 다른 글
함수형 피타고라스 삼각형 구하기 (0) | 2017.10.14 |
---|---|
템플릿 메타 프로그래밍 소수 구하기 (0) | 2017.10.06 |
템플릿 메타 프로그래밍 피보나치 (0) | 2017.10.05 |
템플릿 메타 프로그래밍 binary (0) | 2017.10.05 |
템플릿 메타 프로그래밍 팩토리얼 (0) | 2017.10.05 |
Comments