原题链接
| #include<iostream> |
| #include<cstdio> |
| #define int long long |
| using namespace std; |
| int a, b, c; |
| int pow(int a, int b) |
| { |
| int ans = 1; |
| for (int i = 1;i <= b;i ++) |
| { |
| ans *= a; |
| if (ans > 1e9) return -1; |
| } |
| return ans; |
| } |
| signed main() |
| { |
| scanf("%lld %lld",&a,&b); |
| cout << pow(a, b); |
| } |
原题链接
| #include<iostream> |
| #include<cmath> |
| #define int long long |
| using namespace std; |
| int k, n, d, e; |
| int check(int y) {int x = sqrt(y); return x * x == y; } |
| void solve(int n, int d, int e) |
| { |
| int a = n + 2 - e * d; |
| int b = e * d; |
| int c = a + b - 2; |
| if (a * a - 4 * c >= 0 && check(a * a - 4 * c)) |
| { |
| int t, p, q; |
| t = a + sqrt(a * a - 4 * c); |
| if (t % 2) |
| { |
| cout << "NO\n"; |
| return; |
| } |
| q = t / 2, p = a - q; |
| if (p > q) |
| { |
| cout << "NO\n"; |
| return; |
| } |
| cout << p << " " << q << endl; |
| return; |
| } |
| cout << "NO\n"; |
| } |
| signed main(void) |
| { |
| cin >> k; |
| while (k --) |
| { |
| cin >> n >> d >> e; |
| solve(n, d, e); |
| } |
| } |
原题链接
| #include<bits/stdc++.h> |
| using namespace std; |
| struct node { |
| int value, cnt_or, cnt_and; |
| }; |
| stack<node> str; |
| string expr; |
| int getpriority(char a) |
| { |
| if (a == '(') return 0; |
| if (a == '|') return 1; |
| return 2; |
| } |
| string turn_into(string expr) |
| { |
| string ret; |
| stack<char> st; |
| for (auto c:expr) |
| { |
| if (c == '(') st.push(c); |
| else if (c == ')') |
| { |
| while (st.top() != '(') |
| { |
| ret.push_back(st.top()); |
| st.pop(); |
| } |
| st.pop(); |
| } |
| else if (c == '&' || c == '|') |
| { |
| while (!st.empty() && getpriority(c) <= getpriority(st.top())) |
| { |
| ret.push_back(st.top()); |
| st.pop(); |
| } |
| st.push(c); |
| } |
| else ret.push_back(c); |
| } |
| while (!st.empty()) |
| { |
| ret.push_back(st.top()); |
| st.pop(); |
| } |
| return ret; |
| } |
| int main() |
| { |
| cin >> expr; |
| string skl = turn_into(expr); |
| for (auto c:skl) |
| { |
| if (c == '|') |
| { |
| node r = str.top();str.pop(); |
| node l = str.top();str.pop(); |
| str.push({l.value | r.value, l.cnt_or + (l.value == 1 ? 1 : r.cnt_or), l.cnt_and + (l.value == 1 ? 0 : r.cnt_and)}); |
| } |
| else if (c == '&') |
| { |
| node r = str.top();str.pop(); |
| node l = str.top();str.pop(); |
| str.push({l.value & r.value, l.cnt_or + (l.value == 0 ? 0 : r.cnt_or),l. cnt_and + (l.value == 0 ? 1 : r.cnt_and)}); |
| } |
| else str.push({c - '0', 0, 0}); |
| } |
| node ans = str.top(); |
| cout << ans.value << endl; |
| cout << ans.cnt_and << " " << ans.cnt_or << endl; |
| return 0; |
| } |
原题链接
| #include<iostream> |
| #include<algorithm> |
| #include<cmath> |
| using namespace std; |
| struct _pnt { |
| int x, y; |
| }a[1010]; |
| int n, k, ans = 0; |
| int f[550][550]; |
| int dis(int i, int j) { return abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y) - 1; } |
| bool cmp(_pnt p1, _pnt p2) { |
| if (p1.x == p2.x) return p1.y < p2.y; |
| else return p1.x < p2.x; |
| } |
| int main() |
| { |
| scanf("%d %d", &n, &k); |
| for (int i = 1;i <= n;i ++) scanf("%d %d", &a[i].x, &a[i].y); |
| sort(a + 1, a + n + 1, cmp); |
| for (int i = 1;i <= n;i ++) |
| { |
| int x = a[i].x; |
| int y = a[i].y; |
| for (int z = 0;z <= k;z ++) |
| { |
| f[i][z] = 1; |
| for (int j = 1;j <= n;j ++) |
| { |
| if (i != j && a[j].x <= x && a[j].y <= y) |
| { |
| int len = dis(i, j); |
| if (z >= len) |
| { |
| f[i][z] = max(f[i][z], f[j][z - len] + len + 1); |
| } |
| } |
| } |
| ans = max(ans, f[i][z] + k - z); |
| } |
| } |
| printf("%d\n", ans); |
| return 0; |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异