zoukankan      html  css  js  c++  java
  • Luogu4933 大师

    比较水的DP qwq

    一开始想枚举公差(d), 后来发现直接暴力统计初始化都不用qwq

    (CODE:)

    #include<iostream>
    #include<cstdio>
    #define ll long long
    #define maxn 1001
    #define maxm 40001
    #define z 20000
    using namespace std;
    ll f[maxn][maxm];
    ll ans;
    int c[maxm];
    int h[maxn];
    int qr(){
    	int f=1, x=0;
    	char ch=getchar();
    	for(;!isdigit(ch); ch=getchar()) if(ch=='-') f=-1;
    	for(; isdigit(ch); ch=getchar()) x=x*10+ch-48;
    	return x*f;
    }
    int main(){
    	int n;
    	n=qr();
    	for(int i=1; i<=n; i++)
    		h[i]=qr();
    	for(int i=1; i<=n; i++){
    		ans++;//单个的情况
    		for(int j=1; j<i; j++){
    			f[i][h[i]-h[j]+z]+=f[j][h[i]-h[j]+z]+1;
    			f[i][h[i]-h[j]+z]%=998244353;
    			ans+=f[j][h[i]-h[j]+z]+1;
    			ans%=998244353;
    		}
    	}
    	printf("%lld", ans);
    	return 0;
    }
    
  • 相关阅读:
    day09 文件操作
    深信服二面
    test1
    视频测试
    通过独立按键控制LED灯
    第一个LED灯
    为什么我的递归调用次数和书上的不一样?
    函数指针数组
    虚拟内存
    单元测试
  • 原文地址:https://www.cnblogs.com/pushinl/p/9844789.html
Copyright © 2011-2022 走看看