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 | 29 |
| 30 |
Tags
- web
- WebView
- Android
- AES
- Chrono
- c++
- CustomTab
- SHA512
- Scala
- ranges
- stringprintf
- design pattern
- type_traits
- kotlin
- ChromeTab
- RAII
- Observer
- sha256
- Reflect
- template
- go
- haskell
- async
- coroutines
- SHA1
- program
- sprintf
- Clojure
- Functional
- traits
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