本文共 2000 字,大约阅读时间需要 6 分钟。
#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define pb push_back#define fi first#define se second#define icc(x) (1<<(x))#define lcc(x) (1ll<<(x))#define lowbit(x) (x&-x)#define debug(x) cout<<#x<<"="< < =s;--i)#define mset(g, x) memset(g, x, sizeof(g))using namespace std;typedef long long ll;typedef unsigned long long ull;typedef unsigned int ui;typedef double db;typedef pair pii;typedef pair pll;typedef vector veci;const int mod=(int)1e9+7,inf=0x3fffffff,rx[]={-1,0,1,0},ry[]={ 0,1,0,-1};const ll INF=1ll<<60;const db pi=acos(-1),eps=1e-8;template void rd(T &res){ res = 0; int ch,sign=0; while( (ch=getchar())!='-' && !(ch>='0'&&ch<='9')); if(ch == '-') sign = 1; else res = ch-'0'; while((ch=getchar())>='0'&&ch<='9') res = (res<<3)+(res<<1)+ch-'0'; res = sign?-res:res;}template void rec_pt(T x){ if(!x)return; rec_pt(x/10); putchar(x%10^48);}template void pt(T x){ if(x<0) putchar('-'),x=-x; if(!x)putchar('0'); else rec_pt(x);}template inline void ptn(T x){ pt(x),putchar('\n'); }template inline void Max(T &a,T b){ if(b>a)a=b; }template inline void Min(T &a,T b){ if(b inline T mgcd(T b,T d){ return b?mgcd(d%b,b):d; }//gcd模板,传入的参数必须是用一类型//-------------------------------主代码--------------------------------------//int g[10001000];char sa[10],sb[10];int cmp(int a,int b){ int cnta=0,cntb=0; int ta = a,tb = b; while(ta){ sa[cnta++] = ta%10; ta/=10; } while(tb){ sb[cntb++] = tb%10; tb /= 10; } int flag = 0; cnta--;cntb--; while(cnta>=0 && cntb>=0){ if(sa[cnta] sb[cntb]){ flag = -1; break; } cnta--,cntb--; } if(flag == 0) { if(cnta<0) flag= 1; else flag = -1; } return flag == 1;}int main(){ ll n,m; while(cin>>n>>m){ for(int i=1;i<=n;i++) g[i] = i; sort(g+1,g+1+n,cmp); cout< <
转载于:https://www.cnblogs.com/chenhuan001/p/5917763.html