当前位置: 首页 > news >正文

ccfcsp-202309(1、2、3)

202309-1 坐标变换(其一)

#include <bits/stdc++.h>
using namespace std;
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n, m;cin >> n >> m;int x, y;int opx = 0, opy = 0;for(int i = 0; i < n; i++){cin >> x >> y;opx += x;opy += y;}for(int i = 0; i < m; i++){cin >> x >> y;cout << x + opx << " " << y + opy << endl;}return 0;
}

202309-2 坐标变换(其二)
80分超时解

#include <bits/stdc++.h>
using namespace std;int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n, m;cin >> n >> m;vector<vector<double>> operation(n, vector<double>(2));double x, y;for(int i = 0; i < n; i++){cin >> operation[i][0] >> operation[i][1];}int i, j;for(int t = 0; t < m; t++){cin >> i >> j >> x >> y;double xx = x, yy = y;double angle = 0, k = 1;i--;for(;i < j; i++){if(operation[i][0] == 1){k *= operation[i][1];}else if(operation[i][0] == 2){angle += operation[i][1];}}if(k != 1){x *= k;y *= k;}if(angle != 0){xx = x * cos(angle) - y * sin(angle);yy = x * sin(angle) + y * cos(angle);cout << fixed << setprecision(3) << xx << " " << yy << endl;}else{cout << fixed << setprecision(3) << x << " " << y << endl;}}return 0;
}

100分解

#include <bits/stdc++.h>
using namespace std;int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n, m;cin >> n >> m;vector<double> A(n + 1, 1);//拉伸k倍vector<double> B(n + 1, 0);//旋转角度double x, y;for(int i = 1; i <= n; i++){int a; double b;cin >> a >> b;if(a == 1){A[i] = b*A[i - 1];B[i] = B[i - 1];}else{A[i] = A[i - 1];B[i] = b + B[i - 1];}}int i, j;for(int t = 0; t < m; t++){cin >> i >> j >> x >> y;double xx = x, yy = y;double k = A[j]/A[i - 1], angle = B[j] - B[i - 1];if(k != 1){x *= k;y *= k;}if(angle != 0){xx = x * cos(angle) - y * sin(angle);yy = x * sin(angle) + y * cos(angle);cout << fixed << setprecision(3) << xx << " " << yy << endl;}else{cout << fixed << setprecision(3) << x << " " << y << endl;}}return 0;
}

202309-3 梯度求解

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9 + 7;int main() {vector<string> vec;stack<map<ll, ll>> st;int n, m, k;cin >> n >> m;string str, s;vector<int> a(n + 1, 0);//变量的值getchar();getline(cin, str);std::stringstream ss(str);while(ss >> s){vec.push_back(s);}while(m--){cin >> k;str = "x" + to_string(k);//求导变量for(int i = 1; i <= n; i++)cin >> a[i];for(int i = 0; i < vec.size(); i++){s = vec[i];map<ll, ll> mp;if(s == str){ //是求导变量mp[1] = 1;st.push(mp);}else if(s[0] == 'x'){ //是其他变量int d = stoi(s.substr(1));mp[0] = a[d] % mod;st.push(mp);}else if(s == "+" || s == "-" || s == "*"){//是运算符map<ll,ll> mp2 = st.top();st.pop();map<ll,ll> mp1 = st.top();st.pop();if(s == "+"){mp = mp1;for(auto it : mp2){mp[it.first] = (mp[it.first] + it.second) % mod;}}else if(s == "-"){mp = mp1;for(auto it : mp2){mp[it.first] = (mp[it.first] - it.second) % mod;}}else{for(auto it1 : mp1){for(auto it2 : mp2){mp[it1.first + it2.first] += it1.second * it2.second;mp[it1.first + it2.first] %= mod;}}}mp1.clear();mp2.clear();st.push(mp);}else{ //是数字ll d = stoll(s);mp[0] = d % mod;st.push(mp);}}map<ll,ll> mp = st.top(); //获得结果的一元表达式st.pop();ll ans = 0;for(auto it : mp){ll e = it.first, c = it.second;if(e > 0){ans = ans + c * e * pow(a[k], e - 1);ans %= mod;}}cout << (ans + mod) % mod << endl;mp.clear();}return 0;
}
http://www.lryc.cn/news/424340.html

相关文章:

  • 数据结构--数据结构概述
  • Spring中的BeanFactoryAware
  • Neo4j service is not installed
  • LeetCode 3132.找出与数组相加的整数 II:排序+3次尝试(nlog n)
  • 微信小程序--26(全局配置-1)
  • 汽车4S店管理系统-计算机毕设Java|springboot实战项目
  • bug的常见排查和分析思路以及相关的原因分类
  • Nature:7个提升科研产出的实用建议
  • react-native从入门到实战系列教程-页面之间的跳转
  • HarmonyOS应用开发者高级认证(一)
  • 【网络】套接字(socket)编程——UDP版
  • 一篇文章让你彻底掌握 Shell
  • Java中的Collection集合:深入理解与应用
  • Kubernetes-K8S
  • 简化文本处理流程,通用文字识别助力提升信息采集效率
  • 【网络】TCP协议通信的重要策略——滑动窗口,快重传,流量控制,拥塞控制,延时应答
  • 极狐GitLab CI/CD 如何构建镜像并推送到 azure 镜像仓库?
  • Leetcode—1143. 最长公共子序列【中等】
  • ZBrush笔刷介绍
  • React+AntDesign做一个日历,展示节假日,节气,并且在某几个时间上添加活动备注
  • 排序算法之梳排序
  • ESP8266 创建TCP连接
  • OceanBase内存管理小窍门
  • 【问题解决】git status中文文件名乱码
  • 探索数据结构:AVL树的分析与实现
  • 使用 C++ 实现简单的插件系统
  • 使用Python创建省份城市地图选择器
  • 【Java 数据结构】Stack和Queue介绍
  • Docker基本语法
  • uniapp 对于scroll-view滑动和页面滑动的联动处理