목록분할정복 (3)
레야몬
#include #define MAX_VERTEX 100001 using namespace std; int Index[MAX_VERTEX]; int io[MAX_VERTEX], po[MAX_VERTEX]; int n; void f(int io_left, int io_right, int po_left, int po_right) { if(io_left > io_right) return; int rootIndex = Index[po[po_right]]; int ls = rootIndex - io_left; cout po[i]; f(1, n, 1, n); return 0; } ㅈㄹ 어렵다.. 나에겐 아직 골드2는 버거운건가 참고한 사이트는 아래에 있다. 오랫만에 주석을 안적었는데.ㅠㅠ https://salgur..
#include using namespace std; typedef unsigned long long int lld; lld a, b, c; //A를 B번 곱한 수를 C로 나눈 나머지 lld f(int n) { lld ret; if(n==1) return a; else { lld tmp = f(n/2)%c; ret = tmp*tmp%c; //분할 정복하기 if(n%2) //2로 나눴을 때 나머지가 있으면 a를 한 번 더 곱해야 함 ret=(ret*(a%c))%c; return ret; } } int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); cin >> a >> b >> c; a%=c; cout