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届校赛-大一组的更多相关文章

  1. 河南省acm第九届省赛--《表达式求值》--栈和后缀表达式的变形--手速题

    表达式求值 时间限制:1000 ms | 内存限制:65535 KB 难度:3   描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, ...

  2. CSUST 第15届 校赛总结

    一直想记录一下自己的比赛,却感觉空间说说有点不适,思考了一番还是打算放到自己的博客园 这次比赛总体来说还是不错,签到还是稳的一批,基本前四小时都在rk1 开局切了几道签到题,然后开了一道思维gcd,正 ...

  3. 广工十四届校赛 count 矩阵快速幂

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6470 题意:求,直接矩阵快速幂得f(n)即可 构造矩阵如下: n^3是肯定得变换的,用二项式展开来一点 ...

  4. Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)

    Crack Mathmen TimeLimit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Since mathmen take security ...

  5. ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)

    题目描述 We know thatIvan gives Saya three problems to solve (Problem F), and this is the firstproblem. ...

  6. 之江学院第0届校赛 qwb去面试 (找规律)

    Description 某一天,qwb去WCfun面试,面试官问了他一个问题:把一个正整数n拆分成若干个正整数的和,请求出这些数乘积的最大值. qwb比较猥琐,借故上厕所偷偷上网求助,聪明的你能帮助他 ...

  7. 之江学院第0届校赛 qwb与支教 (容斥公式)

    description qwb同时也是是之江学院的志愿者,暑期要前往周边地区支教,为了提高小学生的数学水平.她把小学生排成一排,从左至右从1开始依次往上报数. 玩完一轮后,他发现这个游戏太简单了.于是 ...

  8. Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)

    Binomial Coeffcients TimeLimit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 输入 输出 示例输入 1 1 10 2 9 ...

  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. ...

  10. 福州大学第十届校赛 & fzu 2128最长子串

    思路: 对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减 ...

随机推荐

  1. redis字段使用说明

    Set(集合)增删改查: #删除当前选择数据库中的所有key127.0.0.1:6379> flushdbOK#生成set集合,添加4个数据127.0.0.1:6379> sadd set ...

  2. openSUSE Tumbleweed 安装原生微信

    优麒麟网站上有![微信原生版](https://www.ubuntukylin.com/applications/106-cn.html)提供下载. 之前用 Ubuntu的时候,直接安装就可以使用. ...

  3. 关于pandas的一些用法

    pandas用法之前我总是把他想的无比复杂.其实也是比较简单的,这个东西在做数据统计的时候还是挺好用的. 然后这里列举几个比较好用的几段代码.偏向数据透视类型pivot的,导出方式是直接在IDE 生成 ...

  4. 树形DP【初级版】

    START: 2021-08-14 10:00:37 在树形DP中,我们可以用数据模拟出一张图,一般是一棵树或是森林,所有的节点一般最多只有一个父节点.并且树里面没有重边或者环, 因此,一颗有N个节点 ...

  5. Ext.form.ComboBox 中如何移除事件,如何添加事件,动态设置事件

    Ext.form.ComboBox 中如何移除事件,如何添加事件 背景: 希望Ext.form.ComboBox动态设置forceSelection属性,动态控制Combobox的可读可写状态,是否允 ...

  6. HTTPS的实现原理 ---- 核心 SSL/TLS协议

    是在应用层和 传输层之间 添加的 安全层(SSL/TLS协议) 端口号 :HTTP 默认是 80,HTTPS 默认是 443. URL 前缀 :HTTP 的 URL 前缀是 http://,HTTPS ...

  7. dockerflie

    FROM newbe36524/aspnet:5.0-buster-slim AS base ENV TZ=Asia/Shanghai WORKDIR /app EXPOSE 3400 3400 RU ...

  8. SQLyog中创建的数据库在idea找不到

    在里面把需要的数据库

  9. 解决VUE中document.documentElement.scrollTop为0(转)

    原文地址:https://blog.csdn.net/WDCCSDN/article/details/82107374 Vue中document.documentElement.scrollTop的值 ...

  10. c语言中%d %f %c %s等的区别

    %d整型输出(%ld长整型输出)%f以小数形式输出,默认情况下保留小数点6位 这里是引用%f和%lf分别是float类型和double类型用于格式化输入输出时对应的格式符号.其中:float,单精度浮 ...