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的更多相关文章

  1. HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分)

    HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分) 传送门:http://acm.hdu.edu.cn/showproblem.php? ...

  2. HDU6578 2019HDU多校训练赛第一场 1001 (dp)

    HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...

  3. [源码解析] 深度学习分布式训练框架 horovod (14) --- 弹性训练发现节点 & State

    [源码解析] 深度学习分布式训练框架 horovod (14) --- 弹性训练发现节点 & State 目录 [源码解析] 深度学习分布式训练框架 horovod (14) --- 弹性训练 ...

  4. HDU6579 2019HDU多校训练赛第一场1002 (线性基)

    HDU6579 2019HDU多校训练赛第一场1002 (线性基) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6579 题意: 两种操作 1.在序列末 ...

  5. HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4902 解题报告:输入一个序列,然后有q次操作,操作有两种,第一种是把区间 (l,r) 变成x,第二种是 ...

  6. 2018牛客网暑假ACM多校训练赛(第四场)B Interval Revisited 动态规划

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-B.html 题目传送门 - https://www.no ...

  7. 2018牛客网暑假ACM多校训练赛(第四场)C Chiaki Sequence Reloaded (组合+计数) 或 数位dp

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-C.html 题目传送门 - https://www.no ...

  8. 2018牛客网暑假ACM多校训练赛(第四场)E Skyline 线段树 扫描线

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-E.html 题目传送门 - https://www.no ...

  9. 2018牛客网暑假ACM多校训练赛(第四场)A Ternary String 数论

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-A.html 题目传送门 - https://www.no ...

随机推荐

  1. hibernate简单应用

    Hibernate 第二章 核心API 和CURD实现 核心API介绍 单表操作方法 查询hql语句 1.认识hibernate 核心思想ORM:实现数据库中的文件一一映射为java中的实体类. 使用 ...

  2. hibernate----hibernate的基础设置

    本次学习的内容是hibernate的基础设置 具体内容为: 一.准备工作 1.新建java工程 2.自动引入相关库(自动生成SessionFactory) 3.将数据库驱动拿进来 4.添加hibern ...

  3. struts----通配符设置

    本次学习的内容是struts通配符配置: 具体内容为: 一.准备工作 1.新建Web工程 2.添加struts:右键点击工程名选择My Eclipse-->点击add struts..--> ...

  4. 基于u盘安装centos6.0

    本人在dell笔记本上尝试安装centos6.0,与win7形成双系统,安装过程如下: 1.使用ultraliso制作u盘启动盘,启动盘以centos6.0的映像文件为源头制作: 2.制作完成后,删除 ...

  5. 玩转html5<canvas>画图

    导航 前言 基本知识 绘制矩形 清除矩形区域 圆弧 路径 绘制线段 绘制贝塞尔曲线 线性渐变 径向渐变(发散) 图形变形(平移.旋转.缩放) 矩阵变换(图形变形的机制) 图形组合 给图形绘制阴影 绘制 ...

  6. MVC中的URL路由(一)

    URL路由系统通过对请求地址进行解析从而得到以目标Controller名称为核心的路由数据.Url路由系统最初是为了实现请求url与物理文件路径分离而建立的,MVC的Url Route是将Url地址与 ...

  7. c#简体繁体转换

     方法一已经亲测,使用正常,方法二貌似不能用. 方法一 /// <summary> /// 中文字符工具类 /// </summary> public static class ...

  8. #ifndef#define#endif的用法

    在网上看到了感觉作者总结得很好,作者辛苦了! #ifndef#define#endif的用法 文件中的#ifndef 头件的中的#ifndef,这是一个很关键的东西.比如你有两个C文件,这两个C文件都 ...

  9. jquery动态添加/删除 tr/td

    <head runat="server"> <title></title> <!--easyui --> <link rel= ...

  10. jdbc的封装

    package com.wjf.helper; import java.io.FileInputStream; import java.io.FileOutputStream; import java ...