Created
February 5, 2022 03:36
-
-
Save hjroh0315/bec88c982cbadfcb6b61883a281b59cf to your computer and use it in GitHub Desktop.
분할정복 거듭제곱을 TMP로 구현해 보았습니다. I made divide-and-conquer exponentiation with TMP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| #include<type_traits> | |
| using namespace std; | |
| using ll=long long; | |
| template<ll val> | |
| struct value{ | |
| ll value=val; | |
| }; | |
| template <ll val,ll cur,ll rem> | |
| struct dcpow{}; | |
| template <ll val,ll cur> | |
| struct dcpow<val,cur,0> | |
| :public integral_constant<ll, | |
| dcpow<val,cur/2,(cur/2)%2>::value* | |
| dcpow<val,cur/2,(cur/2)%2>::value> | |
| {}; | |
| template <ll val,ll cur> | |
| struct dcpow<val,cur,1> | |
| :public integral_constant<ll, | |
| dcpow<val,cur/2,(cur/2)%2>::value* | |
| dcpow<val,cur/2,(cur/2)%2>::value | |
| *val> | |
| {}; | |
| template <ll val> | |
| struct dcpow<val,1,1> | |
| :public integral_constant<ll,val> | |
| {}; | |
| template<ll val,ll c> | |
| using dcpow_t=dcpow<val,c,c%2>; | |
| int main() | |
| { | |
| cout<<dcpow_t<2,30>::value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment