2017 Multi-University Training Contest
来源:互联网 发布:兴趣图谱源码 编辑:程序博客网 时间:2024/06/09 18:31
1003
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#include<vector>using namespace std;vector<int> pri;#define ll long long#define mod 998244353#define maxn 1000001ll res[maxn];vector<int> head[maxn];int check[maxn];ll num[maxn];int main(){ memset(check,0,sizeof(check)); for(int i = 2;i < 1000001;i ++){ if(check[i] == 0) pri.push_back(i); for(int j = i;j < maxn; j+=i) check[j] = 1; } int t; ll l,r,k; cin>>t; while(t--){ cin>>l>>r>>k; for(int i = 0;i <= r - l; i++){ res[i] = l+i; head[i].clear(); num[i] = 1; } ll ans = 0; for(int i = 0;i < pri.size(); i++){ int p = pri[i]; ll be = (l+p-1)/p*p; while(be <= r){ int x = 0; while(res[be-l]%p==0){ res[be-l] /= p; x++; } num[be-l] = num[be-l] *(1+k*x) %mod; be += p; } } for(int i = 0;i <= r - l;i++){ if(res[i] != 1) num[i] = num[i] *(1+k)%mod; ans += num[i]; ans %= mod; } cout<<ans<<endl; }}
1004 真题靠运气的乱搞的,跑了3s左右
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#include<vector>using namespace std;#define maxn 60007int tree[maxn];int get(int p){ int s = 0; while(p > 0){ s += tree[p]; p -= p&(-p); } return s;}void set(int p,int s){ while(p < maxn){ tree[p] += s; p += p&(-p); }}int nextt[maxn],pla[maxn];int num[maxn];int main(){ int t,n; cin>>t; while(t--){ scanf("%d",&n); for(int i = 1;i <= n; i++){ pla[i] = maxn-1; scanf("%d",&num[i]); } for(int i = n;i > 0; i--){ nextt[i] = pla[num[i]]; pla[num[i]] = i; } memset(tree,0,sizeof(tree)); for(int i = 1;i <= n; i++){ if(pla[num[i]] != -1) set(i,1); pla[num[i]] = -1; } int k = sqrt(n); long long up = 1,down = 1; for(int i = 1;i <= n; i++){ int p = i; for(int j = i + k;;j+=k){ int u = get(p); if(j > n) j = n; int ud = get(j) - u; ud = j - p - ud; int d = p - i + 1 + ud; if(up * d > down * u){ for(int q = p+1; q <= j; q++){ d = q - i + 1; u = get(q); if(up * d > down * u){ up = u; down = d; } } } p = j; if(j == n) break; } set(i,-1); set(nextt[i],1); } printf("%0.8f\n",1.0*up / down); }}/**10051 2 1 2 361 2 1 2 1 251 1 1 1 181 2 1 2 1 2 1 293 1 2 1 2 1 2 1 2*/09
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>using namespace std;int main(){ int t,u,n; cin>>t; while(t--){ int odd = 0; cin>>n; for(int i = 0;i < n; i++){ scanf("%d",&u); if(u & 1) odd++; } if(odd >= n - odd) cout<<"2 1"<<endl; else cout<<"2 0"<<endl; }}/**1.XX...XX.....XX...XX.X..X....X......X.X..XX..X....X.X....X.X..X......XX.....XX...XX.X..X.X....X....X.X..XX..X.X.........X.X..X.XX...XX.....XX...XX.*/
11
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>using namespace std;char map[7][21];int result[7];int work(int x,int y){ memset(result,0,sizeof(result)); if(map[x][y+1] == 'X') result[0] = 1; if(map[x+1][y] == 'X') result[1] = 1; if(map[x+1][y+3] == 'X') result[2] = 1; if(map[x+4][y] == 'X') result[3] = 1; if(map[x+4][y+3] == 'X') result[4] = 1; if(map[x+3][y+1] == 'X') result[5] = 1; if(map[x+6][y+1] == 'X') result[6] = 1; if(result[1]){ //0 4 5 6 8 9 if(result[0] == 0) return 4; if(result[5] == 0) return 0; if(result[3] == 0){ if(result[2] == 0) return 5; return 9; } if(result[2] == 0) return 6; return 8; } else { //1 2 3 7 if(result[0] == 0) return 1; if(result[3] == 1) return 2; if(result[5] == 1) return 3; return 7; }}int main(){ int t; cin>>t; while(t--){ for(int i = 0;i < 7; i++) cin>>map[i]; int x; x = work(0,0); cout<<x; x = work(0,5); cout<<x; cout<<":"; x = work(0,12); cout<<x; x = work(0,17); cout<<x<<endl;; }}/**1.XX...XX.....XX...XX.X..X....X......X.X..XX..X....X.X....X.X..X......XX.....XX...XX.X..X.X....X....X.X..XX..X.X.........X.X..X.XX...XX.....XX...XX.*/
12
#include<iostream>#include<cstring>#include<algorithm>#include<cstdio>#include<vector>using namespace std;vector<int> pri;#define ll long long#define mod 998244353#define maxn 2001int a[maxn],b[maxn];ll up[maxn],down[maxn];int main(){ int t,n,m; cin>>t; while(t--){ cin>>n>>m; for(int i = 0;i < n; i++) scanf("%d",&a[i]); for(int j = 0;j < m; j++) scanf("%d",&b[j]); memset(up,0,sizeof(up)); memset(down,0,sizeof(down)); ll ans = 0; for(int i = 0;i < n; i++){ ll s = 0; //up for(int j = 0;j < m; j++){ if(b[j] == a[i]){ up[j] += s + 1; ans = (ans + s + 1) % mod; up[j] %= mod; } if(b[j] > a[i]){ s += down[j]; s %= mod; } } s = 0; for(int j = 0;j < m; j++){ if(b[j] == a[i]){ down[j] += s; down[j] %= mod; ans = (ans + s) % mod; } if(b[j] < a[i]){ s += up[j]; } } } cout<<ans<<endl; }}
阅读全文
0 0
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- #2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- #2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- 2017 Multi-University Training Contest
- Daggger2 概念解读、使用姿势及源码分析(2)
- Android自定义键盘:数字键盘和字母键盘
- Android动画学习(七)之转场动画
- 算法(一):全排列实现与尾递归
- Oracle中distinct的用法实例以及Oracle distince 用法和删除重复数据
- 2017 Multi-University Training Contest
- Mongodb 查询表达式(时间、子集)
- db2查看数据库代码集(字符集、编码)
- 包含第k元素LIS(dp)
- 关于屏幕的概念理解
- java集合
- Servlet中如何获取Spring的工厂
- mysql spring分布式事务处理
- 欢迎使用CSDN-markdown编辑器