QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631403#2934. How Many Unicycles in a Broken WheelTenshiAC ✓40ms3740kbC++231.2kb2024-10-12 02:50:542024-10-12 02:50:55

Judging History

你现在查看的是最新测评结果

  • [2024-10-12 02:50:55]
  • 评测
  • 测评结果:AC
  • 用时:40ms
  • 内存:3740kb
  • [2024-10-12 02:50:54]
  • 提交

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 N=4040, mod=100007;

int n;
int f[N][2];

int add(int a, int b){
	return (a+b)%mod;
}

int mul(int a, int b){
	return 1LL*a*b%mod;
}

int get(int x){
	if(!x) return 1;
	return add(f[x][0], f[x][1]);
}

signed main(){
	cin>>n;
	--n;
	
	f[1][0]=1;
	f[1][1]=1;
	rep(i, 1, n-1){
		f[i+1][0]=add(f[i+1][0], mul(2, f[i][0]));
		f[i+1][1]=add(f[i+1][1], f[i][0]);
		f[i+1][0]=add(f[i+1][0], f[i][1]);
		f[i+1][1]=add(f[i+1][1], f[i][1]);
	}
	
	int res=0;
	rep(l, 1, n) rep(r, l+1, n){
		int fir=l-1;
		int sec=n-r;
		res=add(res, mul(get(fir), get(sec)));
	}
	cout<<res;
		
	return 0;
}

详细

Test #1:

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

input:

5

output:

19

result:

ok single line: '19'

Test #2:

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

input:

1234

output:

50380

result:

ok single line: '50380'

Test #3:

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

input:

3

output:

1

result:

ok single line: '1'

Test #4:

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

input:

4000

output:

14774

result:

ok single line: '14774'

Test #5:

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

input:

10

output:

5911

result:

ok single line: '5911'

Test #6:

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

input:

6

output:

65

result:

ok single line: '65'

Test #7:

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

input:

7

output:

210

result:

ok single line: '210'

Test #8:

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

input:

8

output:

654

result:

ok single line: '654'

Test #9:

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

input:

9

output:

1985

result:

ok single line: '1985'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

779

output:

59262

result:

ok single line: '59262'

Test #11:

score: 0
Accepted
time: 14ms
memory: 3740kb

input:

2320

output:

14502

result:

ok single line: '14502'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3728kb

input:

768

output:

57480

result:

ok single line: '57480'

Test #13:

score: 0
Accepted
time: 16ms
memory: 3532kb

input:

2471

output:

10444

result:

ok single line: '10444'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

796

output:

24011

result:

ok single line: '24011'

Test #15:

score: 0
Accepted
time: 35ms
memory: 3664kb

input:

3931

output:

57605

result:

ok single line: '57605'

Test #16:

score: 0
Accepted
time: 16ms
memory: 3716kb

input:

2508

output:

32594

result:

ok single line: '32594'

Test #17:

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

input:

3093

output:

48868

result:

ok single line: '48868'

Test #18:

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

input:

138

output:

64281

result:

ok single line: '64281'

Test #19:

score: 0
Accepted
time: 5ms
memory: 3644kb

input:

1367

output:

23969

result:

ok single line: '23969'

Test #20:

score: 0
Accepted
time: 14ms
memory: 3668kb

input:

2335

output:

82476

result:

ok single line: '82476'