QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#867540 | #2936. Simple Collatz Sequence | WeaRD276# | WA | 1ms | 3968kb | C++20 | 1.4kb | 2025-01-23 18:35:02 | 2025-01-23 18:35:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
const int MOD = 1000007;
ll add(ll a, ll b)
{
return a + b >= MOD ? a + b - MOD : a + b;
}
int solve()
{
int m;
if (!(cin >> m))
return 1;
if (m == 1)
{
cout << "0\n";
return 0;
}
vector<ll> fib{1, 1};
while (sz(fib) != m)
{
int n = sz(fib);
fib.pb(add(fib[n - 1], fib[n - 2]));
}
cout << fib.back() << '\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
cerr << "_____________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
12345
output:
540591
result:
ok single line: '540591'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3584kb
input:
1
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'