哈尔滨工业大学(威海)第九届ACM程序设计竞赛
Problem A All Palindrome
https://ac.nowcoder.com/acm/contest/624/A
题解:这个字符串只能是所有字符相同的
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str[N];
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);cin>>str;for(int i=0;i<n;i++){a[str[i]-'a']++;}for(int i=0;i<26;i++){ans=max(ans,a[i]);}cout<<n-ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Problem B Clarifications
https://ac.nowcoder.com/acm/contest/624/B
题解:
C++版本一
#include<bits/stdc++.h>
using namespace std;
int n,p;
int vis[10000]={0};
string pp[110],ss[10000];
int main(){cin>>n>>p;getchar();for(int i=0;i<p;i++){getline(cin,pp[i]);}for(int i=0;i<n;i++){getline(cin,ss[i]);if(ss[i][ss[i].size()-1]=='.'){printf("No Response.\n");continue;}int flag=0;for(int j=0;j<p;j++){if(ss[i]==pp[j]){printf("42.\n");flag=1;break;}}if(flag)continue;vis[i]=1;for(int j=i-1;j>=0;j--){if(ss[j]==ss[i]){vis[i]=vis[j]+1;break;}}if(vis[i]<=5)printf("Read the problem statement carefully.\n");else printf("Juries are investigating. Thanks.\n");}return 0;
}
Problem C ∞
https://ac.nowcoder.com/acm/contest/624/C
题解:模拟
1、暴力查找n所在的数是几位数
2、n所在的数是1中确定的几位数的第几个
3、n是2确定的数的第几位
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
ll t,n,m,k,p,l,r,u,v;
ll ans,cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
ll power(ll a ,ll b){ll res=1;ll base=a;while(b){if(b&1)res=res*base;base=base*base;b>>=1;}return res;
}
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%lld",&t);while(t--){scanf("%lld",&n);ll l=0;ll r=9;cnt=1;while(1){if(l<n&&n<=r)break;l=r;cnt++;r=r+9*power(10,cnt-1)*cnt;}//cout<<l<<" "<<r<<endl;ll L=1;ll R=9*power(10,cnt-1);ans=1;while(L<=R){ll mid=(L+R)>>1;//cout<<L<<" "<<R<<endl;if(l+(mid-1)*cnt<n&&n<=l+(mid)*cnt){ans=mid;break;}else if(l+(mid-1)*cnt>=n){R=mid-1;}else{L=mid+1;}}//cout<<ans<<endl;ll num=power(10,cnt-1)+ans-1;l=l+(ans-1)*cnt;//cout<<num<<endl;ans=n-l;ans=num/(ll)power(10,cnt-ans)%10;cout<<ans<<endl;}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Problem G Virtual Youtuber
https://ac.nowcoder.com/acm/contest/624/G
题解:差分法
求相反
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
ll t,n,m,k,p,l,r,u,v;
ll ans,cnt,flag,temp,sum;
ll a[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%lld",&t);int T=0;while(t--){scanf("%lld%lld",&n,&p);for(int i=1;i<=n;i++){scanf("%lld",&a[i]);}l=1;r=1;ans=0;temp=a[1];while(r<=n){//cout<<l<<" "<<r<<" "<<temp<<endl;if(temp>=p){ans+=n-r+1;temp-=a[l++];}else{temp+=a[++r];}}cout<<"Case #"<<++T<<": "<<n*(n+1)/2-ans<<endl;}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Problem J Bubble Sort
https://ac.nowcoder.com/acm/contest/624/J
题解:乘法逆元 规律
1、交换次数的权呈现正态分布;
2、最少交换次数0,最多交换次数n(n-1)/2;
3、根据数列求和可知答案为n(n-1)/4;
4、费马小定理
5、快速幂
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=998244353;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
ll t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
ll power(ll a ,ll b,ll c){ll res=1;ll base=a%c;while(b){if(b&1)res=(res*base)%c;base=(base*base)%c;b>>=1;}return res;
}
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%lld",&t);while(t--){scanf("%lld",&n);printf("%lld\n",((((n%MOD)*((n-1)%MOD))%MOD)*power(4,MOD-2,MOD))%MOD);}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
哈尔滨工业大学(威海)第九届ACM程序设计竞赛相关推荐
- “师创杯”山东理工大学第九届ACM程序设计竞赛 正式赛 F.校赛~校赛~【思维+规律题】
校赛~校赛~ Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description SDUT 的校赛是从 20 ...
- 次短路问题(陕西师范大学第九届ACM程序设计竞赛-F 新冠病毒要回家)
求到顶点v的次短路时,有两种情况,要么是到其他某个顶点u的最短路再加上u->v的边,要么是到某个顶点u的次短路再加上u->v的边. 一般我们用Dijkstra求得最短路(无负权边),由此我 ...
- 青岛农业大学第九届ACM程序设计竞赛
Problem A 喆神装书 https://ac.nowcoder.com/acm/contest/906/A 题意:是否能够把所有的书都放在两个背包里. 题解:贪心 C++版本一 /* *@Aut ...
- 2016河南省第九届ACM程序设计竞赛【正式赛真题】
A题:表达式求值 时间限制: 1000 ms | 内存限制: 65535 KB 描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, ...
- “师创杯”山东理工大学第九届ACM程序设计竞赛 正式赛 I.皮卡丘的梦想2【树状数组】水题
皮卡丘的梦想2 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 一天,一只住在 501 的皮 ...
- “师创杯”山东理工大学第九届ACM程序设计竞赛 热身赛 E.上色的纱雾【二分+贪心】
上色的纱雾 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 纱雾画画功力首屈一指,现在她 ...
- 师创杯”山东理工大学第九届ACM程序设计竞赛(网络同步赛)--I皮卡丘的梦想2
作为水题王者前去水了一波山东理工大学的校赛,这道题一个小细节坑了我2个小时,思路其实很简单,就是线段树单点更新的模板,用一个60的数组标记,如果这个区间内有I种类的化石,那么就是1,否则为0,加入新化 ...
- 北京化工大学2018年10月程序设计竞赛部分题解(A,C,E,H)
目录 北京化工大学2018年10月程序设计竞赛部分题解(A,C,E,H) 竞赛事件相关 竞赛链接 竞赛题目 总结 北京化工大学2018年10月程序设计竞赛部分题解(A,C,E,H) 竞赛事件相关 竞赛 ...
- “玲珑杯”郑州轻工业学院第九届ACM程序设计大赛圆满结束
"玲珑杯"郑州轻工业学院第九届ACM程序设计大赛圆满结束 ACM/ICPC国际大学生程序设计竞赛由美国计算机学会主办,是目前国际大学生计算机相关领域公认规模最大.水平最高的赛事之一 ...
最新文章
- Delphi 调用C#编写的WebService 参数为Null解决方法
- Javascript中的\r\n
- Windows Phone 实用开发技巧(9):自定义Windows Phone 页面切换动画
- 方法引用_通过super引用父类的成员方法
- CanalSharp-mysql数据库binlog的增量订阅消费组件Canal的.NET客户端
- 会话信息必须在服务器端,有关会话跟踪技术描述正确的是
- MTK 驱动(76)---如何用adb控制MTKLogger
- 变量作用域、声明提前、作用域链
- 2020深圳杯数学建模C题
- rar、zip优缺点
- Echars 双击Legend 显示自己隐藏其他Legend
- php 微信公众号自定义菜单栏,php实现微信公众号创建自定义菜单
- 《MATLAB金融算法分析实战》之量化投资趋向指标1— python实现
- 学习Redis的基本命令
- git fatal: schannel: next InitializeSecurityContext failed: SEC E CERT EXPIRED (0x80090328)
- maven多模块依赖导入失败以及私服下载包卡死
- 使用HttpURLConnection下载网络文件
- 使用common-fileupload完成文件的上传
- 软件测试专业院校研究生,北化信息科学与技术学院导师赵瑞莲【计算机考研软件测试与软件可靠性方向】...
- Kafka 3.x的解压安装 - Linux
热门文章
- 掩膜区域内像素值_基于颜色空间采样的抠图算法
- IDEA显示类的结构 Alt+F7
- oracle查看字典结构体,Oracle-17-数据字典查看约束信息
- 手机用鸿蒙,魅族“很聪明”:宣布加入鸿蒙,让大家以为手机用鸿蒙,其实不是...
- parted新建分区_扩展分区及文件系统(Linux)
- 丹佛斯冷媒尺汉化下载_制冷系统十大仿真软件!制冷百家网下载
- 九十八、轻松搞定Python中的Markdown系列
- 化工原理期中考,流体
- pyqt5 中QSS
- 小程序 返回多条图文,类似新闻或者博客的展示,其中遇到的bug