제출 #1277570

#제출 시각아이디문제언어결과실행 시간메모리
1277570vuquangsangMagneti (COCI21_magneti)C++20
10 / 110
1 ms580 KiB
#include <bits/stdc++.h> using namespace std; #define el "\n" #define FOR(i,a,b) for(int i = (a), _b = (b); i <= _b; i++) #define FORD(i,a,b) for(int i = (a), _b = (b); i >= _b; i--) #define pb push_back #define fi first #define se second #define all(x) x.begin(),x.end() #define lg(x) __lg(x) #define alla(a,n) a+1,a+n+1 #define ll long long template <class T> bool maxi(T &x, T y) { if(x < y) { x = y ; return true ;} return false;} template <class T> bool mini(T &x, T y) { if(x > y) { x = y ; return true ;} return false;} const int sm = 1e9 + 7; const int N = 1e4 + 2; int n, r[N], L; ll fac[N], inv_fac[N]; int lim = 1e4; ll Pow(int a, int n) { if(!n) return 1; ll res = Pow(a, n / 2); res = 1LL * res * res % sm; if(n & 1) res = 1LL * res * a % sm; return res; } void prepare() { fac[0] = inv_fac[0] = 1; FOR(i, 1, lim) fac[i] = 1LL * fac[i - 1] * i % sm; inv_fac[lim] = Pow(fac[lim], sm - 2); FORD(i, lim - 1, 1) inv_fac[i] = 1LL * inv_fac[i + 1] * (i + 1) % sm; } ll C(int k, int n) { if(k < 0 || k > n) return 0; return 1LL * fac[n] * inv_fac[k] % sm * inv_fac[n - k] % sm; } void inp() { cin >> n >> L; FOR(i, 1, n) cin >> r[i]; prepare(); } /* Try your best No regrets */ namespace subtask_1 { void slv() { ll res = 1LL * fac[n] * C(n, L - ((n - 1) * r[1] + 1) + n) % sm; cout << res; } } /* Code slowly, think carefully */ main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define __Azul__ "magneti" if(fopen(__Azul__".inp", "r")) { freopen(__Azul__".inp", "r", stdin); freopen(__Azul__".out", "w", stdout); } bool qs = 0; int T = 1; if(qs) cin >> T; while(T--) { inp(); subtask_1::slv(); } cerr << "\nTime" << 0.001 * clock() << "s "; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen(__Azul__".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen(__Azul__".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...