devLupin / algorithm

PS
1 stars 0 forks source link

수학 #25

Open devLupin opened 1 year ago

devLupin commented 1 year ago

지수법칙


devLupin commented 1 year ago

모듈러 성질


devLupin commented 1 year ago

모듈러 성질 BOJ 응용문제

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int a, b, c;

ll foo(ll y)
{
    if (y == 1) return a % c;
    ll val = foo(y / 2) % c;
    if (y % 2 == 0) return val*val%c;
    return val*val%c*a%c;
}

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> a >> b >> c;
    cout << foo(b);
    return 0;
}
devLupin commented 1 year ago
devLupin commented 1 year ago

조합($nCr$) via next_permutation


const int N=15, R=5;
bool mask[N];

fill(mask + R, mask + N, true);
do {

} while(next_permutation(mask, mask+N);
devLupin commented 1 year ago

중복x, 조합 관련문제