제출 #1121677

#제출 시각아이디문제언어결과실행 시간메모리
1121677vjudge1Calvinball championship (CEOI15_teams)C++17
0 / 100
1064 ms1616 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define pb push_back #define in insert #define F first #define S second #define vll vector<ll> #define all(v) v.begin(),v.end() #define endl '\n' #define pii pair<ll,ll> using namespace std; const ll INF =1e18, mod = 1e9 + 7, N = 1e5 + 5; ll f[N]; ll modpow(ll a,ll b){ ll ans = 1; while(b>0){ if(b%2==1){ ans*=a; ans%=mod; } a*=a; a%=mod; b/=2; } return ans; } ll inv(ll a){ return (modpow(a,mod-2)) % mod; } ll C(ll a,ll b){ return(f[a] * inv(f[b] * f[a-b] % mod)) % mod; } void solve(){ ll n; cin >> n; ll a[n]; set<ll>s; for(int i = 0; i < n; i++){ cin >> a[i]; s.in(a[i]); } ll ans = 1; ll now = n - 1; for(int i = 2; i <= n; i++){ if(i != n){ for(int j = 1; j <= n -1; j++){ ans += C(now, j) % mod; ans %= mod; } now--; } else{ ans++; } }//// 1 2 3 4 cout << ans << endl; } int main(){ fast; ll t = 1; //cin >> t; f[0] = 1; f[1] = 1; for(int i = 2; i <= N; i++){ f[i] = f[i - 1] * i; } while(t--){ solve(); } return 0; }

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

teams.cpp: In function 'int main()':
teams.cpp:67:14: warning: iteration 100003 invokes undefined behavior [-Waggressive-loop-optimizations]
   67 |         f[i] = f[i - 1] * i;
      |         ~~~~~^~~~~~~~~~~~~~
teams.cpp:66:22: note: within this loop
   66 |     for(int i = 2; i <= N; i++){
      |                    ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...