??????

小唐唐 · 发布于 2025-12-27 · 浏览 227 回复 1

include <bits/stdc++.h>

using namespace std; typedef long long ll; const ll mod = 99999999;

int main() {

ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n; cin >> n;
if (n == 1) { cout << "2\n3\n"; return 0; }
if (n == 2) { cout << "1\n4\n"; return 0; }
if (n == 3) { cout << "6\n5\n"; return 0; }

// 滚动数组,保存 f(i-2), f(i-1) 两行共四个值
ll f11 = 2, f12 = 3; // i=1
ll f21 = 1, f22 = 4; // i=2
ll f31 = 6, f32 = 5; // i=3

for (ll i = 4; i <= n; ++i) {
    ll next1 = (f22 + 2 * f11 + 5) % mod;
    ll next2 = (f21 + 3 * f11 + 2 * f12 + 3) % mod;
    // 滚动更新
    f11 = f21; f12 = f22;
    f21 = f31; f22 = f32;
    f31 = next1; f32 = next2;
}
cout << f31 << '\n' << f32 << '\n';
return 0;

}

全部回复 共 1 条

  1. 听澜​ #1 ·
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
    	int s=0;
    	int n;
    	cin>>n;
    	int h[4];
    	int v;
    	for(int i=1; i<=n; i++) {
    		cin>>v;
    		h[v%3]++;
    	}
    	s=h[0]/2+min(h[1],h[2]);
    	cout<<s<<endl;
    	return 0;
    }
    
    

发表回复