# codeforces #299 div 2

2022年11月23日
0 收藏 753 点赞 4,529 浏览 5940 个字

（总算是5题都做完了- -）

A题：

`#include <cstdio>#include <cstring>using namespace std;char str[][] = {"" , "" , "twenty" , "thirty" , "forty" , "fifty" , "sixty" , "seventy" ,"eighty" , "ninety"};char single[][] = {"zero" , "one","two","three","four","five","six","seven","eight","nine"};char dou[][] = {"ten" ,"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};int main(){    int x;    while(~scanf("%d" , &x)){        if(x<){            printf("%s\n" , single[x]);        }        else if(x<){            printf("%s\n" , dou[x%]);        }        else{            int tmp = x%;            printf("%s" , str[x/]);            if(tmp){                printf("-%s" , single[tmp]);            }            printf("\n");        }    }    return ;}`

B题：

`#include <cstdio>#include <cstring>#include <iostream>using namespace std;int dig[];int qpow(int digit){    int a= , b=digit , ans=;    while(b)    {        if(b&) ans*=a;        a*=a;        b>>=;    }    return ans;}int getDigit(int x){    int ans=;    while(x){        x/=;        ans++;    }    return ans;}void getHead(int x , int len){    int  index=len;    while(x){        dig[index--]=x%;        x/=;    }}int main(){    int n;    while(~scanf("%d" , &n))    {        int len = getDigit(n);        int ans=;        for(int i= ; i<=len- ; i++)            ans+= qpow(i);        if(ans == ) ans-=;        getHead(n , len);        for(int i= ; i<=len ; i++){             //   cout<<dig[i]<<endl;            if(dig[i]>){                ans += qpow(len-i+);                break;            }            else if(dig[i] == ){                ans += qpow(len-i);                if(i == len) ans+=;            }            else if(dig[i]>){                ans += qpow(len-i);                break;            }            else if(dig[i]==){                if(i == len) ans+=;                continue;            }            else break;        }        printf("%d\n" , ans);    }    return ;}`

C题：

`#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;#define N 1000005int l,t,m;int a , b , n;#define ll long longbool check(int mid){    ll cnt = mid-l+;    ll st = a+(ll)(l-)*b , la=(ll)(mid-)*b+a;    if(t>=la && (st+la)*cnt/<=(ll)t*m) return true;    else return false;}int bin_search(){    if(a+(ll)(l-)*b > (ll)t) return -;    int left = l , right = N , ans = l;    while(left<=right)    {        int mid = left+(right-left)/;        if(check(mid)){            left = mid+;            ans = mid;        }else right=mid-;    }    return ans;}int main(){   // freopen("a.in" , "r" , stdin);    while(~scanf("%d%d%d" , &a , &b , &n))    {        for(int i= ; i<=n ; i++){            scanf("%d%d%d" , &l , &t , &m);            printf("%d\n" , bin_search());        }    }    return ;}`

D题：

`#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;#define N 1000005#define ll long longconst int MOD = 1e9+;char str[N];int a[N] , n , m;int r[N] , sa[N] , height[N] , rank[N] , wa[N] , wb[N] , wsf[N] , wv[N];bool vis[N];int cmp(int *r , int a , int b , int l){    return r[a]==r[b] && r[a+l]==r[b+l];}void get_sa(int *r , int *sa , int n , int m){    int *x=wa , *y=wb , *t;    int i,j,p;    for(i= ; i<m ; i++) wsf[i]=;    for(i= ; i<n ; i++) wsf[x[i]=r[i]]++;    for(i= ; i<m ; i++) wsf[i]+=wsf[i-];    for(i=n- ; i>= ; i--) sa[--wsf[x[i]]]=i;    p= ;    for(j= ; p<n ; j*= , m=p){        for(p= , i=n-j ; i<n ; i++) y[p++] = i;        for(i= ; i<n ; i++) if(sa[i]>=j) y[p++]=sa[i]-j;        for(i= ; i<n ; i++) wv[i]=x[y[i]];        for(i= ; i<m ; i++) wsf[i]=;        for(i= ; i<n ; i++) wsf[wv[i]]++;        for(i= ; i<m ; i++) wsf[i]+=wsf[i-];        for(i=n- ; i>= ; i--) sa[--wsf[wv[i]]]=y[i];        t=x , x=y , y=t;        x[sa[]]=;        for(p= , i= ; i<n ; i++)            x[sa[i]] = cmp(y , sa[i-] , sa[i] , j)?p-:p++;    }}void callHeight(int *r , int *sa , int n , int m){    int i , j , k=;    for(i= ; i<=n ; i++) rank[sa[i]]=i;    for(i= ; i<n ; height[rank[i++]]=k)        for(k?k--: , j=sa[rank[i]-] ; r[i+k] == r[j+k] ; k++) ;    return;}void biaoji(int n){    memset(vis ,  , sizeof(vis));    vis[]=true;    int order = ; //记录以开头为起点的排名    for(int i= ; i<=n ; i++){        if(sa[i] == ) order = i;    }    int len=N;    for(int i=order ; i>= ; i--){        int pos = sa[i-];        len = min(len , height[i]);        if(pos+len>=n) vis[pos]=true;    }    len=N;    for(int i=order+ ; i<=n ; i++){        int pos = sa[i];        len = min(len , height[i]);        if(pos+len>=n) vis[pos]=true;    }}int qpow(int cnt){    if(!cnt) return ;    ll ans =  , a =  ;    while(cnt)    {        if(cnt&) ans = (ans*a)%MOD;        a = (a*a)%MOD;        cnt>>=;    }    return (int)ans;}int main(){   // freopen("a.in" , "r" , stdin);    while(~scanf("%d%d" , &n , &m))    {        scanf("%s" , str);        for(int i= ; i<m ; i++) scanf("%d" , a+i);        sort(a , a+m);        int len = strlen(str);        for(int i= ; i<len ; i++){            r[i] = (int)str[i];        }        r[len]=;        get_sa(r , sa , len+ , );        callHeight(r , sa , len , );        biaoji(len);        int cnt = a[]-;        bool flag = true;        for(int i= ; i<m ; i++){            int dis = a[i]-a[i-];            if(dis>=len){                cnt+=dis-len;            }else{                if(!vis[dis]) {                  //  cout<<i<<" "<<dis<<endl;                    flag = false;                    break;                }            }        }        cnt+=n+-a[m-]-len;        int ans;        if(!flag){         //   cout<<"exist "<<endl;            ans = ;        }        else if(m == ){            ans = qpow(n);        }        else{               // cout<<"no "<<endl;            if(cnt)                ans = qpow(cnt);            else ans=;        }        printf("%d\n" , ans);    }    return ;}`

E题:

t1=x/1+y/3

t2=x/2+y/2

t3=x/3+y/1

2号能夺冠，那么t2<=t1 && t2<=t3

t2<=t1-> x/y>=(1/2-1/3)/(1/1-1/2) = 1/3

t2<=t3 -> x/y<=(1/1-1/2)/(1/2-1/3) = 3/1

` #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> #include <string> #include <set> #include <map> using namespace std; #define N 10000 #define ll long long #define eps 1e-9 int run[N*+]; //游泳速度为i的人中跑步速度最快达到run[i] struct Ath{     int s , r;     Ath(int s= , int r=):s(s),r(r){} }ath[N*+]; int k , s[N*+] , r[N*+]; bool can_win(int s1 , int r1 , int s2 , int r2 , int s3 , int r3) {     //s1<s2<s3 , r1>r2>r3 , 判断s2,r2在包夹下能否有机会夺冠     double t1 = (1.0/r2-1.0/r1) / (1.0/s1-1.0/s2);     double t2 = (1.0/r3-1.0/r2) / (1.0/s2-1.0/s3);   //  cout<<t1<<" "<<t2<<endl;     if(t2-t1>=-eps) return true;     else return false; } int main() {   //  freopen("a.in" , "r" , stdin);     int n;     while(~scanf("%d" , &n))     {         memset(run ,  , sizeof(run));         for(int i= ; i<=n ; i++){             scanf("%d%d" , &s[i] , &r[i]);             run[s[i]] = max(run[s[i]] , r[i]);         }         k=;         int i;         for(i=N ; i>= ; i--){             if(run[i]){                 ath[k++] = Ath(i , run[i]);                 break;             }         }         for(i=i- ; i>= ; i--){             run[i] = max(run[i] , run[i+]);             if(run[i] > run[i+]){                 while(k>){                     if(!can_win(i , run[i] , ath[k-].s , ath[k-].r , ath[k-].s , ath[k-].r)){                         k--;                     }else                         break;                 }                 ath[k++] = Ath(i , run[i]);             }         }         map<int , int> m;         for(int i= ; i<k ; i++){             m[ath[i].s] = ath[i].r;         }         bool flag=true;         for(int i= ; i<=n ; i++){             if(m[s[i]] == r[i]){                 if(flag) printf("%d" , i);                 else printf(" %d" , i);                 flag = false;             }         }         puts("");     }     return ; }`

python开发_常用的python模块及安装方法

Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接：http://www.codeforces.com/contest/660/problem/CDes…

zengkefu@server1:/usr/src\$ uname -aLinux server1 4.10.0-19-generic #21…

Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式，并且由于涉及到要把拍到的照片显…

Struts的使用