답안 #635382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635382 2022-08-26T07:33:07 Z Mahdi Sumtree (INOI20_sumtree) C++17
10 / 100
8 ms 4196 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
const int N=5e5+5, M=1e9+7;
int n, r, f[N], rf[N];

int tav(int a, int b){
    int res=1;
    while(b){
        if(b&1)
            res=1LL*res*a%M;
        a=1LL*a*a%M;
        b>>=1;
    }
    return res;
}

int C(int x, int y){
    ll res=1LL*f[x]*rf[y]%M;
    res=res*rf[x-y]%M;
    return res;
}

int main(){
    cin>>n>>r;
    f[0]=1;
    for(int i=1;i<N;++i)
        f[i]=1LL*f[i-1]*i%M;
    rf[N-1]=tav(f[N-1], M-2);
    for(int i=N-2;i>=0;--i)
        rf[i]=1LL*(i+1)*rf[i+1]%M;
    cout<<C(r+n-1, n-1)<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4180 KB Output is correct
2 Correct 7 ms 4180 KB Output is correct
3 Correct 7 ms 4180 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 7 ms 4160 KB Output is correct
6 Correct 7 ms 4180 KB Output is correct
7 Correct 8 ms 4180 KB Output is correct
8 Correct 6 ms 4180 KB Output is correct
9 Correct 7 ms 4180 KB Output is correct
10 Correct 7 ms 4180 KB Output is correct
11 Correct 7 ms 4180 KB Output is correct
12 Correct 7 ms 4180 KB Output is correct
13 Correct 7 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4180 KB Output is correct
2 Correct 7 ms 4180 KB Output is correct
3 Correct 7 ms 4180 KB Output is correct
4 Correct 7 ms 4180 KB Output is correct
5 Correct 7 ms 4160 KB Output is correct
6 Correct 7 ms 4180 KB Output is correct
7 Correct 8 ms 4180 KB Output is correct
8 Correct 6 ms 4180 KB Output is correct
9 Correct 7 ms 4180 KB Output is correct
10 Correct 7 ms 4180 KB Output is correct
11 Correct 7 ms 4180 KB Output is correct
12 Correct 7 ms 4180 KB Output is correct
13 Correct 7 ms 4180 KB Output is correct
14 Incorrect 7 ms 4180 KB Output isn't correct
15 Halted 0 ms 0 KB -