$tsinsenA1067$

\(problem\)

这种题目需要一个定理
\(a[1]+a[2]+a[3]+a[4]...=(a[1]%mod)+...\) 本人出奇的懒
然后 动态规划?(恰似枚举)

#include <bits/stdc++.h>
using namespace std ;
typedef long long LL ;
const int N = 10000 + 10 ;
LL s , t ;
LL d[4];
LL dp[N][4] ;
signed main() {
    ios::sync_with_stdio(false) ; memset(dp,0,sizeof(dp)) ;
    cin >> s >> t ;
    for(register int i=1;i<=4;i++) cin >> d[i] ;
    for(register int i=1;i<=4;i++) dp[1][i] = dp[2][i] = 1%d[i] ;
    for(register int i=2;i<=N;i++) 
        for(register int j=1;j<=4;j++) dp[i][j] = (dp[i-1][j] + dp[i-2][j]) % d[j] ;
    #ifdef debug
        for(register int i=s;i<=t;i++){
            for(register int j=1;j<=4;j++) cout << dp[i][j] <<' ' ;
            cout << endl ;
        }
    #endif
    for(register int i=s;i<=t;i++){
        bool f = false ;
        for(register int j=1;j<=4;j++) if(dp[i][j] == 0) f = true ;
        if(!f) cout << i << ' ' ;
    }
    return 0 ;
}

猜你喜欢

转载自www.cnblogs.com/qf-breeze/p/10549551.html
今日推荐