NOIP2017金秋冲刺训练营杯联赛模拟大奖赛第一轮Day1

 

T1 天天去哪儿吃

直接枚举

#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100001
int d[N<<1];
bool g[N];
int main()
{
    int n,m;
    long long a,b;
    scanf("%d%d%lld%lld",&n,&m,&a,&b);
    scanf("%d%d",&d[1],&d[2]);
    int now;
    int len=n/2;
    for(int i=2;i>=max(3-len,1);i--) g[d[i]]=true;
    for(int i=3;i<=m;i++)
    {
        now=(a*d[i-1]+b*d[i-2])%n;
        while(g[now]) 
        {
            now++;
            if(now==n) now=0;
        }
        d[i]=now;
        if(i-len>0) g[d[i-len]]=false;
        g[now]=true;
    }
    for(int i=3;i<=m;i++) printf("%d ",d[i]);
}
View Code

相关文章:

  • 2022-01-10
  • 2022-02-02
  • 2021-11-27
  • 2021-11-08
  • 2021-10-11
  • 2022-02-04
  • 2021-08-09
  • 2021-08-22
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-10-24
  • 2021-12-12
  • 2021-10-05
  • 2021-10-02
  • 2021-11-11
相关资源
相似解决方案