8.14 problem solution

T1

A flood problem, but I did not think of life and death, maintaining a lot of useless things, in fact, not too far from positive solution, but they can not think, I corrected the location of each point where after folding, but in fact only turn back turning point update his position makes sense, so only need to be updated to the new position behind useless to point

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #define maxn 3010
 5 #define int long long
 6 using namespace std;
 7 int n,m,l,r;
 8 int d[maxn];
 9 signed main()
10 {
11     //freopen("1.in","r",stdin);
12     //freopen("1W.out","w",stdout);
13     scanf("%lld%lld",&n,&m);  l=0;  r=n;
14     for(int i=1;i<=m;++i)  scanf("%lld",&d[i]);
15     for(int i=1;i<=m;++i)
16     {
17         int len1=d[i]-l,len2=r-d[i];
18         if(len1>=len2)
19         {
20             for(int j=i+1;j<=m;++j)
21             if(d[j]>=d[i]&&d[j]<=r)  d[j]=2*d[i]-d[j];
22             r=d[i];
23         }
24         else
25         {
26             for(int j=i+1;j<=m;++j)
27             if(d[j]>=l&&d[j]<=d[i])  d[j]=2*d[i]-d[j];
28             l=d[i];
29         }
30     }
31     printf("%lld\n",r-l);
32     return 0;
33 }
View Code

T2

$ Exgcd $ examination room and hanging up, write a fake board, of course, it is in fact $ exgcd $ I learned a forgotten time, very embarrassed, of course, no violence enumeration Unfortunately the examination room, that he is of $ exgcd $ , which can not, on the next positive solution, in front of the math, please bring your own pen and paper

First, the original expression for $ {L} \ leq {S * x {\%} M} \ leq {R} $, we can not think that if modulus, i.e. S $ $ find some multiple matches, so at this time is the smallest positive integer constant $ X $ is the desired solution, then we need to consider the case of modulo, followed by reduction of expression and modification of

  ${L}\leq{S*x{\%}M}\leq{R}$

$\Leftrightarrow$

Guess you like

Origin www.cnblogs.com/hzjuruo/p/11366073.html