ACM-NEFU15届校赛-大一组
A. 三角形面积
#include <bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c;
double ans,p,tmp;
cin>>a>>b>>c;
p=(a+b+c)*0.5;
tmp=p*(p-a)*(p-b)*(p-c);
ans=sqrt(tmp);
printf("%.1lf", ans);
return 0;
}
B. 最大质因子
唯一分解定理
唯一分解定理又称为算数基本定理,基本内容是:
每个大于1的自然数,要么本身就是质数,要么可以写为2个或以上的质数的积,而且这些质因子按大小排列之后,写法仅有一种方式。
用另一种方法表示就是:
对于任何一个大于1的正整数,都存在一个标准的分解式: N=p1^a1 * p2a2*···*pnan;(其中一系列an为指数,pn为质数)
此定理表明:任何一个大于 1 的正整数都可以表示为素数的积。
然而这道题纯暴力就可解...
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
bool judge(int a)
{
int flag=1;
for (int i=2;i*2<=a;i++)
if (a%i==0) {flag=0; break; }
if (a==1) return 0;
else return flag;
}
int main()
{
int a;
while(cin>>a)
{
for (int i=a;i>=1;i--)
{
if (a%i==0)
if (judge(i))
{
cout<<i<<endl;
break;
}
}
}
return 0;
}
C.杨辉三角
模板例题
#include<bits/stdc++.h>
using namespace std;
int a[21][21];
int main()
{
memset(a, 0, sizeof(a));
a[1][1]=1;
a[2][1]=a[2][2]=1;
int n;
cin>>n;
for(int i=3;i<=n;i++)//行
{
for(int j=1;j<=i;j++)
{
if(j==1 || j==i)
{
a[i][j]=1;continue;
}
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
D."nefu"的数目
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int scount(int p)
{
int sum=0;
int len=s.length();
for(int i=p+1;i<len;i++)
{
if(s[i]=='e')
{
for(int j=i+1;j<len;j++)
{
if(s[j]=='f')
{
for(int k=j+1;k<len;k++)
{
if(s[k]=='u') sum++;
//cout<<sum<<endl;
}
}
}
}
}
return sum;
}
int main()
{
int ans=0,flag=0;
cin>>s;
int len=s.length();
//cout<<len;
for(int i=0;i<len;i++)
{
if(s[i]=='n')
{
ans+=scount(i);
}
//cout<<ans<<endl;
}
cout<<ans<<endl;
return 0;
}
E. 最少修改次数(1)
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int main()
{
string s,t;
while(cin>>s)
{
cin>>t;
int ct=0;
int nums=s.size(),numt=t.size();
int min=1111;
for (int i=0;i<=nums-numt;i++)
{
int j=0;
ct=0;
for (int k=i;k<=i+numt-1;k++)
{
if (s[k]!=t[j]) ct++;
j++;
}
if (ct<min) min=ct;
}
cout<<min<<endl;
}
return 0;
}
F.字典序
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int main()
{
int n;
while(cin>>n)
{
string s1,s,max="0";
for (int i=1;i<=n;i++)
{
int m=i;
s.clear(); s1.clear();
while(m!=0)
{
s+=m%8+'0';
m/=8;
}
for (int j=s.size()-1;j>=0;j--)
{
s1+=s[j];
}
if (s1>max) max=s1;
}
cout<<max<<endl;
}
return 0;
}
G.最小差值
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int main()
{
int n,tot=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
tot+=a[i];
}
long long sum=0,ans=999999;
for(int i=0;i<n;i++)
{
long long com;
sum+=a[i];
com=tot-sum;
ans=min(ans, abs(com-sum));
}
cout<<ans;
return 0;
}
H.染色方案(待补)
I.最大正方形
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[1000+5];
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
sort(a+1, a+1+n);
int ans=0;
for(int i=n;i>=1;i--)
{
if(a[i]>=ans+1)
{
ans++;
}
else break;
}
cout<<ans;
return 0;
}
J.最大值
注意:此题用C++输入输出会超时
#include<iostream>
#include<cstdio>
using namespace std;
const int MAXN=2e5+10;
int a[MAXN];
int times=0;
int main()
{
int n;
while(cin>>n)
{
int maxn=0,next=0;
for(int i=0;i<n;i++)
{
scanf("%d", &a[i]);
maxn=max(maxn, a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]==maxn)
{
times++;
continue;
}
next=max(next, a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]>=maxn && times<=1)
{
printf("%d\n", next);
}
else
{
printf("%d\n", maxn);
}
}
}
return 0;
}
K.循环排列(待补)
L.库特与围棋(待补)
ACM-NEFU15届校赛-大一组的更多相关文章
- 河南省acm第九届省赛--《表达式求值》--栈和后缀表达式的变形--手速题
表达式求值 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, ...
- CSUST 第15届 校赛总结
一直想记录一下自己的比赛,却感觉空间说说有点不适,思考了一番还是打算放到自己的博客园 这次比赛总体来说还是不错,签到还是稳的一批,基本前四小时都在rk1 开局切了几道签到题,然后开了一道思维gcd,正 ...
- 广工十四届校赛 count 矩阵快速幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6470 题意:求,直接矩阵快速幂得f(n)即可 构造矩阵如下: n^3是肯定得变换的,用二项式展开来一点 ...
- Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)
Crack Mathmen TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take security ...
- ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)
题目描述 We know thatIvan gives Saya three problems to solve (Problem F), and this is the firstproblem. ...
- 之江学院第0届校赛 qwb去面试 (找规律)
Description 某一天,qwb去WCfun面试,面试官问了他一个问题:把一个正整数n拆分成若干个正整数的和,请求出这些数乘积的最大值. qwb比较猥琐,借故上厕所偷偷上网求助,聪明的你能帮助他 ...
- 之江学院第0届校赛 qwb与支教 (容斥公式)
description qwb同时也是是之江学院的志愿者,暑期要前往周边地区支教,为了提高小学生的数学水平.她把小学生排成一排,从左至右从1开始依次往上报数. 玩完一轮后,他发现这个游戏太简单了.于是 ...
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
Binomial Coeffcients TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 输入 输出 示例输入 1 1 10 2 9 ...
- Sdut 2151 Phone Numbers (山东省ACM第一届省赛题 A)
题目描述 We know thatif a phone number A is another phone number B's prefix, B is not able to becalled. ...
- 福州大学第十届校赛 & fzu 2128最长子串
思路: 对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减 ...
随机推荐
- 修改element-ui 面包屑的样式
开发者模式,一层层的找啊 .el-breadcrumb__item{ .el-breadcrumb__inner{ &.is-link{ } } } 第二层的class 使用了& 如果 ...
- window 版本下面建立linux命令行终端的方法
这个主要是解决dos系统命令行与linux命令行不匹配的问题. 因此microsoft shop 中开发了很多免费的app可供傻瓜式的安装使用.但是出现了不能下载的问题. 链接如下:https://w ...
- UI自动化之【chromedriver.exe无法删除问题】
想删掉chromedriver.exe,结果提示被打开 在任务管理器中,找到Chromedriver.exe,结束进程
- matlab函数学习笔记
数值精度 显示精度由format函数控制,不影响原始数据,只控制显示精度 命令 说明 long short rat 分数 digits vpa pi的输出 命令 显示结果结果 form ...
- 使用navicat连接本地数据库时,出现错误1251错误
在安装完MySQL的时候,我们现在一般都使用Navicat来连接数据库,可惜出现下面的错误:1251-Client does not support authentication protocol r ...
- Centos8 中安装GitLab
Centos8 中安装GitLab 1,安装依赖 yum install -y curl policycoreutils-python openssh-server centos8没有policyco ...
- 安装win10:我们无法创建新的分区,也无法定位现有分区
操作环境:win10企业版ISO,U盘安装,UEFI启动 解决思路:win10 UEFI 安装需要硬盘在GPT模式,如果直接创建分区默认的是MBR,所以将磁盘转换成GPT,再分配一个EFI空白分区,就 ...
- sqlite bundle 的含义,和 sqlite.dll, SQLite.Interop.dll, System.Data.SQLite.dll 三者之间的关系
sqlite bundle 的含义,和 sqlite.dll, SQLite.Interop.dll, System.Data.SQLite.dll 三者之间的关系. bundle 表示不需要配合 S ...
- 2020/03/25 CSS相关知识点
2020-03-25 16:35:03 又是一个风和日丽的下午!今天的内容比较多 真是令人头大 ,手速又慢所以缺的可能比较多,而且这东西还是多靠实践为好. 文件下载地址: https://share. ...
- 持续集成环境(4)-Jenkins凭证管理
凭据可以用来存储需要密文保护的数据库密码.Gitlab密码信息.Docker私有仓库密码等,以便 Jenkins可以和这些第三方的应用进行交互. 安装Credentials Binding插件 要在J ...