update
This commit is contained in:
parent
d3292ba39e
commit
3cd3abd251
2
.gitignore
vendored
2
.gitignore
vendored
@ -50,3 +50,5 @@ day4/U287193/chat
|
||||
day4/U461920/fixed
|
||||
day5/hard/hard
|
||||
day5/perfect/perfect
|
||||
day5/good/good
|
||||
day5/fair/fair
|
||||
|
22
README.md
22
README.md
@ -44,7 +44,27 @@ int main(){
|
||||
|
||||
## Day5
|
||||
### 需要学习的点
|
||||
>区间最值
|
||||
#### 区间最值
|
||||
#### 弄懂分数取模出现很大的数字是什么鬼、
|
||||
1. >费马小定理
|
||||
2. >逆元
|
||||
```cpp
|
||||
// a/b%M
|
||||
ll _ksm(ll a, ll b,ll M){
|
||||
ll res = 1;
|
||||
while(b) {
|
||||
if(b & 1)
|
||||
res = res * a % M;
|
||||
a = a * a % M;
|
||||
b >>= 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ll ksm(ll a,ll b,ll M){
|
||||
return a * _ksm(b, M - 2,M) % M;
|
||||
}
|
||||
```
|
||||
|
||||
# 排序
|
||||
## 稳定性
|
||||
|
55
day5/fair/fair.cpp
Normal file
55
day5/fair/fair.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#ifdef DEBUG
|
||||
#define PRINT_VALUE(v){cout<<#v<<" :"<<(v)<<endl;}
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG
|
||||
#define PRINT_VALUE(v)
|
||||
#endif
|
||||
|
||||
#define ll long long
|
||||
#define int long long
|
||||
|
||||
ll _ksm(ll a, ll b,ll M){
|
||||
ll res = 1;
|
||||
while(b) {
|
||||
if(b & 1)
|
||||
res = res * a % M;
|
||||
a = a * a % M;
|
||||
b >>= 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ll ksm(ll a,ll b,ll M){
|
||||
return a * _ksm(b, M - 2,M) % M;
|
||||
}
|
||||
|
||||
int n,k,m,times=1,b;
|
||||
|
||||
signed main(){
|
||||
cin>>n>>k>>m;
|
||||
b=k;
|
||||
/*
|
||||
x=k+x/b
|
||||
bx=k*b+x
|
||||
(b-1)x=k*b
|
||||
x=(k*b)/(b-1)
|
||||
*/
|
||||
PRINT_VALUE(b);
|
||||
PRINT_VALUE(n);
|
||||
PRINT_VALUE(b<n);
|
||||
while(b<n){
|
||||
PRINT_VALUE(b<n);
|
||||
PRINT_VALUE(b*k);
|
||||
b=b*k;
|
||||
times++;
|
||||
PRINT_VALUE(times);
|
||||
}
|
||||
PRINT_VALUE(k);
|
||||
PRINT_VALUE(b);
|
||||
PRINT_VALUE(ksm(k*b,b-1,m));
|
||||
cout<<ksm(k*b,b-1,m)<<endl;
|
||||
}
|
Loading…
Reference in New Issue
Block a user