Codeforces Round #624 (Div. 3)
A.题意:通过加奇数减偶数的操作从a到b最少需要几步 签到题 #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <vector> #include <cmath> #include <queue> #include <deque> #include <map> using namespace std; typedef long long ll; const double inf=1e20; const int maxn=100005; int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++){ ll a,b; scanf("%lld%lld",&a,&b); ll c=b-a; if(c==0){ printf("0\n"); }else if(c>0&&c%2==0){ printf("2\n"); }else if(c<0&&c%2!=0){ printf("2\n"); } else printf("1\n"); } return 0; } B.题意:有一个数组p,你可以任意次交换a[p i ]和a[p i +1],问能不能把数组变成一个非严格上升的子序列。 解:很明显,如果p数组中有连续的一段