福建工程学院第七届ACM程序设计新生赛 (同步赛)
A.关电脑
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int T,h1,m1,s1,h2,m2,s2,t1,t2,ans;
int main(){
while(cin>>T){
for(int cas=;cas<=T;++cas){
cin>>h1>>m1>>s1>>h2>>m2>>s2;
t1=h1*+m1*+s1,t2=h2*+m2*+s2;
ans=t2-t1+(t1>=t2?*:);
cout<<"Case #"<<cas<<": "<<ans<<endl;
}
}
return ;
}
B.保护环境:大的矩形面积减去三个直角三角形的面积即可。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
double a,b;
int main(){
while(cin>>a>>b){
cout<<setiosflags(ios::fixed)<<setprecision()<<(a+b)*a-a*a/-(a+b)*b/-(a-b)*b/<<endl;
}
return ;
}
C.车厘子的守护士兵1.0
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=;
int n,L,R,l[maxn],r,ans;
int main(){
while(cin>>n>>L>>R){
ans=;
for(int i=;i<=n;++i)cin>>l[i];
for(int i=;i<=n;++i){
cin>>r;
if((L<=i&&i<=R)&&(l[i]<=L&&R<=r))ans++;
}
cout<<ans<<endl;
}
return ;
}
D.内心里的一把火:向量叉积求三角形面积,将以P为起点与之相连的三个三角形面积之和与A、B、C三点构成的三角形面积进行比较即可--->相关博文:向量叉积的运用
#include<bits/stdc++.h>
using namespace std;
struct node{int x,y;}nod[];
int a,b,sum,tmp;
inline int cross(node p0,node p1,node p2){
return abs((p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y));
}
int main(){
while(cin>>nod[].x>>nod[].y>>nod[].x>>nod[].y>>nod[].x>>nod[].y){
cin>>nod[].x>>nod[].y,sum=;
for(int i=;i<=;++i)sum+=cross(nod[],nod[i-],nod[i%]);
tmp=cross(nod[],nod[],nod[]);
puts(sum!=tmp?"NO":"YES");
}
return ;
}
E.分配物资
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e6+;
int n,m,q,x,y,z,a[maxn],ans[maxn];bool flag[maxn];
int main(){
while(cin>>n>>m>>q){
memset(ans,,sizeof(ans));
memset(flag,false,sizeof(flag));
memset(a,,sizeof(a));
for(int i=;i<=n;++i)cin>>a[i];
for(int i=;i<=m;++i){
cin>>x>>y;
if(a[x]>=y)///物资充足
flag[i]=true,a[x]-=y;
else ans[i]=y-a[x],a[x]=;///同时置0
}
while(q--){
cin>>z;
if(flag[z])puts("Yes");
else cout<<ans[z]<<endl;
}
}
return ;
}
F.吃饭啦
#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int n,m,a[maxn],x,q,ans,pos;
int main(){
while(cin>>n>>m){
memset(a,,sizeof(a));
for(int i=;i<m;++i)cin>>a[i];
sort(a,a+m);
cin>>q;
for(int i=;i<=q;++i){
cin>>x;
pos=lower_bound(a,a+m,x)-a;
///cout<<"os:"<<pos<<endl;
if(pos==m)cout<<x-a[pos-1]<<endl;///找不到,则为x-a[pos-1]
else if(a[pos]==x)puts("0");///如果在某点上,则为0
else if(!pos)cout<<a[]-x<<endl;///如果比第1个点位置小,则为a[0]-x
else cout<<min(a[pos]-x,x-a[pos-])<<endl;///否则就取到两边绝对值最小的即可
}
}
return ;
}
H.约会
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL x,y,a,z;
int main(){
while(cin>>x>>y>>a){
if(x<)x=-x;
if(y<)y=-y;
z=max(x,y);
if((x+y)&)puts("Not the fate");///如果是奇数,则肯定走不到这个位置
else if((!x&&!y&&a)||(a<z)||((a-z)&))puts("You are lying");///特殊情况x==0&&y==0&&a>0,肯定在说谎或者走的步数a小于z,则肯定还没走到或者a>z,则剩下的步数应为偶数,否则肯定是在说谎
else puts("We are together");
}
return ;
}
I.这是一个沙雕题I
#include<bits/stdc++.h>
using namespace std;
char str[];int k,fuck,cnt[];string ans,tmp;bool flag;
int main(){
while(cin>>k){
cin>>str,memset(cnt,,sizeof(cnt)),ans=tmp="",flag=false,fuck=strlen(str);
for(int i=;str[i];++i)cnt[str[i]-'a']++;
for(int i=;i<;++i)
if(cnt[i]&&cnt[i]%k!=)flag=true;///如果不能被k整除,那么肯定不能构成k个相同的字符串
if(flag){puts("-1");continue;}
for(int i=;i<;++i){
if(cnt[i]){///单个字符串拥有该字母的个数为cnt[i]/k
for(int j=;j<=cnt[i]/k;++j)tmp+=i+'a';
}
}
while(k--)ans+=tmp;///重复k次表示重新排列
cout<<ans<<endl;
}
return ;
}
J.这是一个沙雕题II:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,k,ans,tmp1,tmp2,cnt1,cnt2,i,a[],b[],c[]={};
int main(){
for(i=;i<;++i)c[i]=c[i-]*;///预处理10^i
while(cin>>n>>k){
ans=tmp1=n,tmp2=n-k,cnt1=cnt2=;
while(tmp1)a[cnt1++]=tmp1%,tmp1/=,b[cnt2++]=tmp2%,tmp2/=;
for(i=cnt1-;i>=&&a[i]==b[i];--i);///遇到第一位不相等就退出,剩下的每一位填9
if(i>&&((n+1LL)%c[i]))ans=n-n%c[i]-;///前提是至少要在十位以上的某个位出现的数字不同即i>0,从那一位起剩下的位都填9,但还需要有一种特判情况,就是如果该数剩下的位已都是9,那么这时就不能再改变,因为要取最大,那么含尾数9最大的数就是n-n%a[i]-1。
cout<<ans<<endl;///否则输出原数字
}
return ;
}
K.这是一个沙雕题III
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int T;LL k,x,y,z;
int main(){
while(cin>>T){
while(T--){
cin>>k>>x>>y;///最多能用z张抵扣券
if((z=k/x)*x<=k&&k<=z*y)puts("Y");
else puts("N");
}
}
return ;
}
福建工程学院第七届ACM程序设计新生赛 (同步赛)的更多相关文章
- 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...
- 河南省第七届ACM程序设计大赛赛后总结
我们学校ACM集训开始于4月5号(清明节),5月25日在郑州解放军信息工程大学举办,集训耗时50天,但是感觉效果还行,但是也不是太好:我们也已经尽力了,虽然说只拿了个银牌,每份收获的背后,都会有辛勤的 ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)G a+b+c+d=? (16进制与LL范围)
链接:https://ac.nowcoder.com/acm/contest/338/G来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K6 ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)
RANK 0 题数 0 期末复习没有参加,补几道喜欢的题. A: AFei Loves Magic 签到 思路 :不需考虑 碰撞 直接计算最终状态即可. #include<bits/stdc ...
- 河南省第七届ACM程序设计大赛总结
省赛总结 首先说说比赛时的情况吧,刚开始的时候我的任务就是翻译英文题目,找出比较水的题目,他们两个直接找中文水题切,其实每次比赛我们都是这样配合的,由于他们的判题系统一开始存在问题,交的正确的代码给判 ...
- 湖南大学第十四届ACM程序设计新生杯 E.Easy Problem
E.Easy Problem Description: Zghh likes number, but he doesn't like writing problem description. So h ...
- 湖南大学第十四届ACM程序设计新生杯 Dandan's lunch
Dandan's lunch Description: As everyone knows, there are now n people participating in the competiti ...
- ZZUOJ-1195-OS Job Scheduling(郑州大学第七届ACM大学生程序设计竞赛E题)
1195: OS Job Scheduling Time Limit: 2 Sec Memory Limit: 128 MB Submit: 106 Solved: 35 [id=1195&quo ...
- 山东省第七届ACM省赛------Memory Leak
Memory Leak Time Limit: 2000MS Memory limit: 131072K 题目描述 Memory Leak is a well-known kind of bug in ...
随机推荐
- ViewGroup如何分发事件
dispatchTouchEvent事件派发显示隧道方式.再是冒泡方式隧道方式传递,直道某一个元素消耗此事件,由上至下逐层分发视图.冒泡方式传递,当某个视图消耗事件后其return boolean 是 ...
- GuozhongCrawler系列教程 (5) TransactionRequest具体解释
为了实现和维护并发抓取的属性信息提供线程安全的事务请求.TransactionRequest是一个抽象类自己不能设置Processor,却须要实现 TransactionCallBack接口.Tran ...
- NPOI实现Excel导入
导入功能实现: ]; GetExtensionsFromFileStream(file.InputStream); using NPOI.XSSF.UserModel; public List< ...
- 使用virtualenv, uwsgi, nginx来布署flask
本文讲述了怎样使用virtualenv, uwsgi, nginx来布署flask的步骤. 升级软件包 运行下面命令,保证你的机器安装了最新的软件包. sudo apt-get update sudo ...
- Android — 长按ListView 利用上下文菜单(ActionMode) 进行批量事件处理
好久没写博客拉``````` 近期最终略微闲一点了``````` 无聊拿手机清理短信.发现批量事件的处理还是挺管用的`````` 那么自己也来山寨一记看看效果吧````` 闲话少说,首先,我们来看下手 ...
- HDU 6183 Color it cdq分治 + 线段树 + 状态压缩
Color it Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others) Pro ...
- 4408: [Fjoi 2016]神秘数
4408: [Fjoi 2016]神秘数 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 452 Solved: 273 [Submit][Stat ...
- 最长公共上升子序列 (poj 2127) (Greatest Common Increasing Subsequence)
\(Greatest Common Increasing Subsequence\) 大致题意:给出两个长度不一定相等的数列,求其中最长的公共的且单调递增的子序列(需要具体方案) \(solution ...
- (C)strcpy ,strncpy与strlcpy
1. 背景 好多人已经知道利用strncpy替代strcpy来防止缓冲区越界. 但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式. 2. strcpy strcpy 是依据 /0 作为 ...
- bootstrap学习心得
一.html的编写规范 <!DOCTYPE html> <html lang="zh-CN"> <head> <title>Page ...