1 solutions
-
0
核心:(a / b) % p = (a * b ^p-2^ ) % p
#include<bits/stdc++.h> using namespace std; #define ll long long ll n; const ll mod=1e9+7; ll ksm(ll x, ll n){ x %= mod; ll res = 1; while(n > 0){ if(n&1) res = ((res%mod) * (x%mod))%mod; x = ((x%mod) * (x%mod))%mod; n >>= 1; } return res%mod; } int main(){ cin >> n; cout << (ksm(n, mod-2) % mod); return 0; }
Information
- ID
- 1550
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 2
- Tags
- # Submissions
- 20
- Accepted
- 15
- Uploaded By