QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#867586#2934. How Many Unicycles in a Broken WheelLaVuna47#AC ✓92ms3840kbC++201.9kb2025-01-23 19:50:262025-01-23 19:50:27

Judging History

This is the latest submission verdict.

  • [2025-01-23 19:50:27]
  • Judged
  • Verdict: AC
  • Time: 92ms
  • Memory: 3840kb
  • [2025-01-23 19:50:26]
  • Submitted

answer

//A tree without skin will surely die.
//A man without face is invincible.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif


ll MOD=100007;

const ll MAX_N=5e3;
ll dp[MAX_N][2];

ll add(ll a, ll b)
{
	return (a+b)%MOD;
}

// 0 0 1 5 19 65 210 654 1985
int solve()
{
	ll n;
	if(!(cin>>n))return 1;
	dp[2][0]=2;
	dp[3][0]=3;

	dp[2][1]=0;
	dp[3][1]=1;
	
	FOR(i,4,n+1)
	{
		dp[i][0]=2*dp[i-1][0]%MOD;
		FOR(j,2,i-1)dp[i][0]=add(dp[i][0],dp[j][0]);

		dp[i][1]=add(dp[i-1][0],2*dp[i-1][1]);
		FOR(j,2,i-1)dp[i][1]=add(dp[i][1],dp[j][1]);
	}
	cout<<dp[n][1]<<'\n';
	
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

5

output:

19

result:

ok single line: '19'

Test #2:

score: 0
Accepted
time: 9ms
memory: 3584kb

input:

1234

output:

50380

result:

ok single line: '50380'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

3

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 92ms
memory: 3712kb

input:

4000

output:

14774

result:

ok single line: '14774'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

10

output:

5911

result:

ok single line: '5911'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

6

output:

65

result:

ok single line: '65'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

7

output:

210

result:

ok single line: '210'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

8

output:

654

result:

ok single line: '654'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

9

output:

1985

result:

ok single line: '1985'

Test #10:

score: 0
Accepted
time: 4ms
memory: 3584kb

input:

779

output:

59262

result:

ok single line: '59262'

Test #11:

score: 0
Accepted
time: 31ms
memory: 3584kb

input:

2320

output:

14502

result:

ok single line: '14502'

Test #12:

score: 0
Accepted
time: 4ms
memory: 3584kb

input:

768

output:

57480

result:

ok single line: '57480'

Test #13:

score: 0
Accepted
time: 36ms
memory: 3712kb

input:

2471

output:

10444

result:

ok single line: '10444'

Test #14:

score: 0
Accepted
time: 4ms
memory: 3584kb

input:

796

output:

24011

result:

ok single line: '24011'

Test #15:

score: 0
Accepted
time: 88ms
memory: 3840kb

input:

3931

output:

57605

result:

ok single line: '57605'

Test #16:

score: 0
Accepted
time: 36ms
memory: 3840kb

input:

2508

output:

32594

result:

ok single line: '32594'

Test #17:

score: 0
Accepted
time: 55ms
memory: 3712kb

input:

3093

output:

48868

result:

ok single line: '48868'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

138

output:

64281

result:

ok single line: '64281'

Test #19:

score: 0
Accepted
time: 11ms
memory: 3712kb

input:

1367

output:

23969

result:

ok single line: '23969'

Test #20:

score: 0
Accepted
time: 32ms
memory: 3712kb

input:

2335

output:

82476

result:

ok single line: '82476'