QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#723654#2936. Simple Collatz SequenceBackToSquare1AC ✓1ms4336kbC++201.1kb2024-11-07 23:27:042024-11-07 23:27:06

Judging History

This is the latest submission verdict.

  • [2024-11-07 23:27:06]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 4336kb
  • [2024-11-07 23:27:04]
  • Submitted

answer

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pl;
typedef pair<ld,ld> pd;
typedef vector<ll> vl;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
#define G(x) ll x; cin >> x;
#define F(i, l, r) for (ll i = l; i < (r); ++i)
#define all(a) begin(a), end(a)
#define K first
#define V second
#define OK(i,j) i >= 0 && i < n && j >= 0 && j < m
 
#define NN 2505
#define MM 5005
#define MOD 1000007

ll dp[40005][2];

void solve() {

    dp[0][0] = 0;
    dp[0][1] = 1;
    dp[1][0] = 1;
    dp[1][1] = 0;
    dp[2][0] = 1;
    dp[2][1] = 0;

    for(ll i = 3;i<40005;i++) {
        dp[i][0] = (dp[i-1][0] + dp[i-1][1])%MOD;
        dp[i][1] = dp[i-1][0];

    }

    ll n;
    cin >> n;
    cout << (dp[n][0] + dp[n][1])%MOD << '\n';


}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed << setprecision(10);

    solve();

    return 0;

}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4336kb

input:

6

output:

8

result:

ok single line: '8'

Test #2:

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

input:

12345

output:

540591

result:

ok single line: '540591'

Test #3:

score: 0
Accepted
time: 1ms
memory: 4332kb

input:

1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 4236kb

input:

40000

output:

852282

result:

ok single line: '852282'

Test #5:

score: 0
Accepted
time: 1ms
memory: 4180kb

input:

2148

output:

427120

result:

ok single line: '427120'

Test #6:

score: 0
Accepted
time: 1ms
memory: 4240kb

input:

14386

output:

377717

result:

ok single line: '377717'

Test #7:

score: 0
Accepted
time: 1ms
memory: 4264kb

input:

31251

output:

42371

result:

ok single line: '42371'

Test #8:

score: 0
Accepted
time: 1ms
memory: 4272kb

input:

33516

output:

503005

result:

ok single line: '503005'

Test #9:

score: 0
Accepted
time: 1ms
memory: 4176kb

input:

6167

output:

148870

result:

ok single line: '148870'

Test #10:

score: 0
Accepted
time: 1ms
memory: 4204kb

input:

8508

output:

71598

result:

ok single line: '71598'

Test #11:

score: 0
Accepted
time: 1ms
memory: 4244kb

input:

18757

output:

910805

result:

ok single line: '910805'

Test #12:

score: 0
Accepted
time: 1ms
memory: 4240kb

input:

29843

output:

982119

result:

ok single line: '982119'

Test #13:

score: 0
Accepted
time: 1ms
memory: 4240kb

input:

8618

output:

946465

result:

ok single line: '946465'

Test #14:

score: 0
Accepted
time: 1ms
memory: 4332kb

input:

26480

output:

427468

result:

ok single line: '427468'

Test #15:

score: 0
Accepted
time: 1ms
memory: 4268kb

input:

23988

output:

536392

result:

ok single line: '536392'

Test #16:

score: 0
Accepted
time: 1ms
memory: 4176kb

input:

39830

output:

852687

result:

ok single line: '852687'

Test #17:

score: 0
Accepted
time: 1ms
memory: 4200kb

input:

10055

output:

571911

result:

ok single line: '571911'

Test #18:

score: 0
Accepted
time: 1ms
memory: 4240kb

input:

2227

output:

361051

result:

ok single line: '361051'

Test #19:

score: 0
Accepted
time: 1ms
memory: 4204kb

input:

33772

output:

41792

result:

ok single line: '41792'

Test #20:

score: 0
Accepted
time: 1ms
memory: 4176kb

input:

2094

output:

41578

result:

ok single line: '41578'