QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#629130#2936. Simple Collatz SequenceTenshi#AC ✓1ms3852kbC++23778b2024-10-11 05:40:052024-10-11 05:40:05

Judging History

This is the latest submission verdict.

  • [2024-10-11 05:40:05]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3852kb
  • [2024-10-11 05:40:05]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << ": " << (x) << endl
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define all(x) (x).begin(), (x).end()
 
#define x first
#define y second
using pii = pair<int, int>;
using ll = long long;
 
inline void read(int &x){
    int s=0; x=1;
    char ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-')x=-1;ch=getchar();}
    while(ch>='0' && ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
    x*=s;
}

const int mod=1000007;

int add(int x, int y){
	return (x+y)%mod;
}

signed main(){
	int n; cin>>n;
	vector<int> f(40040);
	f[1]=f[2]=1;
	rep(i, 3, n) f[i]=add(f[i-1], f[i-2]);
	cout<<f[n];
	return 0;
}

詳細信息

Test #1:

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

input:

6

output:

8

result:

ok single line: '8'

Test #2:

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

input:

12345

output:

540591

result:

ok single line: '540591'

Test #3:

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

input:

1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

40000

output:

852282

result:

ok single line: '852282'

Test #5:

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

input:

2148

output:

427120

result:

ok single line: '427120'

Test #6:

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

input:

14386

output:

377717

result:

ok single line: '377717'

Test #7:

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

input:

31251

output:

42371

result:

ok single line: '42371'

Test #8:

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

input:

33516

output:

503005

result:

ok single line: '503005'

Test #9:

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

input:

6167

output:

148870

result:

ok single line: '148870'

Test #10:

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

input:

8508

output:

71598

result:

ok single line: '71598'

Test #11:

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

input:

18757

output:

910805

result:

ok single line: '910805'

Test #12:

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

input:

29843

output:

982119

result:

ok single line: '982119'

Test #13:

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

input:

8618

output:

946465

result:

ok single line: '946465'

Test #14:

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

input:

26480

output:

427468

result:

ok single line: '427468'

Test #15:

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

input:

23988

output:

536392

result:

ok single line: '536392'

Test #16:

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

input:

39830

output:

852687

result:

ok single line: '852687'

Test #17:

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

input:

10055

output:

571911

result:

ok single line: '571911'

Test #18:

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

input:

2227

output:

361051

result:

ok single line: '361051'

Test #19:

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

input:

33772

output:

41792

result:

ok single line: '41792'

Test #20:

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

input:

2094

output:

41578

result:

ok single line: '41578'