Submission #223121

#TimeUsernameProblemLanguageResultExecution timeMemory
223121patrikpavic2Asceticism (JOI18_asceticism)C++17
100 / 100
42 ms1280 KiB
#include <cstdio> #include <cstring> #include <vector> #define X first #define Y second #define PB push_back using namespace std; typedef long long ll; typedef pair < int , int > pii; typedef vector < int > vi; const int N = 1e5 + 500; const int MOD = 1e9 + 7; inline int add(int A,int B){ if(A + B >= MOD) return A + B - MOD; return A + B; } inline int mul(int A,int B){ return (ll)A * B % MOD; } inline int sub(int A,int B){ if(A - B < 0) return A - B + MOD; return A - B; } inline int pot(int A,int B){ int ret = 1, bas = A; for(;B;B >>= 1){ if(B&1) ret = mul(ret, bas); bas = mul(bas, bas); } return ret; } int fak[N], inv[N], n, k; void precompute(){ fak[0] = 1; inv[0] = 1; for(int i = 1;i < N;i++){ fak[i] = mul(fak[i - 1], i); inv[i] = pot(fak[i], MOD -2); } } int choose(int n,int k){ return mul(fak[n], mul(inv[k], inv[n - k])); } int main(){ precompute(); scanf("%d%d", &n, &k); int ret = 0; for(int i = 0;i <= k;i++){ ret = add(ret, mul(pot(MOD - 1, i), mul(choose(n + 1, i), pot(k - i, n)))); } printf("%d\n", ret); return 0; }

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...