QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#867529#2936. Simple Collatz SequenceLaVuna47#AC ✓1ms3712kbC++202.0kb2025-01-23 18:17:532025-01-23 18:17:53

Judging History

This is the latest submission verdict.

  • [2025-01-23 18:17:53]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3712kb
  • [2025-01-23 18:17:53]
  • 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=1000007;
/*

11 -> 12 -> 6 -> 3 -> 4 -> 2 -> 1

1110110010111100
111011001011110
11101100101111
11101100110000


-------------------


Скільки є таких чисел n , що містять m кроків, що стати 1?

*/


ll binpow(ll a, ll b)
{
	ll ans = 1;
	while (b)
	{
		if (b & 1)
		{
			ans = 1LL * ans * a % MOD;
		}
		a = 1LL * a * a % MOD;
		b >>= 1;
	}
	return ans;
}


int solve()
{
	ll m;
	if(!(cin>>m))return 1;
	ll a=1,b=1;
	FOR(i,1,m)
	{
		ll c=(a+b)%MOD;
		a=b;
		b=c;
	}
	cout<<a<<'\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: 0ms
memory: 3712kb

input:

6

output:

8

result:

ok single line: '8'

Test #2:

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

input:

12345

output:

540591

result:

ok single line: '540591'

Test #3:

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

input:

1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

40000

output:

852282

result:

ok single line: '852282'

Test #5:

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

input:

2148

output:

427120

result:

ok single line: '427120'

Test #6:

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

input:

14386

output:

377717

result:

ok single line: '377717'

Test #7:

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

input:

31251

output:

42371

result:

ok single line: '42371'

Test #8:

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

input:

33516

output:

503005

result:

ok single line: '503005'

Test #9:

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

input:

6167

output:

148870

result:

ok single line: '148870'

Test #10:

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

input:

8508

output:

71598

result:

ok single line: '71598'

Test #11:

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

input:

18757

output:

910805

result:

ok single line: '910805'

Test #12:

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

input:

29843

output:

982119

result:

ok single line: '982119'

Test #13:

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

input:

8618

output:

946465

result:

ok single line: '946465'

Test #14:

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

input:

26480

output:

427468

result:

ok single line: '427468'

Test #15:

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

input:

23988

output:

536392

result:

ok single line: '536392'

Test #16:

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

input:

39830

output:

852687

result:

ok single line: '852687'

Test #17:

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

input:

10055

output:

571911

result:

ok single line: '571911'

Test #18:

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

input:

2227

output:

361051

result:

ok single line: '361051'

Test #19:

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

input:

33772

output:

41792

result:

ok single line: '41792'

Test #20:

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

input:

2094

output:

41578

result:

ok single line: '41578'