結果
問題 | No.8054 ほぼ直角二等辺三角形 |
ユーザー | heno239 |
提出日時 | 2019-04-01 22:28:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,117 bytes |
コンパイル時間 | 998 ms |
コンパイル使用メモリ | 114,552 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 03:23:37 |
合計ジャッジ時間 | 2,238 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> using namespace std; typedef unsigned long long ll; typedef unsigned int ui; const ll mod = 1000000007; typedef long double ld; const ll INF = 1e+14; typedef pair<int, int> P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second const int mn = 30; ll pas[mn][mn]; struct out { ll x, y, z; }; out ans[19]; void solve() { rep(i, mn) { rep(j, mn) { if (i == 0 || j == 0)pas[i][j] = 1; else pas[i][j] = (pas[i - 1][j] + pas[i][j - 1]); } } for (int i = 1; i < mn-6; i += 2) { ll k = 0, n = 0; ll s = 1; for (int j = 0; j <= i; j += 2) { k += s * pas[i-j][j]; s *= 2; } s = 1; for (int j = 1; j <= i; j += 2) { n += s * pas[i-j][j]; s *= 2; } ll m = n + k; out u = { m * m - n * n,2 * n*m ,m * m + n * n }; string xx = to_string(u.z); int len = xx.length(); ans[len] = u; } for (int i = 1; i < mn-18; i ++) { ll k = 0, n = 0; ll z = 1; vector<ll> st; rep(j, i)z *= 3; st.push_back(z); rep1(j, i) { z /= 3; z *= 2; st.push_back(z); if (j % 2)z *= 2; } rep(j, i + 1) { if (j % 2 == 0) { k += pas[i - j][j] * st[j]; } else { n += pas[i - j][j] * st[j]; } } ll m = n + k; out u = { 2*n*m,m * m - n * n ,m * m + n * n }; string xx = to_string(u.z); int len = xx.length(); ans[len] = u; } int x; cin >> x; cout << ans[x].x << " " << ans[x].y << " " << ans[x].z << endl; } int main() { solve(); //stop return 0; }