四校训练 warm up 14
A:Pythagoras's Revenge
代码:
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
ll a;
while(scanf("%lld",&a)!=EOF)
{
if (a==) break;
ll aa=a*a;
int ans=;
for(ll i=;i<a;i++)
{
ll x=i;
if (aa%i!=) continue;
ll y=aa/i;
if ((x+y)*(y-x)%!=) continue;
if ((y-x)/>a) ans++;
}
printf("%d\n",ans);
}
return ;
}
B:Digit Solitaire
代码:
#include<cstdio>
using namespace std; int main()
{
int b;
while(scanf("%d",&b)&&b)
{
printf("%d",b);
while(b/>)
{
int tmp=;
while(b>)
{
tmp*=b%;
b/=;
}
b=tmp;
printf(" %d",tmp);
}
printf("\n");
}
return ;
}
C:Any Way You Slice It
计算几何
代码:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 150
#define pi acos(-1)
#define eps 1e-5
using namespace std; struct point
{
double x,y;
point(double x=,double y=):x(x),y(y){}
} p[maxn];
point operator-(point a,point b){return point(a.x-b.x,a.y-b.y);}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int dcmp(double x)
{
if(fabs(x)<eps)return ;
else return x<?-:;
}
bool xiangjiao(point a1,point a2,point b1,point b2)
{
double c1=cross(a2-a1,b1-a1),c2=cross(a2-a1,b2-a1);
double c3=cross(b2-b1,a1-b1),c4=cross(b2-b1,a2-b1);
return dcmp(c1)*dcmp(c2)<&&dcmp(c3)*dcmp(c4)<;
} int main()
{
int n;
double d,x;
while(scanf("%d",&n)&&n)
{
bool flag=;
int ans=;
p[]= point(,);
double ang=pi/;
for(int i=; i<n; i++)
{
scanf("%lf%lf",&d,&x);
ang+=d/*pi;
p[i+].x=p[i].x+cos(ang)*x;
p[i+].y=p[i].y+sin(ang)*x;
if(i>&&flag==)
{
for(int j=; j<i; j++)
{
if(xiangjiao(p[j],p[j+],p[i],p[i+])==)
{
flag=;
ans=i+;
}
}
} }
if(flag==)puts("SAFE");
else printf("%d\n",ans);
}
return ;
}
D:Is the Name of This Problem
代码:
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#define maxn 109
using namespace std; char s1[maxn];
char s2[maxn];
int main()
{
// freopen("in.txt","r",stdin);
while(gets(s1))
{
bool flag=;
memset(s2,,sizeof s2);
if(s1[]=='E'&&s1[]=='N'&&s1[]=='D'&&!s1[])break;
int l=strlen(s1);
if(s1[]!='\"')
{
puts("not a quine");
continue;
}
int i,cnt=;
for(i=; i<l; i++)
{
if(s1[i]=='\"')break;
s2[cnt++]=s1[i];
}
if(cnt==)
{
puts("not a quine");
continue;
}
i++;
if(s1[i]!=' ')
{
flag=;
}
i++;
int j=;
for(;j<cnt;j++)
{
if(s2[j]>='A'&&s2[j]<='Z')continue;
else if(s2[j]==' ')continue;
else
{
flag=;break;
}
}
j=;
for(;i<l;i++)
{
if(s1[i]!=s2[j])
{
flag=;break;
}
j++;
if(j>cnt){flag=;break;}
}
if(j<cnt)flag=;
if(flag)printf("Quine(%s)\n",s2);
else puts("not a quine");
}
return ;
}
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#define maxn 109
using namespace std; char s1[maxn];
char s2[maxn];
int main()
{
// freopen("in.txt","r",stdin);
while(gets(s1))
{
bool flag=;
memset(s2,,sizeof s2);
if(s1[]=='E'&&s1[]=='N'&&s1[]=='D'&&!s1[])break;
int l=strlen(s1);
if(s1[]!='\"')
{
puts("not a quine");
continue;
}
int i,cnt=;
for(i=; i<l; i++)
{
if(s1[i]=='\"')break;
s2[cnt++]=s1[i];
}
if(cnt==)
{
puts("not a quine");
continue;
}
i++;
if(s1[i]!=' ')
{
flag=;
}
i++;
int j=;
for(;j<cnt;j++)
{
if(s2[j]>='A'&&s2[j]<='Z')continue;
else if(s2[j]==' ')continue;
else
{
flag=;break;
}
}
j=;
for(;i<l;i++)
{
if(s1[i]!=s2[j])
{
flag=;break;
}
j++;
if(j>cnt){flag=;break;}
}
if(j<cnt)flag=;
if(flag)printf("Quine(%s)\n",s2);
else puts("not a quine");
}
return ;
}
F:LRU Caching
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 1000009
using namespace std;
int frecount;
int n;
struct node
{
int id;
int fre;
bool operator <(const node &t)const
{
return fre<t.fre;
}
} no[]; void shuchu()
{
sort(no,no+n);
for(int i=; i<n; i++)
{
if(no[i].id>)
printf("%c",no[i].id+'A'-);
}
puts("");
} void add(char s)
{
bool flag=;
frecount++;
for(int i=; i<n; i++)
if(no[i].id==s-'A'+)
{
no[i].fre=frecount;
flag=;
break;
}
if(flag==)
{
sort(no,no+n);
no[].id=s-'A'+;
no[].fre=frecount;
}
} char s[maxn]; int main()
{
// freopen("in.txt","r",stdin);
int ca=;
while(scanf("%d",&n)&&n)
{
printf("Simulation %d\n",ca++);
frecount=;
for(int i=; i<n; i++)
{
no[i].id=-;
no[i].fre=-;
}
scanf("%s",s);
int l=strlen(s);
for(int i=; i<l; i++)
{
if(s[i]=='!')
shuchu();
else add(s[i]);
}
}
return ;
}
G:Jugglefest
代码:
#include<cstdio>
#include<cstring>
using namespace std;
int p[];
char s[];
int main()
{
// freopen("in.txt","r",stdin);
int n;
while(scanf("%d",&n)&&n)
{
bool flag=;
memset(p,,sizeof p);
memset(s,,sizeof s);
for(int i=; i<n; i++)
{
scanf("%d",&p[i]);
}
int cnt=,num=;
for(int i=; i<; i++)
{
if(s[i]==)s[i]='A'+cnt++;
if(s[i+p[num%n]]!=&&(i+p[num%n]<))flag=;
else s[i+p[num%n]]=s[i];
num++;
}
if(flag)
{
for(int i=;i<;i++)
putchar(s[i]);
puts("");
}
else puts("CRASH");
}
return ;
}
四校训练 warm up 14的更多相关文章
- HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分)
HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分) 传送门:http://acm.hdu.edu.cn/showproblem.php? ...
- HDU6578 2019HDU多校训练赛第一场 1001 (dp)
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...
- [源码解析] 深度学习分布式训练框架 horovod (14) --- 弹性训练发现节点 & State
[源码解析] 深度学习分布式训练框架 horovod (14) --- 弹性训练发现节点 & State 目录 [源码解析] 深度学习分布式训练框架 horovod (14) --- 弹性训练 ...
- HDU6579 2019HDU多校训练赛第一场1002 (线性基)
HDU6579 2019HDU多校训练赛第一场1002 (线性基) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6579 题意: 两种操作 1.在序列末 ...
- HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4902 解题报告:输入一个序列,然后有q次操作,操作有两种,第一种是把区间 (l,r) 变成x,第二种是 ...
- 2018牛客网暑假ACM多校训练赛(第四场)B Interval Revisited 动态规划
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-B.html 题目传送门 - https://www.no ...
- 2018牛客网暑假ACM多校训练赛(第四场)C Chiaki Sequence Reloaded (组合+计数) 或 数位dp
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-C.html 题目传送门 - https://www.no ...
- 2018牛客网暑假ACM多校训练赛(第四场)E Skyline 线段树 扫描线
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-E.html 题目传送门 - https://www.no ...
- 2018牛客网暑假ACM多校训练赛(第四场)A Ternary String 数论
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-A.html 题目传送门 - https://www.no ...
随机推荐
- inux设置普通用户无密码sudo权限
配置普通用户无密码sudo权限: root用户进入到Linux系统的/etc目录下 cd /etc 将sudoers文件赋予写的权限 chmod u+w /etc/sudoers 编辑sudoers文 ...
- Verilog Tips and Interview Questions
Verilog Interiew Quetions Collection : What is the difference between $display and $monitor and $wr ...
- 获取tcl开发工具
本篇文章对tcl脚本的解释工具获取和编辑工具进行一个简单的介绍,工欲善其事,必先利其器,掌握好解释工具的用法,能够使后续的脚本开发工作更加顺利.从源代码的获取到编译,详细解释在linux和window ...
- C#扫盲之:带你掌握C#的扩展方法、以及探讨扩展方法的本质、注意事项
1.为什么需要扩展方法 .NET3.5给我们提供了扩展方法的概念,它的功能是在不修改要添加类型的原有结构时,允许你为类或结构添加新方法. 思考:那么究竟为什么需要扩展方法呢,为什么不直接修改原有类型呢 ...
- MySQL索引视图
一.索引 索引是存放在模式(schema)中的一个数据库对象,索引的作用就是提高对表的检索查询速度, 索引是通过快速访问的方法来进行快速定位数据,从而减少了对磁盘的读写操作. 索引是数据库的一个对象, ...
- photoshop 常用快捷键大全
一.文件新建 CTRL+N打开 CTRL+O 打开为 ALT+CTRL+O关闭 CTRL+W保存 CTRL+S 另存为 CTRL+SHIFT+S另存为网页格式 CTRL+ALT+S打印设置 CTRL+ ...
- iOS控件——UIView与UIImageView播放动画的实现方法
1.UIView //初始状态 [UIView animateWithDuration:(int) animations:^{ //最终状态 }completion:^(BOOL finished){ ...
- JamCam创业故事:辞掉工作,去开发一个应用
编者按:这是JamCam创始人的自述.这家初创公司提供的应用很简单,但是极为成功:有了JamCam,你所录制的视频会自动添加你正在iPhone中聆听的音乐,作为视频的背景音乐.和朋友分享时是不是方便多 ...
- ubuntu 安装qt 5.1的各种错误
错误太多了,我就不一一说 了,直接一条命令搞定 sudo apt-:i386 libx11-:i386 libglib2.-:i386 libfreetype6:i386 libSM6:i386 li ...
- SSH中调用另一action的方法(chain,redirect)
从一个Action直接跳到另一个Action中,Struts提供了两种结果类型可以实现:chain.redirect. 从Servlet中学到重定向是不能保留参数的,也就是说重定向了 ...