codeforces #332 div2
A.
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int a,b,c;
int ans1,ans2,ans3;
int main()
{
//freopen("input.txt","r",stdin);
cin>>a>>b>>c;
int ans1=2*(a+b);
int ans2=2*(a+c);
int ans3=2*(b+c);
int ans4=a+b+c;
int w=min(min(ans1,ans2),min(ans3,ans4));
cout<<w<<endl;
}
B.
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int n,m;
int ans[100005];
int w[100005];
map<int,int> q;
map<int,int>::iterator it;
int flag=2;
int main()
{
// freopen("input.txt","r",stdin);
int t;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d",&t);
q.insert(pair<int,int>(t,i+1));
ans[t]++;
}
for(int i=0;i<m;i++)
{
scanf("%d",&t);
it=q.find(t);
if(it!=q.end()&&flag!=1)
{
w[i]=it -> second;
if(ans[it->first]>1)
flag=0;
}
else
flag=1;
}
if(flag==1)
printf("Impossible\n");
else if(flag==0)
printf("Ambiguity\n");
else
{
printf("Possible\n");
for(int i=0;i<m;i++)
printf("%d ",w[i]);
}
}
C.
贪心:前缀最大值不大于后缀最小值
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int a[100005];
int ma[100005];
int mi[100005];
int main()
{
int n,ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
ma[0]=-1;
for(int i=1;i<=n;i++)
{
ma[i]=max(ma[i-1],a[i]);
}
mi[n+1]=1e9+5;
mi[n]=a[n];
for(int i=n-1;i>=1;i--)
{
mi[i]=min(mi[i+1],a[i]);
}
for(int i=1;i<=n;i++)
{
if(ma[i]<=mi[i+1])
ans++;
}
printf("%d\n",ans);
}
D.数学题
f(n,m)=∑k=(n−k+1)(m−k+1)
f(n,m)=(n*n/2+n/2)m+n*n+n−(n+2)(n+1)n/2+n(n+1)(2*n+1)/6
枚举n
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> p;
long long n;
long long ans,x,y;
vector<p>t; int main()
{
scanf("%I64d",&n);
int xx=6*pow(n,1.0/3.0);
// printf("%d\n",xx);
for(long long i=1;i<=xx;i++)
{
x=(i*i+i)/2;
y=n-i*i-i+(i+2)*(i+1)*i/2-(i+1)*i*(2*i+1)/6;
if(y>0&&y%x==0)
{
ans++;
long long dd=y/x;
if(dd>=i){
t.push_back(make_pair<LL,LL>(i,dd));
t.push_back(make_pair<LL,LL>(dd,i));
}
}
}
sort(t.begin(),t.end());
int len=unique(t.begin(),t.end())-t.begin();
printf("%d\n",len);
for(int i=0;i<len;i++)
{
printf("%I64d %I64d\n",t[i].first,t[i].second);
}
}
codeforces #332 div2的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- codeforces #332 div 2 D. Spongebob and Squares
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
随机推荐
- CDZSC_2015寒假新人(1)——基础 h
Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...
- (原)Understand中查看函数调用关系
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/4994551.html 1. 选中某函数,如_tmain,右键“Graphical Views——Cal ...
- Ubuntu13.04手动安装nvidia显卡驱动
1. 下载最新版的nVidia驱动,命名为NVIDIA.run. http://www.nvidia.com/page/drivers.html 2.编辑blacklist.conf. sudo ge ...
- 关于onpropertychange与oninput的兼容问题
关于onpropertychange与oninput的用法,网上一大堆,但还是有不兼容的时候,比如说,我想计下,一个input的值改变了多少次,如果写成兼容写法就为 <!doctype html ...
- C# 创建execl文件 并且填充数据
第一步:引用文件 using NPOI.HSSF.UserModel;using System.Data;using CTUClassLibrary;using System.IO;using NPO ...
- 在JS中得到表单中各项的值
var form = document.getElementById("change");var pageNo = form.pageno.value;
- 解决图片元素下多余空白的BUG
1.将图片转换为块级对象 即,设置img为“display:block;”.在本例中添加一组CSS代码:“#sub img {display:block;}”. 2.设置图片的垂直对齐方式 ...
- DLL技术应用03 - 零基础入门学习Delphi46
DLL技术应用03 让编程改变世界 Change the world by program DLL的加载和调用 [caption id="attachment_2685" alig ...
- Django uplodify 多文件同时上传
Js代码: //批量上传按钮 $('#fileupload').uploadify ({ 'swf' : '/CoveragePlaform/media/uploadify-3.2/uploadify ...
- DropBox与Box的区别,包括直接的投资人的评价(本地Sync可能还是挺重要的)
作者:曲凯链接:http://www.zhihu.com/question/22207220/answer/20642357来源:知乎著作权归作者所有,转载请联系作者获得授权. Box和Dropbox ...