JankTao相亲记

解法:排序

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
const double INF = 1e20;
const double pi = acos(-1.);
int main()
{
int t;
int a[100];
while(cin>>t)
{
while(t--)
{
for(int i=0;i<11;i++)
{
cin>>a[i];
}
sort(a,a+11);
printf("%d\n",a[9]);
}
}
return 0;
}

David的沙漠之路

解法:贪心,尽量往最大的距离走,加上它经历过的加油站中最大的那个,模拟这个过程需要考虑很多情况

#include <iostream>
#include <stdio.h>
#include <queue>
using namespace std;
struct cmp
{
bool operator ()(int &a,int &b)
{
return a<b;
}
};
struct node
{
int x,y;
} e[1005];
int main()
{
priority_queue<int,vector<int>,cmp>que;
int T;
scanf("%d",&T);
while(T--)
{
int n,l,s,x,y,cnt=0,flag=0,f=0;
scanf("%d%d%d",&n,&l,&s);
for(int i=0; i<n; i++)
{
scanf("%d%d",&e[i].x,&e[i].y);
}
e[n].x=0,e[n].y=l;
for(int i=0; i<=n; i++,f=0)
{
x=e[i].x,y=e[i].y;
if(y<=s)
{
que.push(x);
f=1;
//最长可以横跨多少加油站,把他们放在队列里
}
while(y>=s)
{
if(s>=l) break;
if(!f && s==y)
{
que.push(x);
f=1;
//没有横跨,刚刚好到达
}
if(que.empty())
{
printf("TJ\n");
flag=1;
break;
}
int xx=que.top();//取最近的加油站
que.pop();
s+=xx;
cnt++;
}
if(!f) que.push(x);
if(s>=l)
{
printf("%d\n",cnt);
flag=1;
break;
}
if(flag) break;
}
if(!flag) printf("TJ\n");
while(!que.empty()) que.pop();
}
return 0;
}

TJ的文件系统

解法:字符串处理

#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
const int maxn = 22;
int main()
{
int t;
int n;
int i;
int j;
string s,ss;
while(cin>>t)
{
while(t--)
{
string sss="";
int ans;
cin>>n>>s;
for(i=0;i<n;i++)
{
string sss="";
cin>>ss;
ans=ss.find(".");
// cout<<ans<<endl;
for(j=ans+1;j<ss.length();j++)
{
sss+=ss[j];
}
// cout<<sss<<endl;
if(sss==s)
{
cout<<ss<<endl;
}
}
}
} return 0;
}

握手定理

解法:水题

#include <stdio.h>
int main()
{
int SEQ, ACK1, ACK2, T;
scanf("%d", &T);
while(T--)
{
scanf("%d %d %d", &SEQ, &ACK1, &ACK2);
if((ACK1 == SEQ + 1) && (ACK2 == ACK1 + 1))
{
printf("QWN3213\n");
}
else
printf("TJ\n");
}
return 0;
}

Alice AND Bob

解法:模拟

#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
int a[100000],b[100000],c[100000];
int main()
{
int t;
int i,j;
int n,m;
int x,y;
int k;
cin>>t;
while(t--)
{
k=0;
cin>>n>>m;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(i=0;i<n;i++)
{
cin>>x;
a[x]++;
}
for(i=0;i<m;i++)
{
cin>>y;
b[y]++;
}
for(i=0;i<100000;i++)
{
if(a[i]&&b[i])
c[k++]=i;
}
for(i=0;i<k;i++)
{
if(i==0)
{
printf("%d",c[i]);
}
else
{
printf(" %d",c[i]);
}
}
cout<<endl;
}
return 0;
}

建群数据

解法:字符串处理时间

#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
struct P
{
int number;
int hhmmss;
}hehe[100000];
int cmp(P a,P b)
{
if(a.number==b.number)
return a.hhmmss<b.hhmmss;
else
return a.number<b.number;
}
string s,ss,sss,ssss;
string sssss;
int t,n;
int a;
int i,j;
int ans;
int poi;
int num;
int main()
{ cin>>t;
while(t--)
{
poi=1;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a>>s;
hehe[i].number=a;
ss=s.substr(0,2);
sss=s.substr(2,2);
ssss=s.substr(4,2);
// cout<<ss<<" "<<sss<<" "<<ssss<<endl;
hehe[i].hhmmss=((ss[0]-'0')*10+(ss[1]-'0')*1)*3600+((sss[0]-'0')*10+(sss[1]-'0'))*60+((ssss[0]-'0')*10+(ssss[1]-'0'));
}
cin>>sssss;
ss=sssss.substr(0,2);
sss=sssss.substr(2,2);
ssss=sssss.substr(4,2);
ans=((ss[0]-'0')*10+(ss[1]-'0'))*3600+((sss[0]-'0')*10+(sss[1]-'0'))*60+((ssss[0]-'0')*10+(ssss[1]-'0'));
sort(hehe,hehe+n,cmp);
num=hehe[0].hhmmss;
for(int i=1;i<n;i++)
{
if(hehe[i].number!= hehe[i-1].number||hehe[i].hhmmss-num>ans)
{
poi++;
num=hehe[i].hhmmss;
}
}
printf("%d\n",poi);
}
return 0;
}

  

2015年江西理工大学C语言程序设计竞赛(初级组)的更多相关文章

  1. 2018年江西理工大学C语言程序设计竞赛(初级组)一

     C语言竞赛初级组第一.二场答案:https://www.cnblogs.com/xingkongyihao/p/10046918.html  A: 逆序对 时间限制: 1 s      内存限制:  ...

  2. 2017年江西理工大学C语言程序设计竞赛(初级组)

    问题 A: Petr的盒子(初) #include <iostream> #include <stdio.h> #include <algorithm> using ...

  3. 2015年江西理工大学C语言程序设计竞赛(高级组)

    A 解法:DP+二分 dp[i]=max(dp[i],dp[j]+p[i].v)(i>j) dp[i]表示建立i点之后能够获得的最大值 int n,M; struct node { int l, ...

  4. 2014江西理工大学C语言程序设计竞赛高级组题解

    1001 Beautiful Palindrome Number 枚举回文数字前半部分,然后判断该数字是否满足,复杂度为O(sqrt(n))! 1002 Recovery Sequence  本题的核 ...

  5. 2017年江西理工大学C语言程序设计竞赛(高级组)

    问题 A: 求近似值 #include <stdio.h> #include <time.h> #include <stdlib.h> using namespac ...

  6. 2018年江西理工大学C语言程序设计竞赛(高级组) 三角平方数

    题目描述 三角数:形如图a,圆点摆放成等边三角形的数字,则为三角数. (图a) 平方数:形如图b,小方块摆放成正方形的数字,则为平方数. (图b) 那么如果一个数字既是三角形数又是平方数,则称为三角平 ...

  7. 2018年江西理工大学C语言程序设计竞赛高级组部分题解

    B Interesting paths 考察范围:组合数学 此题是机器人走方格的变种,n*m的网格,从(1,1)走到(n,m),首先可以明确,水平要走m-1格,竖直要走n-1格,则走到目的地的任意一条 ...

  8. 2014江西理工大学C语言程序竞赛初级组

    坐公交 解法:略 #include<stdio.h> #include<string> #include<iostream> #include<math.h& ...

  9. 2016年江西理工大学C语言程序设计竞赛(高级组)

    问题 A: jxust 解法:争议的问题(是输入整行还是输入字符串),这里倾向输入字符串,然后判断是否含有jxust就行 #include<bits/stdc++.h> using nam ...

随机推荐

  1. 转:python类型转换、数值操作

    类型转换   1 函数                                    描述 2 int(x [,base ])                      将x转换为一个整数 3 ...

  2. Java基础(43):Java中的Object类与其方法(转)

    Object类 java.lang.Object java.lang包在使用的时候无需显示导入,编译时由编译器自动导入. Object类是类层次结构的根,Java中所有的类从根本上都继承自这个类. O ...

  3. eclipse中修改maven仓储

    1.找到maven的setting文件,修改setting文件: 2.打开eclipce,window->Preference->maven->user Setting

  4. EXTJS 5 开发环境搭建

    WEBstrom eclipse下载: http://www.eclipse.org/downloads/ spket 下载: 安装方式: http://wangke0611.iteye.com/bl ...

  5. struts_22_xwork校验器列表使用说明

    系统提供的校验器列表如下: required (必填校验器,要求field的值不能为null) requiredstring (必填字符串校验器,要求field的值不能为null,并且长度大于0,默认 ...

  6. 静态关键字static

    //静态关键字的使用static //类里面的普通成员是属于对象的,不是属于类的(调用的时候是用对象调用) //什么叫做静态的:类静态成员是属于类的,不是属于每个对象的 //定义静态成员用static ...

  7. 【Ah20160703】咏叹 By C_SUNSHINE

    咏叹 By C_SUNSHINE [试题描述] Salroey拿到了一个1~n的排列A,她想对这个排列进行冒泡排序: counter=0 While A不是升序的 counter=counter+1 ...

  8. mysql笔记01 MySQL架构与历史、Schema与数据类型优化

    MySQL架构与历史 1. MySQL架构推荐参考:http://www.cnblogs.com/baochuan/archive/2012/03/15/2397536.html 2. MySQL会解 ...

  9. shell expr 文件扩展名判断 整数判断

    expr "text.sh" : ".*\.sh" &>/dev/null && echo "yes" ||e ...

  10. python PIL安装

    PIL:Python Imaging Library,已经是Python平台事实上的图像处理标准库了.PIL功能非常强大,但API却非常简单易用. 安装PIL 在Debian/Ubuntu Linux ...