C++算法训练第八天
以下为牛客挑战
今日收获
- 学习到了ksm的写法int ksm(int p,int q,int mod){ int result=1; p=p%mod; while (q>0){ if(q&1){// result=(1ll*result*p)%mod; } q=q>>1; p=(1ll*p*p)%mod; } return result%mod;}知道了滚动数组先有一个数组,然后在操作时候弄一个一样的数组,dp转移完成之后,直接赋值回最先的数组。为了节省空间。练习了一下BFS搜图
复制代码 【算法竞赛知识点-数学】:快速幂_哔哩哔哩_bilibili
牛客周赛 Round 127
(36条未读私信) 牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)
Get The Number
A-Get The Number_牛客周赛 Round 127 (nowcoder.com)
解题代码
[code]#include#define int long long#define lll __uint128_t#define PII pair#define endl '\n'using namespace std;#define yn(ans) printf("%s\n", (ans)?"Yes":"No");//快速打印#define YN(ans) printf("%s\n", (ans)?"YES":"NO");#define REP(i, e) for (int i = 0; i < (e); ++i)#define REP1(i, s, e) for (int i = (s); i > t; while (t--)#define TESTconst int N=2e5+10,M=1e3+10,mod=1e9+7;int a[N],b[N],c[N],pre[N];signed main(){ std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,m,x; cin>>n>>m>>x; if(x==(n+m)||(n-m)==x ||((n/m==x)&&(m*x==n))){ cout |