Task: | Planeetat |
Sender: | Lieska |
Submission time: | 2020-09-26 16:17:06 +0300 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:49:14: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and '__int128') cout << ans[i] << "\n"; ~~~~~^~~~~~~~~ In file included from /usr/include/c++/7/istream:39:0, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from input/code.cpp:1: /usr/include/c++/7/ostream:166:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] operator<<(long __n) ^~~~~~~~ /usr/include/c++/7/ostream:170:7: note: candidate: std::basic_ostream<_CharT, _Tra...
Code
#include <bits/stdc++.h>using namespace std;typedef long long ll;__int128_t M=1e9+7, bi[5050][5050], kertoma[5050], J[5050][5050], ans[5050];ll pot(ll a, ll b){if (a==0) return 1;if (b==0) return 1;ll d=pot(a, b/2);d = (d*d)%M;if (b%2==0) return d;else return (d*a)%M;}ll bin(ll a, ll b){if (bi[a][b]) return bi[a][b];else{ll c=kertoma[a];c = (c*pot(kertoma[b], M-2))%M;c = (c*pot(kertoma[a-b], M-2))%M;bi[a][b]=c;return c;}}int main(){ios_base::sync_with_stdio(0);cin.tie(0);ll n;cin >> n;kertoma[0]=1;for (int i=1; i<=n; ++i) kertoma[i]=(kertoma[i-1]*i)%M;for (int i=1; i<=n; ++i) J[i][1]=kertoma[i-1];for (int i=2; i<=n; ++i){for (int j=2; j<=i; ++j){J[i][j]=(J[i-1][j]*(i-1)+J[i-1][j-1])%M;}}for (int i=1; i<=n; ++i){for (int j=i; j<=n; ++j){if (j<n) ans[i] = (ans[i] + J[j][i]*bin(n, j)*j * pot(n, n-j-1))%M;else ans[i] = (ans[i] + J[j][i]*bin(n, j))%M;}}for (int i=1; i<=n; ++i){cout << ans[i] << "\n";}}