답안 #420737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420737 2021-06-08T13:38:39 Z qwerasdfzxcl Asceticism (JOI18_asceticism) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const int MOD = 1e9+7;

ll pw(ll a, ll e){
    if (!e) return 1;
    ll ret = pw(a, e/2);
    if (e&1) return ret*ret%MOD*a%MOD;
    return ret*ret%MOD;
}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    ll ans = 0, tmp = 1;
    for (int i=k;i;i--){
        ans += pw(i, n)*tmp;
        tmp = (-tmp*(n+1-k+i)%MOD)*pw(k-i+1, MOD-2)%MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message

asceticism.cpp: In function 'int main()':
asceticism.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -