Skip to content

Instantly share code, notes, and snippets.

@niklasjang
Created April 18, 2020 03:24
Show Gist options
  • Select an option

  • Save niklasjang/4cccddf19bb75caaa0e9ea57cf330f6a to your computer and use it in GitHub Desktop.

Select an option

Save niklasjang/4cccddf19bb75caaa0e9ea57cf330f6a to your computer and use it in GitHub Desktop.
[PS][정수론]/[BOJ][17466][n! mod p]
#include <iostream>
using namespace std;
int n, p;
long long ans = 1;
int main(void) {
cin.tie(NULL);
ios::sync_with_stdio("false");
cin >> n >> p;
for (int i = 1; i <= n; i++) {
ans *= i;
ans %= p;
}
cout << ans << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment