2017年浙江工业大学大学生程序设计迎新赛预赛
2017-12-17 04:35
357 查看
挺不错的一套题 写了几道鸽了没写完 有空继续补
比赛链接 https://www.nowcoder.com/acm/contest/52#question
A.
尼姆博弈的想法 很久没写题了 博弈都忘完了 看了提示 其实很简单,,,#include <bits/stdc++.h> using namespace std; #define LL long long const int MAXN = 1e5+10; int main() { ios::sync_with_stdio(false); int T; cin >>T; while (T--) { int n, k, x, y; cin >> n >> k; int res = 0; for(int i = 1; i <= n; i++) { cin >> x; if(k == i) { y = x; continue; } res ^= x; } if(res < y) cout << "Yes\n"; else cout << "No\n"; } return 0; }
B. 多项式求值
感觉这个题好zz啊 就是个简单的快速幂 非要 用字符串读入 而且是多组输入 debug到崩溃QAQ#include <bits/stdc++.h> using namespace std; #define LL long long const LL mod = 1e9+7; const LL MAXN = 1e6+100; char str[MAXN]; LL len; LL pwo_mod(LL a, LL b) { LL ans = 1; a %= mod; while(b) { if(b&1) ans = (ans*a)%mod; a = (a*a)%mod; b >>= 1; } return ans; } LL get_num(LL l, LL r) { LL num = 0, res = 1; for(LL i = r; i >= l; i--) { nu 4000 m += res*(str[i]-'0'); res *= 10; } return num; } LL calcu(LL a, LL b, LL x) { LL res = 1ll*a*pwo_mod(x,b)%mod; return res; } bool is_num(LL x) { if(str[x]>='0' && str[x]<='9') return true; return false; } void solve(LL x) { LL ans = 0; LL a, b, l, r; LL clr; for(LL i = 0; i < len; i++) { if(str[i] == '-') clr = -1; else clr = 1; if(str[i]=='+' || str[i]=='-') i++; l = r = i; if(str[l] == 'x') { a = 1, b = 1; l--, r--; } else { while(r+1<len && is_num(r+1)) r++; a = get_num(l,r); b = 1; } if(str[r+1] != 'x') { b = 0; i = r; } else if(str[r+2] == '^') { l = r+3, r = l; while(r+1<len && is_num(r+1)) r++; b = get_num(l,r); i = r; } else i = r+1; ans = (ans+clr*calcu(a,b,x))%mod; } ans = (ans%mod+mod)%mod; printf("%lld\n",ans); } int main() { while(~scanf("%s",str)) { LL x, m; len = strlen(str); scanf("%lld",&m); while(m--) { scanf("%lld",&x); solve(x); } } return 0; }
C. 数的变换
数学相关 有空在补这里写代码片
D. 简单的数据结构
用deque写下就好 list超时mmp#include <bits/stdc++.h> using namespace std; #define LL long long const int MAXN = 1e5+10; int main() { ios::sync_with_stdio(false); int n, m, x, y; deque<int> d; cin >> n >> m; while(m--) { cin >> x; if(x == 1) { cin >> y; d.push_front(y); } if(x == 2) { d.pop_front(); } if(x == 3) { cin >> y; d.push_back(y); } if(x == 4) { d.pop_back(); } if(x == 5) { reverse(d.begin(),d.end()); } if(x == 6) { cout << d.size() << endl; for(int i = 0; i < d.size()-1; i++) cout << d[i] << ' '; cout << d[d.size()-1] << "\n"; } if(x == 7) { sort(d.begin(),d.end()); } } return 0; }
相关文章推荐
- 2017年浙江工业大学大学生程序设计迎新赛预赛 J 裁缝大师【简单几何】
- 2017年浙江工业大学大学生程序设计迎新赛预赛
- 2017年浙江工业大学大学生程序设计迎新赛预赛E 最大化平均值
- 2017年浙江工业大学大学生程序设计迎新赛预赛
- 【牛客网】2017年浙江工业大学大学生程序设计迎新赛热身赛 F题 方块 I【证明题】【想法题】
- 2017年浙江工业大学大学生程序设计迎新赛热身赛 部分题解
- 2017年浙江工业大学大学生程序设计迎新赛热身赛 I after与迷宫 牛客
- 2017年浙江工业大学大学生程序设计迎新赛预赛 I 【简单题】
- 2017年浙江工业大学大学生程序设计迎新赛预赛 J【三角函数的应用】
- 2017年浙江工业大学大学生程序设计迎新赛预赛-K:栗酱的连通图(最大生成树)
- 2017年浙江工业大学大学生程序设计迎新赛预赛 K 【看似是图其实是贪心】
- 2017年浙江工业大学大学生程序设计迎新赛预赛 L【简单题】
- 2017年浙江工业大学大学生程序设计迎新赛预赛 H - 栗酱的文明
- 2017年浙江工业大学大学生程序设计迎新赛预赛 M
- nowcoder 2017年浙江工业大学大学生程序设计迎新赛预赛- CC的神奇背包
- 2017年浙江工业大学大学生程序设计迎新赛预赛A【巴什博奕 异或和】
- 2017年浙江工业大学大学生程序设计迎新赛热身赛-J-Forever97与寄信
- 2017年浙江工业大学大学生程序设计迎新赛热身赛
- nowcoder 2017年浙江工业大学大学生程序设计迎新赛预赛-栗酱的异或和
- 2017年浙江工业大学大学生程序设计迎新赛预赛 D 简单的数据结构【纯 stl -> List 的应用】