CodeForces 572A,B,C

CodeForces 572A

题意:给定两个序列,问能否从第一个序列取出k个数,从第二个序列取出m个数,使得第一个序列取出来的所有数都小于第二个序列取出来的数。


思路:水。因为问的是存在,所以只要在第一个序列中取最小的k个和第二个序列中最大的m个,然后比较第一取出来最大是否小于第二取出来最小。


code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=1e5+5;
const int M=2005;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define ft(i,s,n) for (int i=s;i<=n;i++)
#define frt(i,s,n) for (int i=s;i>=n;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt  rt<<1
#define rrt  rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);int v1[N],v2[N];
int main()
{int n1,n2,k,m;scanf("%d%d",&n1,&n2);scanf("%d%d",&k,&m);ft(i,1,n1) scanf("%d",&v1[i]);ft(i,1,n2) scanf("%d",&v2[i]);if (v1[k]<v2[n2-m+1]) puts("YES");else puts("NO");
}


CodeForces 572B

题意:给定一些股票的买卖情况,然后买高卖低,然后按价格从大到小输出买卖的股票的序列。


思路:直接开两个数组,一个存取买的,一个存取卖的。输出的时候从100000向下(从0到上)遍历即可。


code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=100005;
const int M=2005;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define ft(i,s,n) for (int i=s;i<=n;i++)
#define frt(i,s,n) for (int i=s;i>=n;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt  rt<<1
#define rrt  rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);int mp1[N],mp2[N];
int main()
{int n,m;int d,p;char s[2];scanf("%d %d",&n,&m);cls(mp1,0);cls(mp2,0);ft(i,1,n){scanf("%s %d %d",&s,&p,&d);if (s[0]=='S') mp1[p]+=d;else mp2[p]+=d;}int k=0,t=0;for(int it=0;it<N&&t<m;it++){//if (it%100==0)printf("%d\n",it);//if (it>100000) break;if (mp1[it]>0)  t++,k=it;}for (int j=k;j>=0;j--) if (mp1[j]>0) printf("S %d %d\n",j,mp1[j]);t=0;for(int it=N;it>=0&&t<m;it--){if (mp2[it]>0) printf("B %d %d\n",it,mp2[it]),t++;}
}

CodeForces 572C

题意:给定一个三角形的三边a,b,c和要延长的长度l,问有多少种方法可以使得延长后的图形为三角形。


思路:先找所有的情况,然后减去不满足的情况。当l为i时,情况为c(i+2,2)(i可以去0-l,一路累加即可)。减去分别以a,b,c作为最长边枚举就算把剩下边加上也无法满足三角形的情况。


code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=1000000;
const int M=2005;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define ft(i,s,n) for (int i=s;i<=n;i++)
#define frt(i,s,n) for (int i=s;i>=n;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt  rt<<1
#define rrt  rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);ll sol(ll a,ll b,ll c,ll l){ll t=0;for(ll i=max(b+c-a,0ll);i<=l;i++){ll x=min(l-i,a+i-b-c);t+=(x+1)*(x+2)/2;}return t;
}
int main()
{ll a,b,c,l,ans=0;cin>>a>>b>>c>>l;for(ll i=0;i<=l;i++) ans+=(i+1)*(i+2)/2;ans-=sol(a,b,c,l);ans-=sol(b,c,a,l);ans-=sol(c,a,b,l);cout<<ans<<endl;
}




本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/381762.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[导入]Ajax使用初步

文章来源:http://blog.csdn.net/21aspnet/archive/2007/03/19/1534299.aspx 转载于:https://www.cnblogs.com/zhaoxiaoyang2/archive/2007/03/20/816309.html

CodeForces 570B,C

CodeForces 570B 题意&#xff1a;给定n和m&#xff0c;然后再&#xff08;1-n&#xff09;中随机取出c&#xff0c;求一个m使得 的概率最大&#xff0c;概率一样时输出最小的m。 思路&#xff1a;只需要看1到m-1和m1和n的最大的那一边就可以了&#xff0c;坑是n1的情况和n为…

ASP.NET2.0学习8--WebPart部件

WebPart学习 内容&#xff1a; 功能简介 webpart的五个模式 自定义webpart部件 一、Webpart功能简介 1&#xff0e; 自定义页面内容 2&#xff0e; 自定义页面布局 3&#xff0e; 导入、导出webpart 4&#xff0e; 在不同部件间建立通信 5&#xff0e; 管理和个性化的设置 二、…

uva 10771——Barbarian tribes

题意&#xff1a;n个G族人和m个K族人做成一圈&#xff0c;编号1-n为G&#xff0c;编号n1-m为K组人&#xff0c;没走k步杀死一个人&#xff0c;当杀死两个人的时候判断杀的两人相同组则在第二个位置补K组人&#xff0c;否则G&#xff0c;问最后留下的是什么组的人。 思路&#x…

验证码(转)

把下面代码存为一个文件code.aspx。另一个文件里调用<img src"code.aspx">using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebCo…

uva 10716——Evil Straw Warts Live

题意&#xff1a;给定一个字符串&#xff0c;然后判断最小经过若干次交换然后使这个串变成一个回文串&#xff08;每次可以交换相邻两位&#xff09;。 思路&#xff1a;贪心。如果一个串的奇数字母的个数为奇数个&#xff0c;那么一定是不可能的。以开头和结尾作为两头不断枚举…

ASP.NET 2.0 中实现模板中的数据绑定系列(2)

双向数据绑定 FormView可以通过相关的数据源控件支持自动地更新、插入和删除操作&#xff08;与DetailsView类似&#xff09;。如果要定义编辑或插入的UI&#xff0c;那么除了定义数据项模板&#xff08;ItemTemplate&#xff09;之外&#xff0c;你还要定义EditItemTemplate或…

uva 10479——The Hendrie Sequence

题意&#xff1a;开始一个数0&#xff0c;然后0变成1&#xff0c;后边的变换规则是如果当前是k就在后边加上k-1个0&#xff0c;然后再加上k-1&#xff0c;该问题求该序列的第n个数是多少。 思路&#xff1a;规律的题目。将串分成1&#xff0c;1&#xff0c;2&#xff0c;4&…

如何实现Asp与Asp.Net共享Session

在.net中&#xff0c;Session的存储机制已经与Asp的存储机制不一样&#xff0c;虽然可以在同一个IIS下同时运行asp与aspx&#xff0c;但是它们之间不能传递Session。 之前大批系统应用到了asp&#xff0c;在升级过程中&#xff0c;如果完全抛弃asp来重写&#xff0c;一来工作量…

BestCoder Round #67 (div.2) 1001——N bulbs

题意&#xff1a;给定一个长度为n的灯泡的状态序列&#xff0c;经过每个灯泡时&#xff0c;都要开关一下&#xff08;开变关&#xff0c;关变开&#xff09;&#xff0c;问能否在回到终点的条件下关掉所有的灯。 思路&#xff1a;没出现一个为1的灯&#xff0c;都需要走奇数步来…

JavaScript 参考教程——写在前面

JavaScript 参考教程 JavaScript 参考教程——写在前面 JavaScript 参考教程——JavaScript简介 JavaScript 参考教程——对象化编程 JavaScript 参考教程——文档对象 JavaScript 参考教程——事件处理 写在前面 本教程的性质 本教程是一个初级教程 本教程为未接触过 JavaScri…

uva 11995——I Can Guess the Data Structure!

题意&#xff1a;给定一个包&#xff0c;然后给定这个包的一些操作以此来判断包的数据结构类型。 思路&#xff1a;直接按照stl来模拟即可。 code&#xff1a; #include <bits/stdc.h> using namespace std;const int N1000 10; int t[N],v[N],n;int check_st(){stack&l…

MyGeneration的NHibernate代码生成模版

MyGeneration 是一款免费的代码生成工具&#xff0c;其强大性和易用性都较为人所称道。之前一直在使用DDLLY命名空间的模版来生成代码&#xff0c;久而久之就想着自己来写个&#xff0c;所幸&#xff0c;一晚上的奋战&#xff0c;终于搞出个像模像样的东东出来。如果还有什么没…

uva 1203—— Argus

题意&#xff1a;给定一个阿格斯系统&#xff0c;每个period周期都会产生一次编号为Q_num的事件&#xff0c;任务是模拟前k个事件。 思路&#xff1a;直接按照优先队列的方法来模拟和构造即可。 code&#xff1a; #include <bits/stdc.h> using namespace std;struct nod…

ASP.NET 2.0 的数据源、数据绑定控件概述与区别

一、Render UI 1 GridView GridView 控件用来在表中显示数据源的值。每列表示一个字段&#xff0c;而每行表示一条记录。GridView 控件支持下面的功能&#xff1a; 绑定至数据源控件&#xff0c;如 SqlDataSource。 内置排序功能。 内置更新和删除功能。 内置分页功能。 内…

uva 11997——K Smallest Sums

题意&#xff1a;给定k个含k个数的数列&#xff0c;然后每次从每个序列中取出一个相加&#xff0c;然后问所有的数中前k小的。 思路&#xff1a;将每个表排序后然后插入优先队列中&#xff0c;依次是a[0]b[0],a[0]b[1],然后不断合并到一张表中&#xff0c;最后打印出来即可。 c…

金蝶Apusic应用服务器的数据源管理(转)

1. 前言 在基于 J2EE 平台的应用开发中&#xff0c;大多数的应用都需要跟数据库打交道&#xff1b;而自从接触 JDBC 起&#xff0c;我们便不止一次的被告之&#xff1a;数据库资源是十分宝贵的系统资源&#xff0c;一定要谨慎使用。但令人遗憾的是&#xff0c;在笔者…

CodeForce 180 C ——Letter

题意&#xff1a;给定一定长度的字符串&#xff0c;要求规则必须是所有大写字母必须在小写字母的前面&#xff0c;也就是所谓的11111000模式。 思路&#xff1a;暴力&#xff0c;用O&#xff08;n&#xff09;的算法处理一下字符串&#xff0c;得到每个字符位前面有多少位小写以…

CodeForce 168 C——Wizards and Trolleybuses

题意&#xff1a;给定n个火车&#xff0c;加速度&#xff0c;和铁轨长度&#xff0c;然后是每个火车的最大速度和开始出发的时间&#xff0c;问每辆火车到达终点的时刻。 思路&#xff1a;暴力。考虑路上的状态可能不太容易思考&#xff0c;那就直接考虑起点和终点&#xff0c;…

树形数据查询示例

--树形数据查询示例--作者: 邹建if exists (select * from dbo.sysobjects where id object_id(N[tb]) and OBJECTPROPERTY(id, NIsUserTable) 1)drop table [tb]GO --示例数据create table [tb]([id] int identity(1,1),[pid] int,name varchar(20))insert [tb] select 0,中…