2017.10.18离线赛总结

wireless ——4121

思路:强模拟…考试时还有点虚了…

road ——4122

思路:从t倒着dfs一遍到s,标记经过的点,再判断这些点是否满足题意,最后最短路跑一下…

equation ——4123

思路:一看到a的范围还有的懵逼了,但仔细一想,只要满足这个式子的和为0,且运算中只有‘+’和‘*’,并没有‘/’,那就果断可以mod,即边读边mod,暴力O(n*m),然而这样还是要被卡掉了,正解应该是多来几个质数去mod,才不容易被卡掉(人品)。

#include<bits/stdc++.h>
#define REP(i,f,t) for(int i=(f),i##_end_=(t);i<=i##_end_;i++)
#define DREP(i,f,t) for(int i=(f),i##_end_=(t);i>=i##_end_;i--)
#define LL long long
#define N 105
#define M 1000005 
#define Mod 1000000007
using namespace std;
int n,m;
int Ans[M];

struct p30{
    int A[N];
    bool check(int x){
        LL res=1LL*A[n]*x;
        DREP(i,n-1,1)res+=A[i],res*=x;
        res+=A[0];
        return !res;
    }
    void solve(){
        int cnt=0;
        REP(i,0,n)scanf("%d",&A[i]);
        REP(i,1,m)if(check(i))Ans[++cnt]=i;
        printf("%d\n",cnt);
        REP(i,1,cnt)printf("%d\n",Ans[i]);
    }
}p30;
struct p70{
    LL A[N];
    LL Rd(){
        LL res=0,f=1;char c;
        while((c=getchar())<48)if(c=='-')f=-1;
        do res=(res<<1)+(res<<3)+(c^48),res%=Mod;
        while((c=getchar())>47);
        return res*f;
    }
    bool check(int x){
        LL res=0;
        DREP(i,n,0)res=res*1LL*x+A[i],res%=Mod;
        return !res;
    }
    void solve(){
        int cnt=0;
        REP(i,0,n)A[i]=Rd();
        REP(i,1,m)if(check(i))Ans[++cnt]=i;
        printf("%d\n",cnt);
        REP(i,1,cnt)printf("%d\n",Ans[i]);
    }
}p70;
struct p100{
    char s[10005];
    int A[N][5],cnt;
    bool mark[100005][5];
    int p[5]={10007,10917,30071};
    bool calc(int x, int j){  
        LL res=0;  
        DREP(i,n,0)res=(res*x+A[i][j])%p[j];  
        return res!=0;  
    }  
    void solve(){
        REP(i,0,n){  
            scanf("%s",s); 
            int len=strlen(s),f=1;  
            REP(l,0,len-1){  
                if(s[l]=='-'){f=-1;continue;} 
                REP(j,0,2)A[i][j]=(A[i][j]*10+s[l]-'0')%p[j];    
            }  
            if(f==-1)REP(j,0,2)A[i][j]=p[j]-A[i][j];
        }  
        REP(j,0,2) 
            REP(i,0,p[j]-1)
                mark[i][j]=calc(i,j);  
        REP(i,1,m){  
            bool flag=1; 
            REP(j,0,2)
            if(mark[i%p[j]][j]){  
                flag=0; 
                break;  
            }  
            if(flag)Ans[++cnt]=i;  
        }  
        printf("%d\n", cnt);  
        REP(i,1,cnt)printf("%d\n",Ans[i]); 
    }
}p100;
int main(){
//  freopen("equation.in","r",stdin);
//  freopen("equation.out","w",stdout);
    scanf("%d%d",&n,&m);
    if(n<=2)p30.solve();
    else if(m<=10000)p70.solve();
    else p100.solve();
    return 0;
}

小结:今天考得还可以,没有犯低级错误了,该切分的也切了,希望要再接再厉!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值